This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coser. See http://git.codelutin.com/coser.git commit 73b10393375e730e0155c6f7f5a970f1b7dd8ddc Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Jun 18 17:59:46 2015 +0200 clean code --- .../fr/ifremer/coser/CoserApplicationContext.java | 2 +- .../java/fr/ifremer/coser/CoserBusinessConfig.java | 10 +- .../fr/ifremer/coser/CoserBusinessException.java | 15 +- .../java/fr/ifremer/coser/CoserClassLoader.java | 18 +- .../main/java/fr/ifremer/coser/CoserConstants.java | 35 +- .../java/fr/ifremer/coser/CoserServiceContext.java | 38 - .../fr/ifremer/coser/CoserTechnicalException.java | 3 +- .../src/main/java/fr/ifremer/coser/CoserUtils.java | 7 +- .../coser/DefaultCoserApplicationContext.java | 2 +- .../ifremer/coser/bean/AbstractDataContainer.java | 24 +- .../java/fr/ifremer/coser/bean/AbstractEntity.java | 12 +- .../main/java/fr/ifremer/coser/bean/Control.java | 10 +- .../fr/ifremer/coser/bean/EchoBaseProject.java | 4 +- .../java/fr/ifremer/coser/bean/GlobalResult.java | 2 +- .../java/fr/ifremer/coser/bean/IndicatorMap.java | 5 +- .../main/java/fr/ifremer/coser/bean/Project.java | 41 +- .../java/fr/ifremer/coser/bean/RSufiResult.java | 6 +- .../fr/ifremer/coser/bean/RSufiResultPath.java | 8 +- .../main/java/fr/ifremer/coser/bean/Selection.java | 37 +- .../fr/ifremer/coser/bean/SpeciesFieldType.java | 4 +- .../java/fr/ifremer/coser/bean/SpeciesListMap.java | 2 +- .../java/fr/ifremer/coser/bean/SpeciesMap.java | 2 +- .../main/java/fr/ifremer/coser/bean/ZoneMap.java | 10 +- .../ifremer/coser/command/CategoryLineCommand.java | 6 +- .../java/fr/ifremer/coser/command/Command.java | 42 +- .../ifremer/coser/command/DeleteLineCommand.java | 106 +- .../ifremer/coser/command/MergeSpeciesCommand.java | 122 +- .../ifremer/coser/command/ModifyFieldCommand.java | 159 ++- .../fr/ifremer/coser/control/ControlError.java | 54 +- .../ifremer/coser/control/ControlErrorGroup.java | 10 +- .../coser/control/DiffCatchLengthControlError.java | 6 +- .../ifremer/coser/control/SpeciesControlError.java | 12 +- .../coser/control/SpeciesLengthControlError.java | 6 +- .../fr/ifremer/coser/data/AbstractDataEntity.java | 14 +- .../src/main/java/fr/ifremer/coser/data/Catch.java | 37 +- .../src/main/java/fr/ifremer/coser/data/Haul.java | 56 +- .../main/java/fr/ifremer/coser/data/Length.java | 57 +- .../main/java/fr/ifremer/coser/data/Strata.java | 28 +- .../java/fr/ifremer/coser/result/CoserCommand.java | 4 +- .../ifremer/coser/result/CoserCommandFactory.java | 4 +- .../coser/result/CoserMainRepositoryProvider.java | 2 +- .../java/fr/ifremer/coser/result/CoserRequest.java | 4 +- .../ifremer/coser/result/CoserRequestBuilder.java | 6 +- .../ifremer/coser/result/CoserRequestContext.java | 4 +- .../ifremer/coser/result/CoserRequestExecutor.java | 14 +- .../java/fr/ifremer/coser/result/CoserResult.java | 4 +- .../coser/result/DefaultCoserRequestContext.java | 2 +- .../coser/result/DuplicatedResultException.java | 4 +- .../coser/result/NoResultFoundException.java | 4 +- .../result/NoResultRepositoryFoundException.java | 2 +- .../ResultRepositoryInitializationException.java | 5 +- .../java/fr/ifremer/coser/result/ResultType.java | 4 +- .../coser/result/repository/ResultRepository.java | 4 +- .../repository/ResultRepositoryProvider.java | 4 +- .../result/repository/ResultRepositoryType.java | 6 +- .../repository/echobase/EchoBasePredicates.java | 2 +- .../echobase/EchoBaseResultRepository.java | 2 +- .../echobase/EchoBaseResultRepositoryProvider.java | 2 +- .../echobase/EchoBaseResultRepositoryType.java | 2 +- .../echobase/command/AbstractEchoBaseCommand.java | 9 +- .../echobase/command/CopyRepositoryCommand.java | 4 +- .../echobase/command/DeleteResultsCommand.java | 2 +- .../command/ExtractRawDataAndResultsCommand.java | 3 +- .../echobase/command/ExtractRawDataCommand.java | 2 +- .../echobase/command/GetAllResultsCommand.java | 2 +- .../GetCommunityIndicatorResultDataCommand.java | 2 +- .../GetCommunityIndicatorResultGraphCommand.java | 2 +- ...dicatorsForCommunityIndicatorResultCommand.java | 2 +- ...dicatorsForExtractRawDataAndResultsCommand.java | 2 +- ...icatorsForPopulationIndicatorResultCommand.java | 2 +- .../echobase/command/GetMapResultCommand.java | 2 +- ...tMatchingRepositoryTypeForMapResultCommand.java | 2 +- .../GetPopulationIndicatorResultDataCommand.java | 2 +- .../GetPopulationIndicatorResultGraphCommand.java | 2 +- .../echobase/command/GetResultNameCommand.java | 2 +- ...tSpeciesForExtractRawDataAndResultsCommand.java | 2 +- .../command/GetSpeciesForMapResultCommand.java | 2 +- ...SpeciesForPopulationIndicatorResultCommand.java | 2 +- ...ciesListForCommunityIndicatorResultCommand.java | 2 +- ...GetZonesForCommunityIndicatorResultCommand.java | 2 +- ...GetZonesForExtractRawDataAndResultsCommand.java | 2 +- .../command/GetZonesForExtractRawDataCommand.java | 2 +- .../command/GetZonesForMapResultCommand.java | 2 +- ...etZonesForPopulationIndicatorResultCommand.java | 2 +- .../result/repository/legacy/LegacyPredicates.java | 2 +- .../repository/legacy/LegacyResultRepository.java | 2 +- .../legacy/LegacyResultRepositoryProvider.java | 4 +- .../legacy/LegacyResultRepositoryType.java | 2 +- .../legacy/command/AbstractLegacyCommand.java | 316 +----- .../legacy/command/DeleteResultsCommand.java | 2 +- .../command/ExtractRawDataAndResultsCommand.java | 3 +- .../legacy/command/ExtractRawDataCommand.java | 2 +- .../legacy/command/GetAllResultsCommand.java | 4 +- .../GetCommunityIndicatorResultDataCommand.java | 2 +- .../GetCommunityIndicatorResultGraphCommand.java | 2 +- ...dicatorsForCommunityIndicatorResultCommand.java | 4 +- ...dicatorsForExtractRawDataAndResultsCommand.java | 4 +- ...icatorsForPopulationIndicatorResultCommand.java | 4 +- .../legacy/command/GetMapResultCommand.java | 4 +- ...tMatchingRepositoryTypeForMapResultCommand.java | 2 +- .../GetPopulationIndicatorResultDataCommand.java | 2 +- .../GetPopulationIndicatorResultGraphCommand.java | 4 +- .../legacy/command/GetResultNameCommand.java | 2 +- ...tSpeciesForExtractRawDataAndResultsCommand.java | 2 +- .../command/GetSpeciesForMapResultCommand.java | 4 +- ...SpeciesForPopulationIndicatorResultCommand.java | 4 +- ...ciesListForCommunityIndicatorResultCommand.java | 3 +- ...GetZonesForCommunityIndicatorResultCommand.java | 4 +- ...GetZonesForExtractRawDataAndResultsCommand.java | 4 +- .../command/GetZonesForExtractRawDataCommand.java | 4 +- .../command/GetZonesForMapResultCommand.java | 4 +- ...etZonesForPopulationIndicatorResultCommand.java | 4 +- .../request/AbstractGetIndicatorResultRequest.java | 4 +- .../result/request/CopyRepositoryRequest.java | 2 +- .../request/CoserRequestExtractTypeListAware.java | 2 +- .../result/request/CoserRequestFacadeAware.java | 4 +- .../result/request/CoserRequestIndicatorAware.java | 4 +- .../CoserRequestRepositoryResultTypeAware.java | 2 +- .../request/CoserRequestRepositoryTypeAware.java | 2 +- .../result/request/CoserRequestSpeciesAware.java | 4 +- .../result/request/CoserRequestZoneAware.java | 4 +- .../result/request/CoserRequestZoneListAware.java | 4 +- .../coser/result/request/DeleteResultsRequest.java | 2 +- .../request/ExtractRawDataAndResultsRequest.java | 6 +- .../result/request/ExtractRawDataRequest.java | 4 +- .../coser/result/request/GetAllResultsRequest.java | 2 +- .../GetCommunityIndicatorResultDataRequest.java | 4 +- .../GetCommunityIndicatorResultGraphRequest.java | 4 +- ...dicatorsForCommunityIndicatorResultRequest.java | 4 +- ...dicatorsForExtractRawDataAndResultsRequest.java | 4 +- ...icatorsForPopulationIndicatorResultRequest.java | 4 +- .../coser/result/request/GetMapResultRequest.java | 4 +- ...tMatchingRepositoryTypeForMapResultRequest.java | 4 +- .../GetPopulationIndicatorResultDataRequest.java | 4 +- .../GetPopulationIndicatorResultGraphRequest.java | 4 +- .../coser/result/request/GetResultNameRequest.java | 2 +- ...tSpeciesForExtractRawDataAndResultsRequest.java | 4 +- .../request/GetSpeciesForMapResultRequest.java | 4 +- ...SpeciesForPopulationIndicatorResultRequest.java | 4 +- ...ciesListForCommunityIndicatorResultRequest.java | 4 +- ...GetZonesForCommunityIndicatorResultRequest.java | 4 +- ...GetZonesForExtractRawDataAndResultsRequest.java | 4 +- .../request/GetZonesForExtractRawDataRequest.java | 4 +- .../request/GetZonesForMapResultRequest.java | 4 +- ...etZonesForPopulationIndicatorResultRequest.java | 4 +- .../result/ExtractRawDataAndResultsResult.java | 2 +- .../fr/ifremer/coser/result/result/FileResult.java | 6 +- .../fr/ifremer/coser/result/result/MapResult.java | 2 +- .../fr/ifremer/coser/result/result/VoidResult.java | 2 +- .../java/fr/ifremer/coser/result/util/Charts.java | 10 +- .../fr/ifremer/coser/result/util/Extracts.java | 4 +- .../java/fr/ifremer/coser/result/util/Reports.java | 6 +- .../coser/services/ClientResultService.java | 8 +- .../fr/ifremer/coser/services/CommandService.java | 52 +- .../fr/ifremer/coser/services/CommonService.java | 245 ++-- .../fr/ifremer/coser/services/ControlService.java | 479 ++++---- .../fr/ifremer/coser/services/ProjectService.java | 1177 ++++++++++---------- .../ifremer/coser/services/PublicationService.java | 608 +++++----- .../ifremer/coser/services/WebResultService.java | 12 +- .../java/fr/ifremer/coser/services/WebService.java | 823 +++++++------- .../java/fr/ifremer/coser/storage/DataStorage.java | 32 +- .../ifremer/coser/storage/DataStorageWalker.java | 4 +- .../fr/ifremer/coser/storage/DataStorages.java | 13 +- .../ifremer/coser/storage/MemoryDataStorage.java | 81 +- .../java/fr/ifremer/coser/util/Coordinate.java | 10 +- .../main/java/fr/ifremer/coser/util/DataType.java | 9 +- .../coser/util/InputStreamKnownSizeBody.java | 18 +- .../fr/ifremer/coser/util/ProgressMonitor.java | 14 +- .../java/fr/ifremer/coser/util/ProgressReader.java | 8 +- .../java/fr/ifremer/coser/util/ProgressStream.java | 6 +- .../coser/util/io/OneEchobaseFileFilter.java | 2 +- .../coser/util/io/OneRSufiResultFileFilter.java | 2 +- .../coser/validators/AbstractFieldValidator.java | 6 +- .../validators/CoserCheckDoubleValidator.java | 21 +- .../coser/validators/CoserDoubleValidator.java | 18 +- .../coser/validators/CoserExpressionValidator.java | 13 +- .../coser/validators/RegexFieldValidator.java | 38 +- .../test/java/fr/ifremer/coser/CoserUtilsTest.java | 6 +- .../fr/ifremer/coser/bean/EchoBaseProjectTest.java | 2 +- .../fr/ifremer/coser/bean/IndicatorMapTest.java | 2 +- .../java/fr/ifremer/coser/bean/ZoneMapTest.java | 2 +- .../EchoBaseResultRepositoryProviderTest.java | 2 +- .../echobase/EchoBaseResultRepositoryTest.java | 2 +- .../legacy/LegacyResultRepositoryProviderTest.java | 2 +- .../ifremer/coser/services/CommandServiceTest.java | 6 +- .../ifremer/coser/services/CommonServiceTest.java | 6 +- .../ifremer/coser/services/ControlServiceTest.java | 6 +- .../ifremer/coser/services/CoserTestAbstract.java | 6 +- .../ifremer/coser/services/ProjectServiceTest.java | 6 +- .../coser/services/PublicationServiceTest.java | 6 +- .../fr/ifremer/coser/services/WebServiceTest.java | 6 +- .../coser/storage/MemoryDataStorageTest.java | 6 +- coser-ui/src/main/java/fr/ifremer/coser/Coser.java | 110 +- .../main/java/fr/ifremer/coser/CoserConfig.java | 19 +- .../java/fr/ifremer/coser/CoserConfigProvider.java | 2 +- .../main/java/fr/ifremer/coser/CoserException.java | 16 +- .../fr/ifremer/coser/CoserExceptionHandler.java | 11 +- .../ifremer/coser/CoserUIApplicationContext.java | 4 +- .../fr/ifremer/coser/ui/ContainerRedoMenu.java | 40 +- .../fr/ifremer/coser/ui/ContainerUndoMenu.java | 35 +- .../main/java/fr/ifremer/coser/ui/CoserFrame.jaxx | 112 +- .../fr/ifremer/coser/ui/CoserFrameHandler.java | 94 +- .../main/java/fr/ifremer/coser/ui/HomeView.jaxx | 30 +- .../fr/ifremer/coser/ui/SelectionsListMenu.java | 45 +- .../fr/ifremer/coser/ui/common/CommonHandler.java | 32 +- .../fr/ifremer/coser/ui/common/DataHandler.java | 59 +- .../ui/common/LengthStructureMatrixFilter.java | 35 +- .../coser/ui/common/SpeciesListRenderer.java | 15 +- .../coser/ui/common/SpeciesTableCellRenderer.java | 15 +- .../coser/ui/control/ControlCategoryListModel.java | 15 +- .../ui/control/ControlCategoryListRenderer.java | 21 +- .../coser/ui/control/ControlDataTableModel.java | 38 +- .../control/ControlDuplicatedLineTableModel.java | 49 +- .../coser/ui/control/ControlErrorTreeRenderer.java | 105 +- .../coser/ui/control/ControlFindReplaceDialog.jaxx | 74 +- .../coser/ui/control/ControlGraphFrame.jaxx | 36 +- .../ifremer/coser/ui/control/ControlHandler.java | 598 +++++----- .../coser/ui/control/ControlTableModel.java | 20 +- .../fr/ifremer/coser/ui/control/ControlView.jaxx | 316 +++--- .../coser/ui/control/GlobalControlErrorModel.java | 81 +- .../ifremer/coser/ui/control/SpecyComboModel.java | 13 +- .../java/fr/ifremer/coser/ui/freize/Freize.jaxx | 162 +-- .../fr/ifremer/coser/ui/freize/FreizeHandler.java | 57 +- .../fr/ifremer/coser/ui/freize/FreizeModel.java | 22 +- .../java/fr/ifremer/coser/ui/maps/CoserMap.java | 55 +- .../ifremer/coser/ui/maps/HaulLocationHandler.java | 41 +- .../coser/ui/option/ConfigurationHandler.java | 40 +- .../ifremer/coser/ui/option/ConfigurationView.jaxx | 352 +++--- .../ifremer/coser/ui/option/NoCopiedLayerUI.java | 24 +- .../fr/ifremer/coser/ui/option/OptionHandler.java | 98 +- .../ifremer/coser/ui/option/ValidatorDialog.jaxx | 87 +- .../coser/ui/option/ValidatorsTreeModel.java | 37 +- .../coser/ui/option/ValidatorsTreeRenderer.java | 36 +- .../coser/ui/project/ProjectCreationView.jaxx | 437 ++++---- .../ifremer/coser/ui/project/ProjectEditView.jaxx | 232 ++-- .../ifremer/coser/ui/project/ProjectHandler.java | 117 +- .../coser/ui/project/ProjectMapsListModel.java | 18 +- .../coser/ui/project/ProjectNamesListModel.java | 15 +- .../ifremer/coser/ui/project/ProjectOpenView.jaxx | 59 +- .../coser/ui/project/ProjectSummaryView.jaxx | 210 ++-- .../ui/project/SpeciesFieldTypeListRenderer.java | 35 +- .../coser/ui/publication/GlobalResultHandler.java | 7 +- .../coser/ui/publication/GlobalResultRenderer.java | 2 +- .../ui/publication/GlobalResultTableModel.java | 2 +- .../ui/publication/GlobalResultZoneRenderer.java | 2 +- .../coser/ui/result/ExportUploadDialog.jaxx | 116 +- .../fr/ifremer/coser/ui/result/ResultHandler.java | 90 +- .../ifremer/coser/ui/result/ResultTableModel.java | 109 +- .../coser/ui/result/ResultTableRenderer.java | 8 +- .../coser/ui/result/RsufiResultRenderer.java | 23 +- .../coser/ui/result/RsufiResultTableModel.java | 154 ++- .../coser/ui/result/RsufiResultZoneRenderer.java | 23 +- .../coser/ui/result/SelectUploadResultView.jaxx | 168 +-- .../coser/ui/result/SelectionAddResultDialog.jaxx | 288 ++--- .../coser/ui/result/SelectionEditResultDialog.jaxx | 178 +-- .../ifremer/coser/ui/result/ZoneComboBoxModel.java | 8 +- .../coser/ui/result/ZoneComboBoxRenderer.java | 22 +- .../coser/ui/selection/SamplingEffortRenderer.java | 41 +- .../coser/ui/selection/SelectionDetailsView.jaxx | 607 +++++----- .../coser/ui/selection/SelectionFilesView.jaxx | 78 +- .../coser/ui/selection/SelectionHandler.java | 465 ++++---- .../coser/ui/selection/SelectionListsView.jaxx | 399 +++---- .../coser/ui/selection/SelectionRsufiView.jaxx | 150 +-- .../ifremer/coser/ui/selection/SelectionView.jaxx | 36 +- .../coser/ui/selection/SpeciesFusionDialog.jaxx | 68 +- .../ui/selection/SpeciesListOccDensRenderer.java | 28 +- .../coser/ui/selection/SpeciesTypesRenderer.java | 29 +- .../coser/ui/selection/model/FileListModel.java | 13 +- .../selection/model/MaturitySpeciesListModel.java | 23 +- .../model/OccurrenceDensitySpeciesListModel.java | 30 +- .../model/SizeAllYearSpeciesListModel.java | 23 +- .../coser/ui/selection/model/SpeciesListModel.java | 21 +- .../ui/selection/model/SpeciesTypesListModel.java | 23 +- .../coser/ui/selection/model/StrataListModel.java | 13 +- .../coser/ui/selection/model/YearListModel.java | 13 +- .../ui/selection/replay/CommandListModel.java | 15 +- .../ui/selection/replay/CommandListRenderer.java | 23 +- .../replay/SelectionByProjectTreeModel.java | 20 +- .../selection/replay/SelectionReplayHandler.java | 95 +- .../ui/selection/replay/SelectionReplayView.jaxx | 188 ++-- .../fr/ifremer/coser/ui/util/CoserListModel.java | 8 +- .../coser/ui/util/CoserListSelectionModel.java | 37 +- .../fr/ifremer/coser/ui/util/CoserProgressBar.java | 18 +- .../java/fr/ifremer/coser/ui/util/ErrorHelper.java | 54 +- .../ifremer/coser/ui/widgets/AccordionLayout.java | 20 +- .../fr/ifremer/coser/ui/widgets/AccordionPane.java | 77 +- .../coser/ui/widgets/AccordionPaneSubPanel.java | 17 +- .../coser/ui/widgets/ComponentTitledBorder.java | 25 +- .../coser/ui/widgets/LookAndFeelViewMenuItem.java | 23 +- .../coser/web/CoserApplicationListener.java | 6 +- .../coser/web/CoserWebApplicationContext.java | 2 +- .../java/fr/ifremer/coser/web/CoserWebConfig.java | 6 +- .../ifremer/coser/web/CoserWebConfigProvider.java | 2 +- .../fr/ifremer/coser/web/CoserWebException.java | 16 +- .../java/fr/ifremer/coser/web/ServiceHelper.java | 4 +- .../ifremer/coser/web/actions/DocumentsAction.java | 5 - .../fr/ifremer/coser/web/actions/IndexAction.java | 20 +- .../fr/ifremer/coser/web/actions/LocaleAction.java | 5 - .../ifremer/coser/web/actions/QualityAction.java | 5 - .../fr/ifremer/coser/web/actions/SurveyAction.java | 5 - .../coser/web/actions/UploadResultAction.java | 10 +- .../web/actions/admin/DeleteProjectsAction.java | 51 +- .../coser/web/actions/admin/IndexAction.java | 7 +- .../web/actions/admin/ListProjectsAction.java | 44 +- .../web/actions/admin/ReloadProjectsAction.java | 7 +- .../coser/web/actions/admin/package-info.java | 3 +- .../coser/web/actions/auth/LoginAction.java | 4 - .../coser/web/actions/auth/LoginInterceptor.java | 4 - .../coser/web/actions/auth/LogoutAction.java | 6 +- .../coser/web/actions/auth/PerformLoginAction.java | 8 +- .../coser/web/actions/com/FacadeAction.java | 5 - .../ifremer/coser/web/actions/com/GraphAction.java | 56 +- .../coser/web/actions/com/GraphDataAction.java | 26 +- .../coser/web/actions/com/GraphDownloadAction.java | 27 +- .../coser/web/actions/com/IndicatorAction.java | 5 - .../ifremer/coser/web/actions/com/ZoneAction.java | 5 - .../web/actions/common/AbstractCoserAction.java | 2 +- .../web/actions/common/AbstractCoserJspAction.java | 8 +- .../coser/web/actions/common/CommonFacade.java | 19 - .../coser/web/actions/common/CommonIndicator.java | 60 +- .../coser/web/actions/common/CommonZone.java | 35 - .../web/actions/json/AbstractCoserJsonAction.java | 6 +- .../coser/web/actions/json/GetFacadesAction.java | 4 +- .../web/actions/json/GetIndicatorsAction.java | 4 +- .../web/actions/json/GetZonesForFacadeAction.java | 4 +- .../coser/web/actions/map/FacadeAction.java | 5 - .../ifremer/coser/web/actions/map/MapAction.java | 37 - .../coser/web/actions/map/MapDataAction.java | 21 +- .../coser/web/actions/map/SpeciesAction.java | 48 - .../ifremer/coser/web/actions/map/ZoneAction.java | 23 - .../coser/web/actions/pop/FacadeAction.java | 5 - .../ifremer/coser/web/actions/pop/GraphAction.java | 53 +- .../coser/web/actions/pop/GraphDataAction.java | 11 +- .../coser/web/actions/pop/GraphDownloadAction.java | 9 +- .../coser/web/actions/pop/IndicatorAction.java | 5 - .../coser/web/actions/pop/SpeciesAction.java | 50 - .../ifremer/coser/web/actions/pop/ZoneAction.java | 5 - .../coser/web/actions/search/ExtractAction.java | 1 - .../coser/web/actions/source/FacadeAction.java | 5 - .../coser/web/actions/source/SourceAction.java | 42 - .../coser/web/actions/source/SourceDataAction.java | 7 +- .../web/actions/source/SourceQualityAction.java | 5 - .../coser/web/actions/source/ZoneAction.java | 23 - 343 files changed, 6329 insertions(+), 8040 deletions(-) diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserApplicationContext.java b/coser-business/src/main/java/fr/ifremer/coser/CoserApplicationContext.java index 5d0db7c..8439464 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserApplicationContext.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserApplicationContext.java @@ -37,7 +37,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserApplicationContext { diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java b/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java index 7c55933..8cea773 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java @@ -44,10 +44,6 @@ import static org.nuiton.i18n.I18n.n; * Coser business application config. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class CoserBusinessConfig extends ApplicationConfig { @@ -265,7 +261,7 @@ public class CoserBusinessConfig extends ApplicationConfig { /** * Retourne la date de dernière mise à jour des données du site web. - * <p/> + * * Retourne une date bidon, si pas de dernière mise à jour. * * @return last data update date @@ -331,7 +327,7 @@ public class CoserBusinessConfig extends ApplicationConfig { } } - public static enum CoserBusinessOption implements ConfigOptionDef { + public enum CoserBusinessOption implements ConfigOptionDef { DATABASE_DIRECTORY("coser.database.directory", n("coser.config.database.directory.description"), File.class, "${user.home}" + File.separator + "coser"), PROJECTS_DIRECTORY("coser.projects.directory", n("coser.config.projects.directory.description"), File.class, "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "projects"), @@ -373,7 +369,7 @@ public class CoserBusinessConfig extends ApplicationConfig { private final Class<?> type; - private CoserBusinessOption(String key, String description, Class<?> type, String defaultValue) { + CoserBusinessOption(String key, String description, Class<?> type, String defaultValue) { this.key = key; this.description = description; this.type = type; diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessException.java b/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessException.java index 512190d..f21754b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessException.java @@ -24,21 +24,16 @@ package fr.ifremer.coser; /** * Coser exception. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserBusinessException extends Exception { - /** serialVersionUID. */ private static final long serialVersionUID = 8197217202331463505L; /** * Constructs a new exception with the specified detail message. - * + * * @param message the detail message */ public CoserBusinessException(String message) { @@ -46,10 +41,10 @@ public class CoserBusinessException extends Exception { } /** - * Constructs a new exception with the specified detail message and cause. - * + * Constructs a new exception with the specified detail message and cause. + * * @param message the detail message - * @param cause the cause + * @param cause the cause */ public CoserBusinessException(String message, Throwable cause) { super(message, cause); diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java b/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java index 8fef992..a3ad3bf 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserClassLoader.java @@ -22,23 +22,19 @@ package fr.ifremer.coser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.io.File; import java.net.MalformedURLException; import java.net.URL; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * Coser class loader. - * + * * Used to load custom xwork validation file. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserClassLoader extends ClassLoader { @@ -60,7 +56,7 @@ public class CoserClassLoader extends ClassLoader { URL result = null; if (name.matches("/fr/ifremer/coser/.+\\.xml")) { - + // cherche sur le disque File valFile = new File(validatorsDirectory, name); if (valFile.isFile()) { @@ -75,7 +71,7 @@ public class CoserClassLoader extends ClassLoader { throw new RuntimeException("Can't get validator url", ex); } } - + // cherche dans le classpath if (result == null) { result = super.getResource("validators" + name); diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java b/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java index bc6294c..4519742 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java @@ -26,12 +26,8 @@ import static org.nuiton.i18n.I18n.n; /** * Coser constants. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserConstants { @@ -52,7 +48,7 @@ public class CoserConstants { /** Nom du dossier de sauvegarde des fichiers apres control. */ public static final String STORAGE_CONTROL_DIRECTORY = "control"; - + /** Nom du dossier de sauvegarde des selections. */ public static final String STORAGE_SELECTION_DIRECTORY = "selections"; @@ -64,13 +60,13 @@ public class CoserConstants { /** Nom du dossier de stockage des maps (project AND results). */ public static final String STORAGE_MAPS_DIRECTORY = "maps"; - + /** Nom du dossier de stockage des autres fichier de resultats rsufi. */ public static final String STORAGE_RESULT_FILES = "others"; /** Suffix des nom de fichiers data apres control. */ public static final String STORAGE_CONTROL_SUFFIX = "_co"; - + /** Suffix des nom de fichiers data contenant les données supprimées. */ public static final String STORAGE_DELECTED_SUFFIX = "_del"; @@ -78,7 +74,7 @@ public class CoserConstants { public static final String STORAGE_SELECTION_SUFFIX = "_se"; /** Categories des données manipulées. */ - public static enum Category { + public enum Category { CATCH(n("coser.business.category.catch"), "catch.csv", true), STRATA(n("coser.business.category.strata"), "strata.csv", true), HAUL(n("coser.business.category.haul"), "haul.csv", true), @@ -87,40 +83,41 @@ public class CoserConstants { TYPE_ESPECES(n("coser.business.category.typeEspece"), "codeTypeEspeces.csv", false); protected String translationKey; + protected String storageFileName; - + /** Data category (par opposition reftax n'est pas un fichier de data). */ protected boolean dataCategory; - private Category(String translationKey, String storageFileName, boolean dataCategory) { + Category(String translationKey, String storageFileName, boolean dataCategory) { this.translationKey = translationKey; this.storageFileName = storageFileName; this.dataCategory = dataCategory; } - + public String getTranslationKey() { return translationKey; } /** * Nom de stockage interne a coser. - * + * * N'est pas utilisé pour les categorie de données (nom original utilisé). - * + * * @return le nom de stockage (pour les fichier de référence) */ public String getStorageFileName() { - + if (dataCategory) { throw new IllegalStateException("Can't use storageFileName for data category !"); } return storageFileName; } - + /** * Data category (par opposition reftax n'est pas un fichier de data). - * + * * @return {@code true} si la category correspond a des data */ public boolean isDataCategory() { @@ -129,7 +126,7 @@ public class CoserConstants { } /** Différent niveau de message de validation. */ - public static enum ValidationLevel { + public enum ValidationLevel { INFO("info"), WARNING("warning"), ERROR("error"), @@ -137,7 +134,7 @@ public class CoserConstants { protected String xworkContext; - private ValidationLevel(String xworkContext) { + ValidationLevel(String xworkContext) { this.xworkContext = xworkContext; } diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserServiceContext.java b/coser-business/src/main/java/fr/ifremer/coser/CoserServiceContext.java deleted file mode 100644 index 883be38..0000000 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserServiceContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package fr.ifremer.coser; - -/* - * #%L - * Coser :: Business - * %% - * Copyright (C) 2010 - 2014 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -import java.io.File; - -/** - * Created on 3/14/14. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 1.5 - */ -public interface CoserServiceContext { - - CoserApplicationContext getApplicationContext(); - - File getTemporaryDirectory(); -} diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserTechnicalException.java b/coser-business/src/main/java/fr/ifremer/coser/CoserTechnicalException.java index 4bc00f4..5b57c50 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserTechnicalException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserTechnicalException.java @@ -27,10 +27,11 @@ package fr.ifremer.coser; * * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserTechnicalException extends RuntimeException { + private static final long serialVersionUID = 1L; public CoserTechnicalException(String message) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/CoserUtils.java b/coser-business/src/main/java/fr/ifremer/coser/CoserUtils.java index c094be6..b8fdea2 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/CoserUtils.java +++ b/coser-business/src/main/java/fr/ifremer/coser/CoserUtils.java @@ -53,10 +53,6 @@ import java.util.regex.Pattern; * Coser utility class. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class CoserUtils { @@ -170,7 +166,7 @@ public class CoserUtils { /** * Dans un nom de fichier, ajoute un suffix dans le nom du fichier * juste avant l'extension. - * <p/> + * * Exemple : * captures.csv > captures_co.csv (ajout du suffix _co) * captures > captures_co (si pas d'extension) @@ -233,6 +229,7 @@ public class CoserUtils { public static <K, V extends Comparable<? super V>> LinkedHashMap<K, V> sortByValue(Map<K, V> map) { List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet()); Collections.sort(list, new Comparator<Map.Entry<K, V>>() { + public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) { return (o1.getValue()).compareTo(o2.getValue()); } diff --git a/coser-business/src/main/java/fr/ifremer/coser/DefaultCoserApplicationContext.java b/coser-business/src/main/java/fr/ifremer/coser/DefaultCoserApplicationContext.java index 12f1960..5903155 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/DefaultCoserApplicationContext.java +++ b/coser-business/src/main/java/fr/ifremer/coser/DefaultCoserApplicationContext.java @@ -40,7 +40,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DefaultCoserApplicationContext implements CoserApplicationContext { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java b/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java index 7d0f73f..d5d5465 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java @@ -22,26 +22,22 @@ package fr.ifremer.coser.bean; -import java.util.List; - import fr.ifremer.coser.command.Command; import fr.ifremer.coser.storage.DataStorage; +import java.util.List; + /** * Common container code for {@link Control} and {@link Selection}. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class AbstractDataContainer extends AbstractEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 3963187480579783560L; - public static final String PROPERTY_HISTORY_COMMANDS= "historyCommands"; + public static final String PROPERTY_HISTORY_COMMANDS = "historyCommands"; protected DataStorage dataCatch; @@ -62,8 +58,8 @@ public class AbstractDataContainer extends AbstractEntity { /** Deleted length (can be null). */ protected DataStorage deletedDataLength; - - /** L'historique des commandes do/undo .*/ + + /** L'historique des commandes do/undo . */ protected List<Command> historyCommands; /** @@ -163,7 +159,7 @@ public class AbstractDataContainer extends AbstractEntity { historyCommands.remove(historyCommand); getPropertyChangeSupport().firePropertyChange(PROPERTY_HISTORY_COMMANDS, null, historyCommands); } - + public void clearHistoryCommands() { historyCommands.clear(); getPropertyChangeSupport().firePropertyChange(PROPERTY_HISTORY_COMMANDS, null, historyCommands); @@ -171,9 +167,9 @@ public class AbstractDataContainer extends AbstractEntity { /** * Return {@code true} if data are loaded. - * + * * If lists are non {@code null}. - * + * * @return {@code true} if at least one list is not {@code null} */ public boolean isDataLoaded() { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java b/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java index 0e80cfc..b4fa767 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java @@ -28,16 +28,12 @@ import java.io.Serializable; /** * Abstract entity to add property change support to all classes. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class AbstractEntity implements Serializable { - /** serialVersionUID. */ + private static final long serialVersionUID = -86518442573383360L; protected transient PropertyChangeSupport support; @@ -58,12 +54,12 @@ public abstract class AbstractEntity implements Serializable { } public void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + PropertyChangeListener listener) { getPropertyChangeSupport().addPropertyChangeListener(propertyName, listener); } public void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + PropertyChangeListener listener) { getPropertyChangeSupport().removePropertyChangeListener(propertyName, listener); } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java b/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java index 8d98914..3f97f93 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java @@ -26,16 +26,12 @@ import java.util.Properties; /** * Control entity. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Control extends AbstractDataContainer { - /** serialVersionUID. */ + private static final long serialVersionUID = 3693938021315541627L; public static final String PROPERTY_VALIDATED = "validated"; @@ -73,7 +69,7 @@ public class Control extends AbstractDataContainer { props.setProperty("control.validated", String.valueOf(validated)); return props; } - + public void fromProperties(Properties props) { if (props.containsKey("control.comment")) { setComment(props.getProperty("control.comment")); diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/EchoBaseProject.java b/coser-business/src/main/java/fr/ifremer/coser/bean/EchoBaseProject.java index 0248587..b079b97 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/EchoBaseProject.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/EchoBaseProject.java @@ -41,10 +41,10 @@ import java.util.Properties; /** * Represent the storage of the EchoBase project published to CoserWeb application. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseProject implements Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/GlobalResult.java b/coser-business/src/main/java/fr/ifremer/coser/bean/GlobalResult.java index 4cdedeb..ee657ad 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/GlobalResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/GlobalResult.java @@ -35,7 +35,7 @@ import java.util.Date; * * Created on 3/17/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GlobalResult implements Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/IndicatorMap.java b/coser-business/src/main/java/fr/ifremer/coser/bean/IndicatorMap.java index f4461f7..9d21fc1 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/IndicatorMap.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/IndicatorMap.java @@ -42,10 +42,10 @@ import java.util.Set; /** * Contains the localized indicator definitions. - * <p/> + * * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class IndicatorMap implements Serializable { @@ -105,6 +105,7 @@ public class IndicatorMap implements Serializable { DataStorage storage = DataStorages.load(indicatorsFile); DataStorages.walk(storage, new DataStorageWalker() { + @Override public void onRow(String... row) { String indicatorCode = row[0]; diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java b/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java index 50f2043..156b5fe 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java @@ -22,6 +22,12 @@ package fr.ifremer.coser.bean; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserUtils; +import fr.ifremer.coser.storage.DataStorage; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + import java.io.File; import java.util.ArrayList; import java.util.Date; @@ -31,38 +37,27 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import fr.ifremer.coser.CoserConstants; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.storage.DataStorage; - /** * Project. - * + * * For now, just composed of four simple String lists for data list. - * + * * Also composed of loaded reftax (with header {@link #REFTAX_SPECIES_HEADER}). * "C_Perm";"NumSys";"NivSys";"C_VALIDE";"L_VALIDE";"AA_VALIDE";"C_TxPère";"Taxa" - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Project extends AbstractEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 8372568232663922521L; public static final String[] REFTAX_SPECIES_HEADER = { - "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" + "C_Perm", "NumSys", "NivSys", "C_VALIDE", "L_VALIDE", "AA_VALIDE", "C_TxP\u00E8re", "Taxa" }; public static final String[] TYPE_ESPECE_HEADER = { - "Types","Commentaire","NumSys min","NumSys max","Code" + "Types", "Commentaire", "NumSys min", "NumSys max", "Code" }; public static final String PROPERTY_SELECTIONS = "selections"; @@ -288,7 +283,7 @@ public class Project extends AbstractEntity { /** * Recuperation de la map de cache code especes/visualisation utilisateur. - * + * * @return refTax species map * @since 1.3 */ @@ -298,7 +293,7 @@ public class Project extends AbstractEntity { /** * Modification de la map de cache code especes/visualisation utilisateur. - * + * * @param refTaxSpeciesMap new map * @since 1.3 */ @@ -309,7 +304,7 @@ public class Project extends AbstractEntity { /** * Retourne le nom de visualisation de l'espèce conformement à la configuration * du projet. - * + * * @return le label espece * @since 1.3 */ @@ -418,7 +413,7 @@ public class Project extends AbstractEntity { } return props; } - + public void fromProperties(Properties props, File mapDirectory) { if (props.containsKey("project.author")) { setAuthor(props.getProperty("project.author")); @@ -477,7 +472,7 @@ public class Project extends AbstractEntity { * (sauf les fichiers de réference) donc il n'est pas fixe. * * @param category category to get file name - * @param suffix suffix to add into file name + * @param suffix suffix to add into file name * @return storage file name * @since 1.5 */ @@ -493,7 +488,7 @@ public class Project extends AbstractEntity { result = getHaulFileName(); break; case LENGTH: - result = getLengthFileName(); + result = getLengthFileName(); break; case STRATA: result = getStrataFileName(); diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java b/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java index d303dd1..6017db0 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java @@ -39,14 +39,10 @@ import java.util.Properties; * RSufi result. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class RSufiResult extends AbstractEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = -1337710082675120199L; /** Logger. */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java b/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java index 508b420..8125552 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java @@ -30,17 +30,13 @@ import java.io.Serializable; * Object utilitaire represantant un path vers un résultat (projet / selection * / rsufiresult) utilisé par l'interface d'admin et l'upload de resultat * vers l'interface web. - * <p/> + * * L'egalité et le hashcode sont basé sur les {@link Project#name}, * {@link Selection#name}, et {@link RSufiResult#name}. - * <p/> + * * Les attribut sont finaux car le hashcode est basé dessus. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class RSufiResultPath implements Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java b/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java index 6ecc4bc..4dd5ca1 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java @@ -22,27 +22,22 @@ package fr.ifremer.coser.bean; +import fr.ifremer.coser.CoserUtils; +import org.apache.commons.lang3.StringUtils; + import java.io.File; import java.util.Collections; import java.util.List; import java.util.Properties; -import org.apache.commons.lang3.StringUtils; - -import fr.ifremer.coser.CoserUtils; - /** * Project selection. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Selection extends AbstractDataContainer { - /** serialVersionUID. */ + private static final long serialVersionUID = -1484104459960459854L; public static final String PROPERTY_VALIDATED = "validated"; @@ -76,7 +71,7 @@ public class Selection extends AbstractDataContainer { /** L4 : */ protected List<String> selectedSpeciesMaturity; - + /** L1 : comment. */ protected String selectedSpeciesComment; @@ -106,7 +101,7 @@ public class Selection extends AbstractDataContainer { selectedSpeciesSizeAllYear = Collections.EMPTY_LIST; selectedSpeciesMaturity = Collections.EMPTY_LIST; } - + public Selection(String name) { this(); this.name = name; @@ -295,13 +290,13 @@ public class Selection extends AbstractDataContainer { props.setProperty("selection.description", description); } if (getAllYears() != null) { - props.setProperty("selection.allYears", StringUtils.join(getAllYears(),',')); + props.setProperty("selection.allYears", StringUtils.join(getAllYears(), ',')); } if (getSelectedYears() != null) { - props.setProperty("selection.selectedYears", StringUtils.join(getSelectedYears(),',')); + props.setProperty("selection.selectedYears", StringUtils.join(getSelectedYears(), ',')); } if (getSelectedStrata() != null) { - props.setProperty("selection.selectedStrata", StringUtils.join(getSelectedStrata(),',')); + props.setProperty("selection.selectedStrata", StringUtils.join(getSelectedStrata(), ',')); } if (comment != null) { props.setProperty("selection.comment", comment); @@ -309,16 +304,16 @@ public class Selection extends AbstractDataContainer { props.setProperty("selection.occurrenceFilter", String.valueOf(occurrenceFilter)); props.setProperty("selection.densityFilter", String.valueOf(densityFilter)); if (getSelectedSpecies() != null) { - props.setProperty("selection.selectedSpecies", StringUtils.join(getSelectedSpecies(),',')); + props.setProperty("selection.selectedSpecies", StringUtils.join(getSelectedSpecies(), ',')); } if (getSelectedSpeciesOccDens() != null) { - props.setProperty("selection.selectedSpeciesOccDens", StringUtils.join(getSelectedSpeciesOccDens(),',')); + props.setProperty("selection.selectedSpeciesOccDens", StringUtils.join(getSelectedSpeciesOccDens(), ',')); } if (getSelectedSpeciesSizeAllYear() != null) { - props.setProperty("selection.selectedSpeciesSizeAllYear", StringUtils.join(getSelectedSpeciesSizeAllYear(),',')); + props.setProperty("selection.selectedSpeciesSizeAllYear", StringUtils.join(getSelectedSpeciesSizeAllYear(), ',')); } if (getSelectedSpeciesMaturity() != null) { - props.setProperty("selection.selectedSpeciesMaturity", StringUtils.join(getSelectedSpeciesMaturity(),',')); + props.setProperty("selection.selectedSpeciesMaturity", StringUtils.join(getSelectedSpeciesMaturity(), ',')); } if (selectedSpeciesComment != null) { props.setProperty("selection.selectedSpeciesComment", selectedSpeciesComment); @@ -333,10 +328,10 @@ public class Selection extends AbstractDataContainer { props.setProperty("selection.selectedSpeciesMaturityComment", selectedSpeciesMaturityComment); } props.setProperty("selection.validated", String.valueOf(isValidated())); - + return props; } - + public void fromProperties(Properties props) { if (props.containsKey("selection.description")) { setDescription(props.getProperty("selection.description")); diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesFieldType.java b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesFieldType.java index f64a38b..f6b09b1 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesFieldType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesFieldType.java @@ -25,13 +25,13 @@ package fr.ifremer.coser.bean; /** * Since 1.3, species can be managed by C_Perm, AA_Valide or L_Valide. * They are always presented to user with latin name. - * + * * @author echatellier * @since 1.3 */ public enum SpeciesFieldType { - /** Species alpha code (BONA, BONAOST...)*/ + /** Species alpha code (BONA, BONAOST...) */ C_Valide("C_Valide"), /** Species num code (1, 2, 3...). */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesListMap.java b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesListMap.java index 477426c..db86f19 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesListMap.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesListMap.java @@ -40,7 +40,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class SpeciesListMap implements Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesMap.java b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesMap.java index 68eb994..a876d2f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesMap.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/SpeciesMap.java @@ -37,7 +37,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class SpeciesMap implements Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/bean/ZoneMap.java b/coser-business/src/main/java/fr/ifremer/coser/bean/ZoneMap.java index f7785e2..5893a1c 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/bean/ZoneMap.java +++ b/coser-business/src/main/java/fr/ifremer/coser/bean/ZoneMap.java @@ -44,10 +44,10 @@ import java.util.Map; /** * Contains all usefull methods on zone definitions. - * <p/> + * * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ZoneMap implements Serializable { @@ -65,9 +65,9 @@ public class ZoneMap implements Serializable { if (zonesFile == null || zonesFile.isFile()) { if (log.isInfoEnabled()) { - log.info("Using zone file: "+zonesFile); + log.info("Using zone file: " + zonesFile); } - + storage = DataStorages.load(zonesFile); } else { storage = new MemoryDataStorage(); @@ -217,7 +217,7 @@ public class ZoneMap implements Serializable { /** * Get all zones for a given facade. - * <p/> + * * If no facade is given, then return all zones. * * @return zones for the given facade (or all zones if no facade is given) diff --git a/coser-business/src/main/java/fr/ifremer/coser/command/CategoryLineCommand.java b/coser-business/src/main/java/fr/ifremer/coser/command/CategoryLineCommand.java index e6b11ef..7494346 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/command/CategoryLineCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/command/CategoryLineCommand.java @@ -26,12 +26,8 @@ import fr.ifremer.coser.CoserConstants.Category; /** * Commande faite une une category de fichier a une ligne specifique. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class CategoryLineCommand extends Command { diff --git a/coser-business/src/main/java/fr/ifremer/coser/command/Command.java b/coser-business/src/main/java/fr/ifremer/coser/command/Command.java index 01174f4..56bbe91 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/command/Command.java +++ b/coser-business/src/main/java/fr/ifremer/coser/command/Command.java @@ -28,12 +28,8 @@ import fr.ifremer.coser.bean.Project; /** * Command interface. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class Command { @@ -51,7 +47,7 @@ public abstract class Command { /** * UUID de la commande. Les commandes ayant un UUID commun font partie * du même groupe de commandes. - * + * * @return command UUID * @see java.util.UUID */ @@ -62,7 +58,7 @@ public abstract class Command { /** * UUID de la commande. Les commandes ayant un UUID commun font partie * du même groupe de commandes. - * + * * @param commandUUID new uuid * @see java.util.UUID */ @@ -72,7 +68,7 @@ public abstract class Command { /** * Command comment. - * + * * @return command comment */ public String getComment() { @@ -81,7 +77,7 @@ public abstract class Command { /** * Command comment. - * + * * @param comment command comment */ public void setComment(String comment) { @@ -90,42 +86,42 @@ public abstract class Command { /** * Do command on project. - * - * @param project project + * + * @param project project * @param container container - * @throws CoserBusinessException + * @throws CoserBusinessException */ public abstract void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException; /** * Undo command on project. - * - * @param project project + * + * @param project project * @param container container - * @throws CoserBusinessException + * @throws CoserBusinessException */ public abstract void undoCommand(Project project, AbstractDataContainer container) throws CoserBusinessException; /** * Get command argument string representation. - * + * * @return command argument string representation */ public abstract String toStringRepresentation(); /** * Init command from string representation. - * + * * @param representation string command representation */ public abstract void fromStringRepresentation(String representation); /** * Return human readable string for log output. - * - * @param project used to convert species code + * + * @param project used to convert species code * @param container rarement utile, mais dans certains cas, sert a avoir les - * vrais valeur de champs au lieu des noms techniques + * vrais valeur de champs au lieu des noms techniques * @return log representation */ public abstract String getLogString(Project project, AbstractDataContainer container); @@ -133,10 +129,10 @@ public abstract class Command { /** * Return human readable string for ui display (used in selection replay, * and undo redo commands). - * - * @param project used to convert species code + * + * @param project used to convert species code * @param container rarement utile, mais dans certains cas, sert a avoir les - * vrais valeur de champs au lieu des noms techniques + * vrais valeur de champs au lieu des noms techniques * @return string description (i18n) */ public abstract String getDescription(Project project, AbstractDataContainer container); diff --git a/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java b/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java index 22b4921..bced34f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java @@ -22,28 +22,23 @@ package fr.ifremer.coser.command; -import static org.nuiton.i18n.I18n.t; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserUtils; import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.storage.DataStorage; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Command pattern object. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class DeleteLineCommand extends CategoryLineCommand { @@ -54,23 +49,23 @@ public class DeleteLineCommand extends CategoryLineCommand { DataStorage deletedDataStorage = null; // get data storage depending on category - switch(category) { - case CATCH: - dataStorage = container.getCatch(); - deletedDataStorage = container.getDeletedCatch(); - break; - case HAUL: - dataStorage = container.getHaul(); - deletedDataStorage = container.getDeletedHaul(); - break; - case LENGTH: - dataStorage = container.getLength(); - deletedDataStorage = container.getDeletedLength(); - break; - case STRATA: - dataStorage = container.getStrata(); - deletedDataStorage = container.getDeletedStrata(); - break; + switch (category) { + case CATCH: + dataStorage = container.getCatch(); + deletedDataStorage = container.getDeletedCatch(); + break; + case HAUL: + dataStorage = container.getHaul(); + deletedDataStorage = container.getDeletedHaul(); + break; + case LENGTH: + dataStorage = container.getLength(); + deletedDataStorage = container.getDeletedLength(); + break; + case STRATA: + dataStorage = container.getStrata(); + deletedDataStorage = container.getDeletedStrata(); + break; } // parcourt des lignes @@ -78,8 +73,7 @@ public class DeleteLineCommand extends CategoryLineCommand { if (index >= 0) { String[] data = dataStorage.remove(index); deletedDataStorage.add(data); - } - else { + } else { // if not found, throw business exception throw new CoserBusinessException(t("Can't find line %s for deletion", lineNumber)); } @@ -92,30 +86,30 @@ public class DeleteLineCommand extends CategoryLineCommand { DataStorage deletedDataStorage = null; // get data storage depending on category - switch(category) { - case CATCH: - dataStorage = container.getCatch(); - deletedDataStorage = container.getDeletedCatch(); - break; - case HAUL: - dataStorage = container.getHaul(); - deletedDataStorage = container.getDeletedHaul(); - break; - case LENGTH: - dataStorage = container.getLength(); - deletedDataStorage = container.getDeletedLength(); - break; - case STRATA: - dataStorage = container.getStrata(); - deletedDataStorage = container.getDeletedStrata(); - break; + switch (category) { + case CATCH: + dataStorage = container.getCatch(); + deletedDataStorage = container.getDeletedCatch(); + break; + case HAUL: + dataStorage = container.getHaul(); + deletedDataStorage = container.getDeletedHaul(); + break; + case LENGTH: + dataStorage = container.getLength(); + deletedDataStorage = container.getDeletedLength(); + break; + case STRATA: + dataStorage = container.getStrata(); + deletedDataStorage = container.getDeletedStrata(); + break; } int indexDeletedData = deletedDataStorage.indexOf(lineNumber); - + if (indexDeletedData != -1) { String[] deletedDataLine = deletedDataStorage.get(indexDeletedData); - + // search for new insert point int lineNumberInt = Integer.parseInt(lineNumber); @@ -129,13 +123,12 @@ public class DeleteLineCommand extends CategoryLineCommand { lineNumberInt--; indexData = dataStorage.indexOf(String.valueOf(lineNumberInt)); } while (indexData < 0 && lineNumberInt > 0); - + // re add deleted data if (indexData >= 0) { // +1 car on l'insert apres la ligne qu'on a trouvé dataStorage.add(indexData + 1, deletedDataLine); - } - else { + } else { dataStorage.add(0, deletedDataLine); } deletedDataStorage.remove(indexDeletedData); @@ -168,11 +161,10 @@ public class DeleteLineCommand extends CategoryLineCommand { for (String arg : args) { int indexOfEqual = arg.indexOf('='); String argAttribute = arg.substring(0, indexOfEqual); - String value = arg.substring(indexOfEqual +1); + String value = arg.substring(indexOfEqual + 1); if (argAttribute.equals("category")) { category = Category.valueOf(value); - } - else if (argAttribute.equals("lineNumber")) { + } else if (argAttribute.equals("lineNumber")) { lineNumber = value; } } @@ -182,7 +174,7 @@ public class DeleteLineCommand extends CategoryLineCommand { public String getLogString(Project project, AbstractDataContainer container) { return t("coser.business.command.deleteline.log", t(category.getTranslationKey()), lineNumber); } - + @Override public String getDescription(Project project, AbstractDataContainer container) { String desc = t("coser.business.command.deleteline.desc", t(category.getTranslationKey()), lineNumber); diff --git a/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java b/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java index fc71551..f1202b8 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java @@ -22,7 +22,16 @@ package fr.ifremer.coser.command; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserUtils; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.data.Length; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.Arrays; @@ -31,26 +40,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserConstants; -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.data.Catch; -import fr.ifremer.coser.data.Length; +import static org.nuiton.i18n.I18n.t; /** * Merge species command. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class MergeSpeciesCommand extends Command { @@ -81,10 +76,10 @@ public class MergeSpeciesCommand extends Command { */ @Override public void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { - + project = mergeCatch(project, container, newSpecyName, speciesNames); project = mergeLength(project, container, newSpecyName, speciesNames); - + } /* @@ -98,15 +93,15 @@ public class MergeSpeciesCommand extends Command { /** * Fusion d'espece dans les données de captures. - * - * @param project project - * @param container data container + * + * @param project project + * @param container data container * @param newSpecyName new specy name (after merge) * @param speciesNames species name to merge * @return project */ protected Project mergeLength(Project project, AbstractDataContainer container, - String newSpecyName, String... speciesNames) { + String newSpecyName, String... speciesNames) { // Campagne;Annee;Trait;Espece;Sexe;Maturite;Longueur;Nombre;Poids;Age @@ -135,11 +130,11 @@ public class MergeSpeciesCommand extends Command { // compute key (attention a ne pas prendre en compte l'espece : elle change) StringBuilder sb = new StringBuilder(); - for (int tupleIndex = 0 ; tupleIndex < tuple.length; ++tupleIndex) { + for (int tupleIndex = 0; tupleIndex < tuple.length; ++tupleIndex) { if (tupleIndex == Length.INDEX_SURVEY || tupleIndex == Length.INDEX_YEAR || - tupleIndex == Length.INDEX_HAUL || tupleIndex == Length.INDEX_SEX || - tupleIndex == Length.INDEX_MATURITY || tupleIndex == Length.INDEX_LENGTH || - tupleIndex == Length.INDEX_AGE) { + tupleIndex == Length.INDEX_HAUL || tupleIndex == Length.INDEX_SEX || + tupleIndex == Length.INDEX_MATURITY || tupleIndex == Length.INDEX_LENGTH || + tupleIndex == Length.INDEX_AGE) { sb.append(tuple[tupleIndex]).append(';'); } } @@ -154,8 +149,7 @@ public class MergeSpeciesCommand extends Command { firstLineForKey.put(key, lineIndex); lineIndex++; - } - else { + } else { String[] previousTuple = container.getLength().get(firstLineFound); String[] mergedTuple = mergeLengths(previousTuple, tuple); // et on supprime le tuple @@ -173,39 +167,36 @@ public class MergeSpeciesCommand extends Command { /** * Merge deux lines des catch. - * + * * Le resultat est mergé dans {@code tuple1} et retourné. - * + * * Somme les "Nombre" et "Poids" - * + * * @param tuple1 first tuple to merge * @param tuple2 second tuple to merge * @return merged tuples */ protected String[] mergeLengths(String[] tuple1, String[] tuple2) { - + try { // number if (isNotAvailableData(tuple1[Length.INDEX_NUMBER]) || isNotAvailableData(tuple2[Length.INDEX_NUMBER])) { tuple1[Length.INDEX_NUMBER] = CoserConstants.VALIDATION_NA; - } - else { + } else { double nombre1 = Double.parseDouble(tuple1[Length.INDEX_NUMBER]); double nombre2 = Double.parseDouble(tuple2[Length.INDEX_NUMBER]); tuple1[Length.INDEX_NUMBER] = String.valueOf(nombre1 + nombre2); } - + // weight if (isNotAvailableData(tuple1[Length.INDEX_WEIGHT]) || isNotAvailableData(tuple2[Length.INDEX_WEIGHT])) { tuple1[Length.INDEX_WEIGHT] = CoserConstants.VALIDATION_NA; - } - else { + } else { double poids1 = Double.parseDouble(tuple1[Length.INDEX_WEIGHT]); double poids2 = Double.parseDouble(tuple2[Length.INDEX_WEIGHT]); tuple1[Length.INDEX_WEIGHT] = String.valueOf(poids1 + poids2); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't convert data as double for merge", ex); } @@ -214,8 +205,8 @@ public class MergeSpeciesCommand extends Command { } /** - * Return true if a value - * + * Return true if a value + * * @param data data value to check * @return {@code true} if value is empty or NA */ @@ -229,18 +220,18 @@ public class MergeSpeciesCommand extends Command { /** * Fusion d'especes dans les données de taille. - * + * * Peut etre a revoir, car ca fonctionne, mais le traitement * est dépendant de l'ordre. - * - * @param project project - * @param container data container + * + * @param project project + * @param container data container * @param newSpecyName new specy name (after merge) * @param speciesNames species name to merge * @return project */ - protected Project mergeCatch(Project project, AbstractDataContainer container, - String newSpecyName, String... speciesNames) { + protected Project mergeCatch(Project project, AbstractDataContainer container, + String newSpecyName, String... speciesNames) { // "Campagne","Annee","Trait","Espece","Nombre","Poids" @@ -269,9 +260,9 @@ public class MergeSpeciesCommand extends Command { // compute key (attention a ne pas prendre en compte l'espece : elle change) StringBuilder sb = new StringBuilder(); - for (int tupleIndex = 0 ; tupleIndex < tuple.length; ++tupleIndex) { + for (int tupleIndex = 0; tupleIndex < tuple.length; ++tupleIndex) { if (tupleIndex == Catch.INDEX_SURVEY || tupleIndex == Catch.INDEX_YEAR || - tupleIndex == Catch.INDEX_HAUL) { + tupleIndex == Catch.INDEX_HAUL) { sb.append(tuple[tupleIndex]).append(';'); } } @@ -286,8 +277,7 @@ public class MergeSpeciesCommand extends Command { firstLineForKey.put(key, lineIndex); lineIndex++; - } - else { + } else { String[] previousTuple = container.getCatch().get(firstLineFound); String[] mergeTuple = mergeCatches(previousTuple, tuple); // et on supprime le tuple @@ -302,23 +292,23 @@ public class MergeSpeciesCommand extends Command { } } - + return project; } /** * Merge deux lines des catch. - * + * * Le resultat est mergé dans {@code tuple1} et retourné. - * + * * Somme les "Nombre" et "Poids" - * + * * @param tuple1 tuple1 * @param tuple2 tuple2 * @return tuple1 */ protected String[] mergeCatches(String[] tuple1, String[] tuple2) { - + // "Campagne","Annee","Trait","Espece","Nombre","Poids" try { @@ -329,15 +319,14 @@ public class MergeSpeciesCommand extends Command { tuple1[Catch.INDEX_NUMBER] = String.valueOf(nombre1 + nombre2); tuple1[Catch.INDEX_WEIGHT] = String.valueOf(poids1 + poids2); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't convert data as double for merge", ex); } } return tuple1; } - + /* * @see fr.ifremer.coser.command.Command#toStringRepresentation() */ @@ -354,22 +343,21 @@ public class MergeSpeciesCommand extends Command { */ @Override public void fromStringRepresentation(String representation) { - + List<String> args = CoserUtils.convertBracketToList(representation); for (String arg : args) { int indexOfEqual = arg.indexOf('='); String argAttribute = arg.substring(0, indexOfEqual); - String value = arg.substring(indexOfEqual +1); + String value = arg.substring(indexOfEqual + 1); if (argAttribute.equals("newSpecyName")) { newSpecyName = value; - } - else if (argAttribute.equals("speciesNames")) { + } else if (argAttribute.equals("speciesNames")) { List<String> speciesNamesList = CoserUtils.convertBracketToList(value); speciesNames = speciesNamesList.toArray(new String[speciesNamesList.size()]); } } } - + @Override public String getLogString(Project project, AbstractDataContainer container) { StringBuilder speciesAsString = new StringBuilder(256); @@ -402,10 +390,10 @@ public class MergeSpeciesCommand extends Command { String desc = null; if (speciesNames.length == 1) { desc = t("coser.business.command.mergespecies.rename.desc", - project.getDisplaySpeciesText(newSpecyName), speciesNames.length, speciesAsString.toString()); + project.getDisplaySpeciesText(newSpecyName), speciesNames.length, speciesAsString.toString()); } else { desc = t("coser.business.command.mergespecies.desc", - project.getDisplaySpeciesText(newSpecyName), speciesNames.length, speciesAsString.toString()); + project.getDisplaySpeciesText(newSpecyName), speciesNames.length, speciesAsString.toString()); } if (StringUtils.isNotBlank(comment)) { desc += " (" + comment + ")"; diff --git a/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java b/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java index bd7ddce..23df32e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java @@ -22,19 +22,9 @@ package fr.ifremer.coser.command; -import static org.nuiton.i18n.I18n.t; - -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; - import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserUtils; import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserUtils; import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.data.AbstractDataEntity; @@ -43,15 +33,20 @@ import fr.ifremer.coser.data.Haul; import fr.ifremer.coser.data.Length; import fr.ifremer.coser.data.Strata; import fr.ifremer.coser.storage.DataStorage; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + +import java.beans.Introspector; +import java.util.ArrayList; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Command pattern object. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ModifyFieldCommand extends CategoryLineCommand { @@ -94,22 +89,22 @@ public class ModifyFieldCommand extends CategoryLineCommand { AbstractDataEntity beanData = null; DataStorage dataStorage = null; switch (category) { - case CATCH: - beanData = new Catch(); - dataStorage = container.getCatch(); - break; - case HAUL: - beanData = new Haul(); - dataStorage = container.getHaul(); - break; - case LENGTH: - beanData = new Length(); - dataStorage = container.getLength(); - break; - case STRATA: - beanData = new Strata(); - dataStorage = container.getStrata(); - break; + case CATCH: + beanData = new Catch(); + dataStorage = container.getCatch(); + break; + case HAUL: + beanData = new Haul(); + dataStorage = container.getHaul(); + break; + case LENGTH: + beanData = new Length(); + dataStorage = container.getLength(); + break; + case STRATA: + beanData = new Strata(); + dataStorage = container.getStrata(); + break; } int lineIndex = dataStorage.indexOf(lineNumber); @@ -118,13 +113,12 @@ public class ModifyFieldCommand extends CategoryLineCommand { try { String beanFieldName = Introspector.decapitalize(fieldName); String stringFieldProperty = beanFieldName + "AsString"; - String dataValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty); + String dataValue = (String) PropertyUtils.getProperty(beanData, stringFieldProperty); if (dataValue.equals(currentValue)) { PropertyUtils.setProperty(beanData, stringFieldProperty, newValue); - + dataStorage.set(lineIndex, beanData.getData()); - } - else { + } else { throw new CoserBusinessException(t("Can't replace data value. Expected %s but was %s", currentValue, dataValue)); } } catch (Exception ex) { @@ -137,22 +131,22 @@ public class ModifyFieldCommand extends CategoryLineCommand { AbstractDataEntity beanData = null; DataStorage dataStorage = null; switch (category) { - case CATCH: - beanData = new Catch(); - dataStorage = container.getCatch(); - break; - case HAUL: - beanData = new Haul(); - dataStorage = container.getHaul(); - break; - case LENGTH: - beanData = new Length(); - dataStorage = container.getLength(); - break; - case STRATA: - beanData = new Strata(); - dataStorage = container.getStrata(); - break; + case CATCH: + beanData = new Catch(); + dataStorage = container.getCatch(); + break; + case HAUL: + beanData = new Haul(); + dataStorage = container.getHaul(); + break; + case LENGTH: + beanData = new Length(); + dataStorage = container.getLength(); + break; + case STRATA: + beanData = new Strata(); + dataStorage = container.getStrata(); + break; } int lineIndex = dataStorage.indexOf(lineNumber); @@ -161,13 +155,12 @@ public class ModifyFieldCommand extends CategoryLineCommand { try { String beanFieldName = Introspector.decapitalize(fieldName); String stringFieldProperty = beanFieldName + "AsString"; - String dataValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty); + String dataValue = (String) PropertyUtils.getProperty(beanData, stringFieldProperty); if (dataValue.equals(newValue)) { PropertyUtils.setProperty(beanData, stringFieldProperty, currentValue); - + dataStorage.set(lineIndex, beanData.getData()); - } - else { + } else { throw new CoserBusinessException(t("Can't replace data value. Expected %s but was %s", newValue, dataValue)); } } catch (Exception ex) { @@ -199,20 +192,16 @@ public class ModifyFieldCommand extends CategoryLineCommand { for (String arg : args) { int indexOfEqual = arg.indexOf('='); String argAttribute = arg.substring(0, indexOfEqual); - String value = arg.substring(indexOfEqual +1); + String value = arg.substring(indexOfEqual + 1); if (argAttribute.equals("category")) { category = Category.valueOf(value); - } - else if (argAttribute.equals("lineNumber")) { + } else if (argAttribute.equals("lineNumber")) { lineNumber = value; - } - else if (argAttribute.equals("fieldName")) { + } else if (argAttribute.equals("fieldName")) { fieldName = value; - } - else if (argAttribute.equals("currentValue")) { + } else if (argAttribute.equals("currentValue")) { currentValue = value; - } - else if (argAttribute.equals("newValue")) { + } else if (argAttribute.equals("newValue")) { newValue = value; } } @@ -236,11 +225,11 @@ public class ModifyFieldCommand extends CategoryLineCommand { /** * Look for real field name. - * + * * Les nom de champs utilisé par introspection et sauvegardé sont les * nom anglais (toujours). Par contre pour la sortie log, l'utilisateur * est plutôt interessé par le nom original du fichier. - * + * * @param container le container pour lire les headers csv * @return le nom original du fichier */ @@ -248,31 +237,31 @@ public class ModifyFieldCommand extends CategoryLineCommand { String[] headers = null; DataStorage dataStorage = null; switch (category) { - case CATCH: - headers = Catch.EN_HEADERS; - dataStorage = container.getCatch(); - break; - case HAUL: - headers = Haul.EN_HEADERS; - dataStorage = container.getHaul(); - break; - case LENGTH: - headers = Length.EN_HEADERS; - dataStorage = container.getLength(); - break; - case STRATA: - headers = Strata.EN_HEADERS; - dataStorage = container.getStrata(); - break; + case CATCH: + headers = Catch.EN_HEADERS; + dataStorage = container.getCatch(); + break; + case HAUL: + headers = Haul.EN_HEADERS; + dataStorage = container.getHaul(); + break; + case LENGTH: + headers = Length.EN_HEADERS; + dataStorage = container.getLength(); + break; + case STRATA: + headers = Strata.EN_HEADERS; + dataStorage = container.getStrata(); + break; } - + int index = ArrayUtils.indexOf(headers, fieldName); // 0 = header // +1 = les données contiennent le champs 'line' en plus String realFieldName = dataStorage.get(0)[index + 1]; return realFieldName; } - + @Override public String toString() { return "Modify field " + fieldName + " on line " + lineNumber; diff --git a/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java b/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java index 2df89e7..4d46c9e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java +++ b/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java @@ -22,28 +22,24 @@ package fr.ifremer.coser.control; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; + import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserConstants.ValidationLevel; - /** * Class regroupant les erreurs de controle d'une entité, son type (erreur, * warning...) et les information supplémentaires permettant de la corriger * (numéro de ligne). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlError implements Serializable { - /** serialVersionUID. */ + private static final long serialVersionUID = -1806823191454701123L; /** Category de l'erreur. */ @@ -60,10 +56,10 @@ public class ControlError implements Serializable { /** Tip message (can be {@code null}). */ protected String tipMessage; - + /** * Numero des lignes dans le fichier CSV. - * + * * Peut être vide si l'erreur n'est pas associé à une ligne specifiques. */ protected List<String> lineNumbers; @@ -75,9 +71,9 @@ public class ControlError implements Serializable { /** * Category de l'erreur. - * + * * Peut etre null si l'erreur n'est pas associées à une category en particulier. - * + * * @return category de l'erreur */ public Category getCategory() { @@ -86,7 +82,7 @@ public class ControlError implements Serializable { /** * Category de l'erreur. - * + * * @param category category de l'erreur */ public void setCategory(Category category) { @@ -95,7 +91,7 @@ public class ControlError implements Serializable { /** * Niveau de l'erreur (fatal, error, warning, info). - * + * * @return level */ public ValidationLevel getLevel() { @@ -104,7 +100,7 @@ public class ControlError implements Serializable { /** * Niveau de l'erreur (fatal, error, warning, info). - * + * * @param level level */ public void setLevel(ValidationLevel level) { @@ -113,7 +109,7 @@ public class ControlError implements Serializable { /** * Message explicitant l'erreur de validation. - * + * * @return message */ public String getMessage() { @@ -122,7 +118,7 @@ public class ControlError implements Serializable { /** * Message explicitant l'erreur de validation. - * + * * @param message message */ public void setMessage(String message) { @@ -131,9 +127,9 @@ public class ControlError implements Serializable { /** * Message donnant plus de précision sur l'erreur. - * + * * Si le message de detail est null, le message est retourné. - * + * * @return detail message */ public String getDetailMessage() { @@ -146,7 +142,7 @@ public class ControlError implements Serializable { /** * Message donnant plus de précision sur l'erreur. - * + * * @param detailMessage detail message */ public void setDetailMessage(String detailMessage) { @@ -155,7 +151,7 @@ public class ControlError implements Serializable { /** * Get tip message (can be {@code null}). - * + * * @return tip message */ public String getTipMessage() { @@ -164,7 +160,7 @@ public class ControlError implements Serializable { /** * Set tip message (can be {@code null}). - * + * * @param tipMessage tip message */ public void setTipMessage(String tipMessage) { @@ -173,9 +169,9 @@ public class ControlError implements Serializable { /** * Numero des lignes dans le fichier CSV (sorted by implementation). - * + * * Peut être vide si l'erreur n'est pas associé a une ligne specifiques. - * + * * @return line number */ public List<String> getLineNumbers() { @@ -184,9 +180,9 @@ public class ControlError implements Serializable { /** * Numero des lignes dans le fichier CSV. - * + * * Peut être vide si l'erreur n'est pas associé a une ligne specifiques. - * + * * @param lineNumber line number */ public void addLineNumber(String lineNumber) { @@ -195,7 +191,7 @@ public class ControlError implements Serializable { /** * Numero des lignes dans le fichier CSV. - * + * * @param lineNumbers line numbers to add */ public void addAllLineNumber(Collection<String> lineNumbers) { @@ -205,6 +201,6 @@ public class ControlError implements Serializable { @Override public String toString() { return "ValidationError [level=" + level + ", message=" + message - + ", lineNumber=" + lineNumbers + "]"; + + ", lineNumber=" + lineNumbers + "]"; } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java b/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java index 848293f..3af9c15 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java +++ b/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java @@ -27,19 +27,15 @@ import fr.ifremer.coser.CoserConstants.ValidationLevel; /** * Global validation group node. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlErrorGroup implements Comparable<ControlErrorGroup> { protected final Category category; protected final ValidationLevel validationLevel; - + protected final String message; /** @@ -56,7 +52,7 @@ public class ControlErrorGroup implements Comparable<ControlErrorGroup> { public Category getCategory() { return category; } - + public ValidationLevel getValidationLevel() { return validationLevel; } diff --git a/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java b/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java index 0c4f50d..60897ea 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java +++ b/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java @@ -26,12 +26,8 @@ package fr.ifremer.coser.control; * Erreur de controle specifique pour les différences des nombres entre * les captures et les tailles pour utilisation typée de cette erreur * (export html) et information supplémentaires (especes). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class DiffCatchLengthControlError extends SpeciesControlError { diff --git a/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java b/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java index d7e8d73..418c0cb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java +++ b/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java @@ -26,24 +26,20 @@ package fr.ifremer.coser.control; * Erreur de controle specifique pour les différences des nombres entre * les captures et les tailles pour utilisation typée de cette erreur * (export html) et information supplémentaires (especes). - * + * * @author chatellier - * @version $Revision$ * @since 1.3 - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesControlError extends ControlError implements Comparable<SpeciesControlError> { - /** serialVersionUID. */ + private static final long serialVersionUID = -3254763296138201677L; protected String species; /** * Get species code (untranslated). - * + * * @param species species code */ public String getSpecies() { @@ -52,7 +48,7 @@ public class SpeciesControlError extends ControlError implements Comparable<Spec /** * Get species code (untranslated). - * + * * @param species species code */ public void setSpecies(String species) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesLengthControlError.java b/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesLengthControlError.java index 9294e44..109ff5c 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesLengthControlError.java +++ b/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesLengthControlError.java @@ -25,13 +25,9 @@ package fr.ifremer.coser.control; /** * Erreur de controls specifique aux taille des espèces devant par exemple * afficher un type de graphique particulier dans l'UI. - * + * * @author chatellier - * @version $Revision$ * @since 1.3 - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesLengthControlError extends SpeciesControlError { diff --git a/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java b/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java index a35431e..0f2cb32 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java +++ b/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java @@ -22,24 +22,22 @@ package fr.ifremer.coser.data; -import static org.nuiton.i18n.I18n.n; import fr.ifremer.coser.bean.AbstractEntity; +import static org.nuiton.i18n.I18n.n; + /** * Abstract entity to add all common data array code. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class AbstractDataEntity extends AbstractEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 4188448448464323807L; public static final int INDEX_LINE = 0; + public static final String PROPERTY_LINE = n("coser.business.line"); protected String[] data; @@ -64,7 +62,7 @@ public abstract class AbstractDataEntity extends AbstractEntity { /** * Return CSV header according to properties names. - * + * * @return header array */ public abstract String[] getHeaders(); diff --git a/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java b/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java index 41d2fa1..28fa603 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java +++ b/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java @@ -24,34 +24,35 @@ package fr.ifremer.coser.data; /** * Catch entity delegating to ordered array. - * + * * "Campagne","Annee","Trait","Espece","Nombre","Poids" * "Survey","Year","Haul","Species","Number","Weight" - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Catch extends AbstractDataEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = -3868116128268974801L; public static final String[] FR_HEADERS = { - "Campagne","Annee","Trait","Espece","Nombre","Poids" + "Campagne", "Annee", "Trait", "Espece", "Nombre", "Poids" }; public static final String[] EN_HEADERS = { - "Survey","Year","Haul","Species","Number","Weight" + "Survey", "Year", "Haul", "Species", "Number", "Weight" }; public static final int INDEX_SURVEY = 1; + public static final int INDEX_YEAR = 2; + public static final int INDEX_HAUL = 3; + public static final int INDEX_SPECIES = 4; + public static final int INDEX_NUMBER = 5; + public static final int INDEX_WEIGHT = 6; public String[] getHeaders() { @@ -77,7 +78,7 @@ public class Catch extends AbstractDataEntity { public String getYear() { return data[INDEX_YEAR]; } - + public void setHaul(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -87,7 +88,7 @@ public class Catch extends AbstractDataEntity { public String getHaul() { return data[INDEX_HAUL]; } - + public void setSpecies(String value) { String oldValue = data[INDEX_SPECIES]; data[INDEX_SPECIES] = value; @@ -97,7 +98,7 @@ public class Catch extends AbstractDataEntity { public String getSpecies() { return data[INDEX_SPECIES]; } - + public void setNumber(double value) { double oldValue = getNumber(); data[INDEX_NUMBER] = String.valueOf(value); @@ -108,7 +109,7 @@ public class Catch extends AbstractDataEntity { double result = Double.parseDouble(data[INDEX_NUMBER]); return result; } - + public void setWeight(double value) { double oldValue = getWeight(); data[INDEX_WEIGHT] = String.valueOf(value); @@ -119,7 +120,7 @@ public class Catch extends AbstractDataEntity { double result = Double.parseDouble(data[INDEX_WEIGHT]); return result; } - + public void setSurveyAsString(String value) { String oldValue = data[INDEX_SURVEY]; data[INDEX_SURVEY] = value; @@ -139,7 +140,7 @@ public class Catch extends AbstractDataEntity { public String getYearAsString() { return data[INDEX_YEAR]; } - + public void setHaulAsString(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -149,7 +150,7 @@ public class Catch extends AbstractDataEntity { public String getHaulAsString() { return data[INDEX_HAUL]; } - + public void setSpeciesAsString(String value) { String oldValue = data[INDEX_SPECIES]; data[INDEX_SPECIES] = value; @@ -159,7 +160,7 @@ public class Catch extends AbstractDataEntity { public String getSpeciesAsString() { return data[INDEX_SPECIES]; } - + public void setNumberAsString(String value) { String oldValue = data[INDEX_NUMBER]; data[INDEX_NUMBER] = value; @@ -169,7 +170,7 @@ public class Catch extends AbstractDataEntity { public String getNumberAsString() { return data[INDEX_NUMBER]; } - + public void setWeightAsString(String value) { String oldValue = data[INDEX_WEIGHT]; data[INDEX_WEIGHT] = value; diff --git a/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java b/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java index f4a7470..7e49b80 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java +++ b/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java @@ -24,37 +24,41 @@ package fr.ifremer.coser.data; /** * Haul entity delegating to ordered array. - * + * * "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy" * "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth" - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Haul extends AbstractDataEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 3931599935237369209L; public static final String[] FR_HEADERS = { - "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy" + "Campagne", "Annee", "Trait", "Mois", "Strate", "SurfaceBalayee", "Lat", "Long", "ProfMoy" }; public static final String[] EN_HEADERS = { - "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth" + "Survey", "Year", "Haul", "Month", "Stratum", "SweptSurface", "Lat", "Long", "Depth" }; public static final int INDEX_SURVEY = 1; + public static final int INDEX_YEAR = 2; + public static final int INDEX_HAUL = 3; + public static final int INDEX_MONTH = 4; + public static final int INDEX_STRATUM = 5; + public static final int INDEX_SWEPT_SURFACE = 6; + public static final int INDEX_LAT = 7; + public static final int INDEX_LONG = 8; + public static final int INDEX_DEPTH = 9; public String[] getHeaders() { @@ -70,7 +74,7 @@ public class Haul extends AbstractDataEntity { public String getSurvey() { return data[INDEX_SURVEY]; } - + public void setYear(String value) { String oldValue = data[INDEX_YEAR]; data[INDEX_YEAR] = value; @@ -80,7 +84,7 @@ public class Haul extends AbstractDataEntity { public String getYear() { return data[INDEX_YEAR]; } - + public void setHaul(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -90,7 +94,7 @@ public class Haul extends AbstractDataEntity { public String getHaul() { return data[INDEX_HAUL]; } - + public void setMonth(String value) { String oldValue = data[INDEX_MONTH]; data[INDEX_MONTH] = value; @@ -100,7 +104,7 @@ public class Haul extends AbstractDataEntity { public String getMonth() { return data[INDEX_MONTH]; } - + public void setStratum(String value) { String oldValue = data[INDEX_STRATUM]; data[INDEX_STRATUM] = value; @@ -110,7 +114,7 @@ public class Haul extends AbstractDataEntity { public String getStratum() { return data[INDEX_STRATUM]; } - + public void setSweptSurface(String value) { String oldValue = data[INDEX_SWEPT_SURFACE]; data[INDEX_SWEPT_SURFACE] = value; @@ -120,7 +124,7 @@ public class Haul extends AbstractDataEntity { public String getSweptSurface() { return data[INDEX_SWEPT_SURFACE]; } - + public void setLat(String value) { String oldValue = data[INDEX_LAT]; data[INDEX_LAT] = value; @@ -130,7 +134,7 @@ public class Haul extends AbstractDataEntity { public String getLat() { return data[INDEX_LAT]; } - + public void setLong(String value) { String oldValue = data[INDEX_LONG]; data[INDEX_LONG] = value; @@ -140,7 +144,7 @@ public class Haul extends AbstractDataEntity { public String getLong() { return data[INDEX_LONG]; } - + public void setDepth(String value) { String oldValue = data[INDEX_DEPTH]; data[INDEX_DEPTH] = value; @@ -150,7 +154,7 @@ public class Haul extends AbstractDataEntity { public String getDepth() { return data[INDEX_DEPTH]; } - + public void setSurveyAsString(String value) { String oldValue = data[INDEX_SURVEY]; data[INDEX_SURVEY] = value; @@ -160,7 +164,7 @@ public class Haul extends AbstractDataEntity { public String getSurveyAsString() { return data[INDEX_SURVEY]; } - + public void setYearAsString(String value) { String oldValue = data[INDEX_YEAR]; data[INDEX_YEAR] = value; @@ -170,7 +174,7 @@ public class Haul extends AbstractDataEntity { public String getYearAsString() { return data[INDEX_YEAR]; } - + public void setHaulAsString(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -180,7 +184,7 @@ public class Haul extends AbstractDataEntity { public String getHaulAsString() { return data[INDEX_HAUL]; } - + public void setMonthAsString(String value) { String oldValue = data[INDEX_MONTH]; data[INDEX_MONTH] = value; @@ -190,7 +194,7 @@ public class Haul extends AbstractDataEntity { public String getMonthAsString() { return data[INDEX_MONTH]; } - + public void setStratumAsString(String value) { String oldValue = data[INDEX_STRATUM]; data[INDEX_STRATUM] = value; @@ -200,7 +204,7 @@ public class Haul extends AbstractDataEntity { public String getStratumAsString() { return data[INDEX_STRATUM]; } - + public void setSweptSurfaceAsString(String value) { String oldValue = data[INDEX_SWEPT_SURFACE]; data[INDEX_SWEPT_SURFACE] = value; @@ -210,7 +214,7 @@ public class Haul extends AbstractDataEntity { public String getSweptSurfaceAsString() { return data[INDEX_SWEPT_SURFACE]; } - + public void setLatAsString(String value) { String oldValue = data[INDEX_LAT]; data[INDEX_LAT] = value; @@ -220,7 +224,7 @@ public class Haul extends AbstractDataEntity { public String getLatAsString() { return data[INDEX_LAT]; } - + public void setLongAsString(String value) { String oldValue = data[INDEX_LONG]; data[INDEX_LONG] = value; @@ -230,7 +234,7 @@ public class Haul extends AbstractDataEntity { public String getLongAsString() { return data[INDEX_LONG]; } - + public void setDepthAsString(String value) { String oldValue = data[INDEX_DEPTH]; data[INDEX_DEPTH] = value; diff --git a/coser-business/src/main/java/fr/ifremer/coser/data/Length.java b/coser-business/src/main/java/fr/ifremer/coser/data/Length.java index b15cb1f..69a3058 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/data/Length.java +++ b/coser-business/src/main/java/fr/ifremer/coser/data/Length.java @@ -24,38 +24,43 @@ package fr.ifremer.coser.data; /** * Length entity delegating to ordered array. - * + * * "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age" * "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age" - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Length extends AbstractDataEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 1283486477462355761L; public static final String[] FR_HEADERS = { - "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age" + "Campagne", "Annee", "Trait", "Espece", "Sexe", "Maturite", "Longueur", "Nombre", "Poids", "Age" }; public static final String[] EN_HEADERS = { - "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age" + "Survey", "Year", "Haul", "Species", "Sex", "Maturity", "Length", "Number", "Weight", "Age" }; public static final int INDEX_SURVEY = 1; + public static final int INDEX_YEAR = 2; + public static final int INDEX_HAUL = 3; + public static final int INDEX_SPECIES = 4; + public static final int INDEX_SEX = 5; + public static final int INDEX_MATURITY = 6; + public static final int INDEX_LENGTH = 7; + public static final int INDEX_NUMBER = 8; + public static final int INDEX_WEIGHT = 9; + public static final int INDEX_AGE = 10; public String[] getHeaders() { @@ -71,7 +76,7 @@ public class Length extends AbstractDataEntity { public String getSurvey() { return data[INDEX_SURVEY]; } - + public void setYear(String value) { String oldValue = data[INDEX_YEAR]; data[INDEX_YEAR] = value; @@ -81,7 +86,7 @@ public class Length extends AbstractDataEntity { public String getYear() { return data[INDEX_YEAR]; } - + public void setHaul(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -91,7 +96,7 @@ public class Length extends AbstractDataEntity { public String getHaul() { return data[INDEX_HAUL]; } - + public void setSpecies(String value) { String oldValue = data[INDEX_SPECIES]; data[INDEX_SPECIES] = value; @@ -111,7 +116,7 @@ public class Length extends AbstractDataEntity { public String getSex() { return data[INDEX_SEX]; } - + public void setMaturity(String value) { String oldValue = data[INDEX_MATURITY]; data[INDEX_MATURITY] = value; @@ -121,7 +126,7 @@ public class Length extends AbstractDataEntity { public String getMaturity() { return data[INDEX_MATURITY]; } - + public void setLength(String value) { String oldValue = data[INDEX_LENGTH]; data[INDEX_LENGTH] = value; @@ -141,7 +146,7 @@ public class Length extends AbstractDataEntity { public String getNumber() { return data[INDEX_NUMBER]; } - + public void setWeight(String value) { String oldValue = data[INDEX_WEIGHT]; data[INDEX_WEIGHT] = value; @@ -154,7 +159,7 @@ public class Length extends AbstractDataEntity { /** * Age field. - * + * * @param value new value to set */ public void setAge(String value) { @@ -165,13 +170,13 @@ public class Length extends AbstractDataEntity { /** * Age field. - * + * * @return age */ public String getAge() { return data[INDEX_AGE]; } - + public void setSurveyAsString(String value) { String oldValue = data[INDEX_SURVEY]; data[INDEX_SURVEY] = value; @@ -181,7 +186,7 @@ public class Length extends AbstractDataEntity { public String getSurveyAsString() { return data[INDEX_SURVEY]; } - + public void setYearAsString(String value) { String oldValue = data[INDEX_YEAR]; data[INDEX_YEAR] = value; @@ -191,7 +196,7 @@ public class Length extends AbstractDataEntity { public String getYearAsString() { return data[INDEX_YEAR]; } - + public void setHaulAsString(String value) { String oldValue = data[INDEX_HAUL]; data[INDEX_HAUL] = value; @@ -201,7 +206,7 @@ public class Length extends AbstractDataEntity { public String getHaulAsString() { return data[INDEX_HAUL]; } - + public void setSpeciesAsString(String value) { String oldValue = data[INDEX_SPECIES]; data[INDEX_SPECIES] = value; @@ -221,7 +226,7 @@ public class Length extends AbstractDataEntity { public String getSexAsString() { return data[INDEX_SEX]; } - + public void setMaturityAsString(String value) { String oldValue = data[INDEX_MATURITY]; data[INDEX_MATURITY] = value; @@ -231,7 +236,7 @@ public class Length extends AbstractDataEntity { public String getMaturityAsString() { return data[INDEX_MATURITY]; } - + public void setLengthAsString(String value) { String oldValue = data[INDEX_LENGTH]; data[INDEX_LENGTH] = value; @@ -251,7 +256,7 @@ public class Length extends AbstractDataEntity { public String getNumberAsString() { return data[INDEX_NUMBER]; } - + public void setWeightAsString(String value) { String oldValue = data[INDEX_WEIGHT]; data[INDEX_WEIGHT] = value; @@ -264,7 +269,7 @@ public class Length extends AbstractDataEntity { /** * Age field. - * + * * @param value new value to set */ public void setAgeAsString(String value) { @@ -275,7 +280,7 @@ public class Length extends AbstractDataEntity { /** * Age field. - * + * * @return age */ public String getAgeAsString() { diff --git a/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java b/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java index 04e0a21..4bccb3f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java +++ b/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java @@ -24,31 +24,29 @@ package fr.ifremer.coser.data; /** * Strata entity delegating to ordered array. - * + * * "Campagne","Strate","Surface" * "Survey","Stratum","Surface" - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Strata extends AbstractDataEntity { - /** serialVersionUID. */ + private static final long serialVersionUID = 3176546952537796549L; public static final String[] FR_HEADERS = { - "Campagne","Strate","Surface" + "Campagne", "Strate", "Surface" }; public static final String[] EN_HEADERS = { - "Survey","Stratum","Surface" + "Survey", "Stratum", "Surface" }; public static final int INDEX_SURVEY = 1; + public static final int INDEX_STRATUM = 2; + public static final int INDEX_SURFACE = 3; public String[] getHeaders() { @@ -64,7 +62,7 @@ public class Strata extends AbstractDataEntity { public String getSurvey() { return data[INDEX_SURVEY]; } - + public void setStratum(String value) { String oldValue = data[INDEX_STRATUM]; data[INDEX_STRATUM] = value; @@ -74,7 +72,7 @@ public class Strata extends AbstractDataEntity { public String getStratum() { return data[INDEX_STRATUM]; } - + public void setSurface(String value) { String oldValue = data[INDEX_SURFACE]; data[INDEX_SURFACE] = value; @@ -84,7 +82,7 @@ public class Strata extends AbstractDataEntity { public String getSurface() { return data[INDEX_SURFACE]; } - + public void setSurveyAsString(String value) { String oldValue = data[INDEX_SURVEY]; data[INDEX_SURVEY] = value; @@ -94,7 +92,7 @@ public class Strata extends AbstractDataEntity { public String getSurveyAsString() { return data[INDEX_SURVEY]; } - + public void setStratumAsString(String value) { String oldValue = data[INDEX_STRATUM]; data[INDEX_STRATUM] = value; @@ -104,7 +102,7 @@ public class Strata extends AbstractDataEntity { public String getStratumAsString() { return data[INDEX_STRATUM]; } - + public void setSurfaceAsString(String value) { String oldValue = data[INDEX_SURFACE]; data[INDEX_SURFACE] = value; @@ -114,5 +112,5 @@ public class Strata extends AbstractDataEntity { public String getSurfaceAsString() { return data[INDEX_SURFACE]; } - + } diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommand.java index c3b13b7..25a2230 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommand.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.repository.ResultRepository; /** * To execute a command on a request for a given result repository. - * <p/> + * * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserCommand<Repository extends ResultRepository, Request extends CoserRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommandFactory.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommandFactory.java index fde9273..7f3c157 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommandFactory.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserCommandFactory.java @@ -34,14 +34,14 @@ import java.util.Set; * To create commands. * Created on 3/14/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserCommandFactory { /** * Cache of command types. - * <p/> + * * Keys are (repository type id, request type). */ protected final MultiKeyMap<Object, Class<? extends CoserCommand>> commands; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserMainRepositoryProvider.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserMainRepositoryProvider.java index bd1e7a1..3dc2fcb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserMainRepositoryProvider.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserMainRepositoryProvider.java @@ -38,7 +38,7 @@ import java.util.Set; /** * Created on 3/15/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserMainRepositoryProvider { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequest.java index d1f74b7..54227ff 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequest.java @@ -26,10 +26,10 @@ import java.io.Serializable; /** * Request to obtain results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequest extends Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestBuilder.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestBuilder.java index 9ae4cb8..c7095fb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestBuilder.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestBuilder.java @@ -45,9 +45,9 @@ import java.util.Map; /** * To build requests. - * <p/> + * * TO build a new request, instanciate a new build, add some parameters and then use the {@link #toRequest()} method. - * <p/> + * * Example: * <pre> * MapRequest r = CoserRequestBuilder. @@ -58,7 +58,7 @@ import java.util.Map; * </pre> * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserRequestBuilder<R extends CoserRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestContext.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestContext.java index 20f05b6..63b4d76 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestContext.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestContext.java @@ -34,10 +34,10 @@ import java.util.Locale; /** * Useful object used by commands. - * <p/> + * * Created on 3/14/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestContext { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java index e914ca7..5611a15 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserRequestExecutor.java @@ -45,12 +45,12 @@ import java.util.Set; /** * To execute request all over coser result repositories. - * <p/> + * * This new API will let us to define any result format to be queried. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserRequestExecutor { @@ -119,9 +119,9 @@ public class CoserRequestExecutor { /** * Execute the given {@code request} to obtain a single result. - * <p/> + * * A unique result repository must match this request, otherwise a {@link DuplicatedResultException} will be thrown. - * <p/> + * * If no result repository matches the request a {@link NoResultRepositoryFoundException} will be thrown * * @param context request context @@ -165,7 +165,7 @@ public class CoserRequestExecutor { /** * Execute the given {@code request} on the first matching result repository. - * <p/> + * * If no result repository matches the request a {@link NoResultRepositoryFoundException} will be thrown. * * @param context request context @@ -215,7 +215,7 @@ public class CoserRequestExecutor { /** * Execute the given {@code request} on any matching result repository. - * <p/> + * * If no result repository matches the request a {@link NoResultRepositoryFoundException} will be thrown. * * @param context request context diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/CoserResult.java b/coser-business/src/main/java/fr/ifremer/coser/result/CoserResult.java index ac54bb2..7a805fe 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/CoserResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/CoserResult.java @@ -26,10 +26,10 @@ import java.io.Serializable; /** * Result of a request. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserResult extends Serializable { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/DefaultCoserRequestContext.java b/coser-business/src/main/java/fr/ifremer/coser/result/DefaultCoserRequestContext.java index e9e1b25..6c98b09 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/DefaultCoserRequestContext.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/DefaultCoserRequestContext.java @@ -39,7 +39,7 @@ import java.util.Locale; /** * Created on 3/14/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DefaultCoserRequestContext implements CoserRequestContext { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/DuplicatedResultException.java b/coser-business/src/main/java/fr/ifremer/coser/result/DuplicatedResultException.java index 4dd9518..6c77c3f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/DuplicatedResultException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/DuplicatedResultException.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.repository.ResultRepository; /** * When multiple result repository can offer a result. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DuplicatedResultException extends CoserTechnicalException { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/NoResultFoundException.java b/coser-business/src/main/java/fr/ifremer/coser/result/NoResultFoundException.java index 03700f8..ed8faf1 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/NoResultFoundException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/NoResultFoundException.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result; /** * When no result was found for a matching repository. - * <p/> + * * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class NoResultFoundException extends RuntimeException { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/NoResultRepositoryFoundException.java b/coser-business/src/main/java/fr/ifremer/coser/result/NoResultRepositoryFoundException.java index 884dd79..7fd3941 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/NoResultRepositoryFoundException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/NoResultRepositoryFoundException.java @@ -27,7 +27,7 @@ import fr.ifremer.coser.CoserTechnicalException; /** * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class NoResultRepositoryFoundException extends CoserTechnicalException { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/ResultRepositoryInitializationException.java b/coser-business/src/main/java/fr/ifremer/coser/result/ResultRepositoryInitializationException.java index f26a330..d3129fc 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/ResultRepositoryInitializationException.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/ResultRepositoryInitializationException.java @@ -27,13 +27,14 @@ import fr.ifremer.coser.result.repository.ResultRepositoryProvider; /** * When an eror occurs while init a result repository. - * <p/> + * * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ResultRepositoryInitializationException extends CoserTechnicalException { + private static final long serialVersionUID = 1L; protected final ResultRepositoryProvider source; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/ResultType.java b/coser-business/src/main/java/fr/ifremer/coser/result/ResultType.java index 58d3964..1a22c60 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/ResultType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/ResultType.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result; /** * Type of result we can get on a result repository. - * <p/> + * * Created on 3/12/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public enum ResultType { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepository.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepository.java index 3250888..3369e55 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepository.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepository.java @@ -26,10 +26,10 @@ import java.io.File; /** * General contract of a repository of results in CoserWeb. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface ResultRepository { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryProvider.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryProvider.java index 5ca5ca2..6fbb05d 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryProvider.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryProvider.java @@ -26,10 +26,10 @@ import java.util.Set; /** * Provides some {@link ResultRepository} for a given type of result repository. - * <p/> + * * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface ResultRepositoryProvider<Repository extends ResultRepository> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryType.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryType.java index f13bbb9..70fefbd 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/ResultRepositoryType.java @@ -33,12 +33,12 @@ import java.util.Set; /** * To define a new type of result repository. - * <p/> + * * <strong>Important Note:</strong> Each repository type must have a unique id ({@link #getId()}). - * <p/> + * * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @see GetAllResultsRequest * @since 1.5 */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBasePredicates.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBasePredicates.java index 57e4d0e..e7bc791 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBasePredicates.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBasePredicates.java @@ -31,7 +31,7 @@ import java.util.List; /** * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBasePredicates { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepository.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepository.java index cfa9b41..46ecd04 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepository.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepository.java @@ -52,7 +52,7 @@ import java.util.Set; /** * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseResultRepository implements ResultRepository { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProvider.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProvider.java index db5e899..44885f9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProvider.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProvider.java @@ -41,7 +41,7 @@ import java.util.Set; /** * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseResultRepositoryProvider implements ResultRepositoryProvider<EchoBaseResultRepository> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryType.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryType.java index 1e231b9..fd75e9d 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryType.java @@ -85,7 +85,7 @@ import static org.nuiton.i18n.I18n.n; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseResultRepositoryType implements ResultRepositoryType { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/AbstractEchoBaseCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/AbstractEchoBaseCommand.java index 69e621f..1a84ecc 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/AbstractEchoBaseCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/AbstractEchoBaseCommand.java @@ -60,7 +60,7 @@ import static org.nuiton.i18n.I18n.l; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements CoserCommand<EchoBaseResultRepository, R> { @@ -157,6 +157,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[2]; @@ -171,6 +172,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> speciesList = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[2]; @@ -186,6 +188,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> speciesList = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[2]; @@ -201,6 +204,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> speciesList = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[2]; @@ -225,6 +229,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; @@ -239,6 +244,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; @@ -255,6 +261,7 @@ public abstract class AbstractEchoBaseCommand<R extends CoserRequest> implements final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/CopyRepositoryCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/CopyRepositoryCommand.java index 3bebf6b..fa55f6b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/CopyRepositoryCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/CopyRepositoryCommand.java @@ -34,7 +34,7 @@ import java.io.IOException; /** * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CopyRepositoryCommand extends AbstractEchoBaseCommand<CopyRepositoryRequest> { @@ -47,7 +47,7 @@ public class CopyRepositoryCommand extends AbstractEchoBaseCommand<CopyRepositor @Override public VoidResult execute(CopyRepositoryRequest request) { File basedir = repository.getBasedir(); - File targetDirectory = new File (request.getTargetDirectory(), repository.getProjectName()); + File targetDirectory = new File(request.getTargetDirectory(), repository.getProjectName()); try { CoserUtils.customCopyDirectory(basedir, targetDirectory, FileFilterUtils.trueFileFilter()); } catch (IOException e) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/DeleteResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/DeleteResultsCommand.java index 10b010a..5b91814 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/DeleteResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/DeleteResultsCommand.java @@ -35,7 +35,7 @@ import java.io.IOException; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DeleteResultsCommand extends AbstractEchoBaseCommand<DeleteResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataAndResultsCommand.java index d032d18..711a963 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataAndResultsCommand.java @@ -50,7 +50,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataAndResultsCommand extends AbstractEchoBaseCommand<ExtractRawDataAndResultsRequest> { @@ -188,6 +188,7 @@ public class ExtractRawDataAndResultsCommand extends AbstractEchoBaseCommand<Ext // get for all indicators the first species list found (we only extract this one) final Map<String, String> indicatorLists = new HashMap<String, String>(); walkOnCommunity(LegacyPredicates.communityIndicatorPredicate(indicators), new DataStorageWalker() { + @Override public void onRow(String... row) { String indicatorCode = row[1]; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataCommand.java index c4c5623..b75214a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/ExtractRawDataCommand.java @@ -38,7 +38,7 @@ import java.util.Locale; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataCommand extends AbstractEchoBaseCommand<ExtractRawDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetAllResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetAllResultsCommand.java index 3122164..7b3280b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetAllResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetAllResultsCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetAllResultsCommand extends AbstractEchoBaseCommand<GetAllResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultDataCommand.java index b529f80..d26d423 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultDataCommand.java @@ -39,7 +39,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultDataCommand extends AbstractEchoBaseCommand<GetCommunityIndicatorResultDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultGraphCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultGraphCommand.java index 7d0af19..bb4dd79 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultGraphCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetCommunityIndicatorResultGraphCommand.java @@ -34,7 +34,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultGraphCommand extends AbstractEchoBaseCommand<GetCommunityIndicatorResultGraphRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForCommunityIndicatorResultCommand.java index 41379f2..20e049b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForCommunityIndicatorResultCommand.java @@ -31,7 +31,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForCommunityIndicatorResultCommand extends AbstractEchoBaseCommand<GetIndicatorsForCommunityIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForExtractRawDataAndResultsCommand.java index 3626a51..070bea7 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForExtractRawDataAndResultsCommand.java @@ -32,7 +32,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForExtractRawDataAndResultsCommand extends AbstractEchoBaseCommand<GetIndicatorsForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForPopulationIndicatorResultCommand.java index 5bbee60..7488a0e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetIndicatorsForPopulationIndicatorResultCommand.java @@ -33,7 +33,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForPopulationIndicatorResultCommand extends AbstractEchoBaseCommand<GetIndicatorsForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMapResultCommand.java index 1c9f6d7..b9da264 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMapResultCommand.java @@ -30,7 +30,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMapResultCommand extends AbstractEchoBaseCommand<GetMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMatchingRepositoryTypeForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMatchingRepositoryTypeForMapResultCommand.java index a1fe48d..8f24daf 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMatchingRepositoryTypeForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetMatchingRepositoryTypeForMapResultCommand.java @@ -30,7 +30,7 @@ import java.io.File; /** * Created on 6/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMatchingRepositoryTypeForMapResultCommand extends AbstractEchoBaseCommand<GetMatchingRepositoryTypeForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultDataCommand.java index 08a5c10..37e2f5c 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultDataCommand.java @@ -35,7 +35,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultDataCommand extends AbstractEchoBaseCommand<GetPopulationIndicatorResultDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultGraphCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultGraphCommand.java index a79d01e..f4e8a53 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultGraphCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetPopulationIndicatorResultGraphCommand.java @@ -34,7 +34,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultGraphCommand extends AbstractEchoBaseCommand<GetPopulationIndicatorResultGraphRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetResultNameCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetResultNameCommand.java index b837d3b..c9905a1 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetResultNameCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetResultNameCommand.java @@ -33,7 +33,7 @@ import java.util.Map; /** * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetResultNameCommand extends AbstractEchoBaseCommand<GetResultNameRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForExtractRawDataAndResultsCommand.java index 6ea3222..904cc81 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForExtractRawDataAndResultsCommand.java @@ -33,7 +33,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForExtractRawDataAndResultsCommand extends AbstractEchoBaseCommand<GetSpeciesForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForMapResultCommand.java index aab6d32..86eac0e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForMapResultCommand.java @@ -30,7 +30,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForMapResultCommand extends AbstractEchoBaseCommand<GetSpeciesForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForPopulationIndicatorResultCommand.java index 48ab0e8..a88d3a8 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesForPopulationIndicatorResultCommand.java @@ -30,7 +30,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForPopulationIndicatorResultCommand extends AbstractEchoBaseCommand<GetSpeciesForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesListForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesListForCommunityIndicatorResultCommand.java index 08844db..f0dba69 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesListForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetSpeciesListForCommunityIndicatorResultCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesListForCommunityIndicatorResultCommand extends AbstractEchoBaseCommand<GetSpeciesListForCommunityIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForCommunityIndicatorResultCommand.java index 0ba9d3b..ca727e3 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForCommunityIndicatorResultCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForCommunityIndicatorResultCommand extends AbstractEchoBaseCommand<GetZonesForCommunityIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataAndResultsCommand.java index 4de828b..1059ad8 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataAndResultsCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataAndResultsCommand extends AbstractEchoBaseCommand<GetZonesForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataCommand.java index 9caf231..e2aaf4a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForExtractRawDataCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataCommand extends AbstractEchoBaseCommand<GetZonesForExtractRawDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForMapResultCommand.java index dfcc705..305b17b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForMapResultCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForMapResultCommand extends AbstractEchoBaseCommand<GetZonesForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForPopulationIndicatorResultCommand.java index d4a92de..02e47d2 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/echobase/command/GetZonesForPopulationIndicatorResultCommand.java @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForPopulationIndicatorResultCommand extends AbstractEchoBaseCommand<GetZonesForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyPredicates.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyPredicates.java index f07d0d3..07c9347 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyPredicates.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyPredicates.java @@ -31,7 +31,7 @@ import java.util.List; /** * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class LegacyPredicates { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepository.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepository.java index 8d9dcb9..f78595e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepository.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepository.java @@ -55,7 +55,7 @@ import java.util.Set; /** * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class LegacyResultRepository implements ResultRepository { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProvider.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProvider.java index b397f9f..2c638ba 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProvider.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProvider.java @@ -44,7 +44,7 @@ import java.util.Set; /** * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class LegacyResultRepositoryProvider implements ResultRepositoryProvider<LegacyResultRepository> { @@ -107,7 +107,7 @@ public class LegacyResultRepositoryProvider implements ResultRepositoryProvider< /** * Retourne tous les projets qui ont des résultats. - * <p/> + * * De la forme d'une liste de de path (à la tree path) : * ProjetName/SelectionName/ResultName * diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryType.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryType.java index d9db19f..f011d2d 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryType.java @@ -83,7 +83,7 @@ import static org.nuiton.i18n.I18n.n; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class LegacyResultRepositoryType implements ResultRepositoryType { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/AbstractLegacyCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/AbstractLegacyCommand.java index f167495..8f3ae2a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/AbstractLegacyCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/AbstractLegacyCommand.java @@ -63,7 +63,7 @@ import static org.nuiton.i18n.I18n.l; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements CoserCommand<LegacyResultRepository, R> { @@ -166,7 +166,6 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C } - // --------------------------------------------------------------------- // // --- Get species lists ----------------------------------------------- // // --------------------------------------------------------------------- // @@ -175,6 +174,7 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[3]; @@ -189,20 +189,6 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C final Set<String> speciesList = getPopulationSpecies(); Map<String, String> result = repository.getSpeciesMap().getSpeciesSubMap(speciesList); - -// SpeciesMap speciesNames = getSpeciesMap(); -// Iterator<String[]> iterator = loadPopulationIndicatorStorage(true); -// while (iterator.hasNext()) { -// String[] tuple = iterator.next(); -// String speciesCode = tuple[3]; -// -// String speciesName = speciesNames.getSpeciesName(speciesCode); -// -// if (StringUtils.isNotEmpty(speciesName)) { -// result.put(speciesCode, speciesName); -// } -// result.put(speciesCode, speciesName); -// } return result; } @@ -210,6 +196,7 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C final Set<String> speciesList = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesCode = tuple[3]; @@ -219,19 +206,6 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C walkOnCommunity(walker); Map<String, String> result = repository.getSpeciesMap().getSpeciesSubMap(speciesList); -// SpeciesMap speciesNames = getSpeciesMap(); -// Iterator<String[]> iterator = loadCommunityIndicatorStorage(true); -// while (iterator.hasNext()) { -// String[] tuple = iterator.next(); -// String speciesCode = tuple[3]; -// -// String speciesName = speciesNames.getSpeciesName(speciesCode); -// -// if (StringUtils.isNotEmpty(speciesName)) { -// result.put(speciesCode, speciesName); -// } -// result.put(speciesCode, speciesName); -// } return result; } @@ -247,6 +221,7 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C protected Set<String> getCommunityIndicators() { final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; @@ -254,19 +229,13 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C } }; walkOnCommunity(walker); -// Iterator<String[]> iterator = loadCommunityIndicatorStorage(true); -// final Set<String> result = Sets.newHashSet(); -// while (iterator.hasNext()) { -// String[] tuple = iterator.next(); -// String indicatorCode = tuple[1]; -// result.add(indicatorCode); -// } return result; } protected Set<String> getPopulationIndicators() { final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; @@ -274,19 +243,13 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C } }; walkOnPopulation(walker); -// Iterator<String[]> iterator = loadPopulationIndicatorStorage(true); -// Set<String> result = Sets.newHashSet(); -// while (iterator.hasNext()) { -// String[] tuple = iterator.next(); -// String indicatorCode = tuple[1]; -// result.add(indicatorCode); -// } return result; } protected Set<String> getPopulationIndicators(String species) { final Set<String> result = Sets.newHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String indicatorCode = tuple[1]; @@ -294,15 +257,6 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C } }; walkOnPopulation(LegacyPredicates.populationSpeciesPredicate(species), walker); -// Iterator<String[]> iterator = loadPopulationIndicatorStorage(true); -// Set<String> result = Sets.newHashSet(); -// while (iterator.hasNext()) { -// String[] tuple = iterator.next(); -// if (matchPopulationSpecies(tuple, species)) { -// String indicatorCode = tuple[1]; -// result.add(indicatorCode); -// } -// } return result; } @@ -457,262 +411,4 @@ public abstract class AbstractLegacyCommand<R extends CoserRequest> implements C return chart; } -// protected JFreeChart generateCommunityChart(Locale locale, -// String zone, -// String indicator, -// String speciesList) { -// -// Predicate<String[]> predicate = Predicates.and( -// LegacyPredicates.communityIndicatorPredicate(indicator), -// LegacyPredicates.communitySpeciesListPredicate(speciesList)); -// -// CommunityExtractGraphDataWalker walker = new CommunityExtractGraphDataWalker(); -// walkOnCommunity(predicate, walker); -// -// // get graph title -// String zoneDisplayName = getZoneMap().getZoneFullName(zone); -// String indicatorName = getIndicatorMap().getIndicatorValue(locale, indicator); -// String speciesListName = repository.getSpeciesListMap().getSpeciesListName(locale, speciesList); -// String chartTitle = zoneDisplayName + " - " + indicatorName + " - " + speciesListName; -// -// int multiplicator = walker.getMultiplicator(); -// int minYear = walker.getMinYear(); -// int maxYear = walker.getMaxYear(); -// Map<Integer, Double[]> graphData = walker.getGraphData(); -// -// // generate dataset with sorted data -// DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); -// for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { -// Double[] entry = graphData.get(indexYear); -// if (entry != null) { -// Double estimation = entry[0] / multiplicator; -// Double ecart = entry[1] / multiplicator; -// statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); -// } else { -// statisticalDataset.add(null, null, "Serie1", indexYear); -// } -// } -// -// // configure chart -// String yearAxis = Reports.getYearChartTitle(locale); -// CategoryAxis categoryAxis = new CategoryAxis(yearAxis); -// categoryAxis.setCategoryMargin(0); -// categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); -// -// String unit = getIndicatorMap().getIndicatorUnit(indicator); -// // label horizontaux -// String legendY = indicatorName; -// if (multiplicator != 1) { -// // affiche par exemple : cm * 1000 -// legendY += " (" + unit + "*" + multiplicator + ")"; -// } else if (StringUtils.isNotEmpty(unit)) { -// legendY += " (" + unit + ")"; -// } -// ValueAxis valueAxis = new NumberAxis(legendY); -// valueAxis.setUpperMargin(0.1); -// -// CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); -// -// CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); -// plot.setOrientation(PlotOrientation.VERTICAL); -// JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); -// -// // remove series legend -// chart.removeLegend(); -// // white background -// chart.setBackgroundPaint(Color.WHITE); -// -// return chart; -// } - -// protected JFreeChart generatePopulationChart(Locale locale, -// String zone, -// String species, -// String indicator) { -// -// // get data to put in graph -// Predicate<String[]> predicate = Predicates.and( -// LegacyPredicates.populationSpeciesPredicate(species), -// LegacyPredicates.populationIndicatorPredicate(indicator)); -// -// PopulationExtractGraphDataWalker walker = new PopulationExtractGraphDataWalker(); -// walkOnPopulation(predicate, walker); -// -// int multiplicator = walker.getMultiplicator(); -// int minYear = walker.getMinYear(); -// int maxYear = walker.getMaxYear(); -// Map<Integer, Double[]> graphData = walker.getGraphData(); -// -// String zoneDisplayName = getZoneMap().getZoneFullName(zone); -// String indicatorName = getIndicatorMap().getIndicatorValue(locale, indicator); -// -// // get graph title -// String title = zoneDisplayName + " - " + indicatorName + " - " + repository.getSpeciesMap().getReportDisplayName(species); -// -// // generate dataset with sorted data -// DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); -// for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { -// Double[] entry = graphData.get(indexYear); -// if (entry != null) { -// Double estimation = entry[0] / multiplicator; -// Double ecart = entry[1] / multiplicator; -// statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); -// } else { -// statisticalDataset.add(null, null, "Serie1", indexYear); -// } -// } -// -// // configure chart -// //CategoryAxis categoryAxis = new CategoryAxis(t("coser.business.common.year")); -// String yearAxis = Reports.getYearChartTitle(locale); -// CategoryAxis categoryAxis = new CategoryAxis(yearAxis); -// categoryAxis.setCategoryMargin(0); -// categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); -// -// // label horizontaux -// String unit = getIndicatorMap().getIndicatorUnit(indicator); -// String legendY = indicatorName; -// if (multiplicator != 1) { -// // affiche par exemple : cm * 1000 -// legendY += " (" + unit + "*" + multiplicator + ")"; -// } else if (StringUtils.isNotEmpty(unit)) { -// legendY += " (" + unit + ")"; -// } -// ValueAxis valueAxis = new NumberAxis(legendY); -// valueAxis.setUpperMargin(0.1); -// -// CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); -// -// CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); -// plot.setOrientation(PlotOrientation.VERTICAL); -// JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); -// -// // remove series legend -// chart.removeLegend(); -// // white background -// chart.setBackgroundPaint(Color.WHITE); -// -// return chart; -// } -// -// protected static class CommunityExtractGraphDataWalker implements DataStorageWalker { -// -// int multiplicator = 1; -// -// int minYear = Integer.MAX_VALUE; -// -// int maxYear = Integer.MIN_VALUE; -// -// boolean indicatorFound = false; -// -// Map<Integer, Double[]> graphData = new HashMap<Integer, Double[]>(); -// -// @Override -// public void onRow(String... tuple) { -// -// indicatorFound = true; -// -// Double estimation = Double.parseDouble(tuple[5]); -// Double ecart = Double.parseDouble(tuple[6]); -// int year = Integer.parseInt(tuple[4]); -// -// if (year < minYear) { -// minYear = year; -// } -// if (year > maxYear) { -// maxYear = year; -// } -// graphData.put(year, new Double[]{estimation, ecart}); -// -// // si les données sont énormes, on affiche les données -// // / multiplicator et on le mentionne dans la légende -// if (estimation > 1e9) { -// multiplicator = 1000000; -// } -// if (estimation > 1e6 && multiplicator < 1000000) { -// multiplicator = 1000; -// } -// } -// -// public int getMultiplicator() { -// return multiplicator; -// } -// -// public int getMinYear() { -// return minYear; -// } -// -// public int getMaxYear() { -// return maxYear; -// } -// -// public boolean isIndicatorFound() { -// return indicatorFound; -// } -// -// public Map<Integer, Double[]> getGraphData() { -// return graphData; -// } -// } - -// protected static class PopulationExtractGraphDataWalker implements DataStorageWalker { -// -// int multiplicator = 1; -// -// int minYear = Integer.MAX_VALUE; -// -// int maxYear = Integer.MIN_VALUE; -// -// boolean indicatorFound = false; -// -// Map<Integer, Double[]> graphData = new HashMap<Integer, Double[]>(); -// -// @Override -// public void onRow(String... tuple) { -// -// indicatorFound = true; -// -// Double estimation = Double.parseDouble(tuple[6]); -// Double ecart = Double.parseDouble(tuple[7]); -// int year = Integer.parseInt(tuple[5]); -// -// if (year < minYear) { -// minYear = year; -// } -// if (year > maxYear) { -// maxYear = year; -// } -// graphData.put(year, new Double[]{estimation, ecart}); -// -// // si les données sont énormes, on affiche les données -// // / multiplicator et on le mentionne dans la légende -// if (estimation > 1e9) { -// multiplicator = 1000000; -// } -// if (estimation > 1e6 && multiplicator < 1000000) { -// multiplicator = 1000; -// } -// } -// -// public int getMultiplicator() { -// return multiplicator; -// } -// -// public int getMinYear() { -// return minYear; -// } -// -// public int getMaxYear() { -// return maxYear; -// } -// -// public boolean isIndicatorFound() { -// return indicatorFound; -// } -// -// public Map<Integer, Double[]> getGraphData() { -// return graphData; -// } -// } - } diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/DeleteResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/DeleteResultsCommand.java index 1891039..4331570 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/DeleteResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/DeleteResultsCommand.java @@ -35,7 +35,7 @@ import java.io.IOException; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DeleteResultsCommand extends AbstractLegacyCommand<DeleteResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataAndResultsCommand.java index e592b1e..5e398a0 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataAndResultsCommand.java @@ -49,7 +49,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataAndResultsCommand extends AbstractLegacyCommand<ExtractRawDataAndResultsRequest> { @@ -206,6 +206,7 @@ public class ExtractRawDataAndResultsCommand extends AbstractLegacyCommand<Extra // get for all indicators the first species list found (we only extract this one) final Map<String, String> indicatorLists = new HashMap<String, String>(); walkOnCommunity(LegacyPredicates.communityIndicatorPredicate(indicators), new DataStorageWalker() { + @Override public void onRow(String... row) { String indicatorCode = row[1]; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataCommand.java index b05d511..7fe96c3 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/ExtractRawDataCommand.java @@ -39,7 +39,7 @@ import java.util.Locale; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataCommand extends AbstractLegacyCommand<ExtractRawDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetAllResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetAllResultsCommand.java index 485b85a..8b074a4 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetAllResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetAllResultsCommand.java @@ -24,15 +24,15 @@ package fr.ifremer.coser.result.repository.legacy.command; import com.google.common.collect.Maps; import fr.ifremer.coser.result.CoserResult; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetAllResultsRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetAllResultsCommand extends AbstractLegacyCommand<GetAllResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultDataCommand.java index b214d8a..994bed9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultDataCommand.java @@ -39,7 +39,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultDataCommand extends AbstractLegacyCommand<GetCommunityIndicatorResultDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultGraphCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultGraphCommand.java index 481f8db..3690786 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultGraphCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetCommunityIndicatorResultGraphCommand.java @@ -34,7 +34,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultGraphCommand extends AbstractLegacyCommand<GetCommunityIndicatorResultGraphRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForCommunityIndicatorResultCommand.java index d7d59a0..36d73bb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForCommunityIndicatorResultCommand.java @@ -22,8 +22,8 @@ package fr.ifremer.coser.result.repository.legacy.command; * #L% */ -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetIndicatorsForCommunityIndicatorResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.Map; import java.util.Set; @@ -31,7 +31,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForCommunityIndicatorResultCommand extends AbstractLegacyCommand<GetIndicatorsForCommunityIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForExtractRawDataAndResultsCommand.java index 71e35a1..dd84c71 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForExtractRawDataAndResultsCommand.java @@ -22,8 +22,8 @@ package fr.ifremer.coser.result.repository.legacy.command; * #L% */ -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetIndicatorsForExtractRawDataAndResultsRequest; +import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.util.DataType; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForExtractRawDataAndResultsCommand extends AbstractLegacyCommand<GetIndicatorsForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForPopulationIndicatorResultCommand.java index 0312669..ba67f2b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetIndicatorsForPopulationIndicatorResultCommand.java @@ -23,9 +23,9 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import com.google.common.base.Predicate; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.repository.legacy.LegacyPredicates; import fr.ifremer.coser.result.request.GetIndicatorsForPopulationIndicatorResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.Map; import java.util.Set; @@ -33,7 +33,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForPopulationIndicatorResultCommand extends AbstractLegacyCommand<GetIndicatorsForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMapResultCommand.java index c359ea3..4ee6214 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMapResultCommand.java @@ -22,15 +22,15 @@ package fr.ifremer.coser.result.repository.legacy.command; * #L% */ -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetMapResultRequest; +import fr.ifremer.coser.result.result.FileResult; import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMapResultCommand extends AbstractLegacyCommand<GetMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMatchingRepositoryTypeForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMatchingRepositoryTypeForMapResultCommand.java index a6ce468..6bec5b7 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMatchingRepositoryTypeForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetMatchingRepositoryTypeForMapResultCommand.java @@ -30,7 +30,7 @@ import java.io.File; /** * Created on 6/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMatchingRepositoryTypeForMapResultCommand extends AbstractLegacyCommand<GetMatchingRepositoryTypeForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultDataCommand.java index 8ec34fb..956e6d9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultDataCommand.java @@ -35,7 +35,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultDataCommand extends AbstractLegacyCommand<GetPopulationIndicatorResultDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultGraphCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultGraphCommand.java index 56bd330..5354669 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultGraphCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetPopulationIndicatorResultGraphCommand.java @@ -24,9 +24,9 @@ package fr.ifremer.coser.result.repository.legacy.command; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.repository.legacy.LegacyPredicates; import fr.ifremer.coser.result.request.GetPopulationIndicatorResultGraphRequest; +import fr.ifremer.coser.result.result.FileResult; import org.jfree.chart.JFreeChart; import java.io.File; @@ -34,7 +34,7 @@ import java.io.File; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultGraphCommand extends AbstractLegacyCommand<GetPopulationIndicatorResultGraphRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetResultNameCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetResultNameCommand.java index 2ae8c10..e5e8046 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetResultNameCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetResultNameCommand.java @@ -33,7 +33,7 @@ import java.util.Map; /** * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetResultNameCommand extends AbstractLegacyCommand<GetResultNameRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForExtractRawDataAndResultsCommand.java index 919ee83..3fc03dc 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForExtractRawDataAndResultsCommand.java @@ -33,7 +33,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForExtractRawDataAndResultsCommand extends AbstractLegacyCommand<GetSpeciesForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForMapResultCommand.java index c18748e..3c5048a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForMapResultCommand.java @@ -22,15 +22,15 @@ package fr.ifremer.coser.result.repository.legacy.command; * #L% */ -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetSpeciesForMapResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForMapResultCommand extends AbstractLegacyCommand<GetSpeciesForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForPopulationIndicatorResultCommand.java index 696e259..564d6c2 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesForPopulationIndicatorResultCommand.java @@ -22,15 +22,15 @@ package fr.ifremer.coser.result.repository.legacy.command; * #L% */ -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetSpeciesForPopulationIndicatorResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForPopulationIndicatorResultCommand extends AbstractLegacyCommand<GetSpeciesForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesListForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesListForCommunityIndicatorResultCommand.java index 73b9c32..114ce3b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesListForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetSpeciesListForCommunityIndicatorResultCommand.java @@ -35,7 +35,7 @@ import java.util.Set; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesListForCommunityIndicatorResultCommand extends AbstractLegacyCommand<GetSpeciesListForCommunityIndicatorResultRequest> { @@ -60,6 +60,7 @@ public class GetSpeciesListForCommunityIndicatorResultCommand extends AbstractLe // linked hash map (doit respecter l'ordre d'insertion) final Set<String> speciesList = Sets.newLinkedHashSet(); DataStorageWalker walker = new DataStorageWalker() { + @Override public void onRow(String... tuple) { String speciesListCode = tuple[2]; diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForCommunityIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForCommunityIndicatorResultCommand.java index c6eafcb..01a8ec9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForCommunityIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForCommunityIndicatorResultCommand.java @@ -23,8 +23,8 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import fr.ifremer.coser.bean.ZoneMap; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetZonesForCommunityIndicatorResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.List; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForCommunityIndicatorResultCommand extends AbstractLegacyCommand<GetZonesForCommunityIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataAndResultsCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataAndResultsCommand.java index de53f7e..e9fcb59 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataAndResultsCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataAndResultsCommand.java @@ -23,8 +23,8 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import fr.ifremer.coser.bean.ZoneMap; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetZonesForExtractRawDataAndResultsRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.List; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataAndResultsCommand extends AbstractLegacyCommand<GetZonesForExtractRawDataAndResultsRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataCommand.java index 05b7c84..b9eef4f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForExtractRawDataCommand.java @@ -23,8 +23,8 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import fr.ifremer.coser.bean.ZoneMap; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetZonesForExtractRawDataRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.List; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataCommand extends AbstractLegacyCommand<GetZonesForExtractRawDataRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForMapResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForMapResultCommand.java index 776c4b5..6094a83 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForMapResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForMapResultCommand.java @@ -23,8 +23,8 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import fr.ifremer.coser.bean.ZoneMap; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetZonesForMapResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.List; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForMapResultCommand extends AbstractLegacyCommand<GetZonesForMapResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForPopulationIndicatorResultCommand.java b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForPopulationIndicatorResultCommand.java index 1d34b09..fe15886 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForPopulationIndicatorResultCommand.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/repository/legacy/command/GetZonesForPopulationIndicatorResultCommand.java @@ -23,8 +23,8 @@ package fr.ifremer.coser.result.repository.legacy.command; */ import fr.ifremer.coser.bean.ZoneMap; -import fr.ifremer.coser.result.result.MapResult; import fr.ifremer.coser.result.request.GetZonesForPopulationIndicatorResultRequest; +import fr.ifremer.coser.result.result.MapResult; import java.util.List; import java.util.Map; @@ -32,7 +32,7 @@ import java.util.Map; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForPopulationIndicatorResultCommand extends AbstractLegacyCommand<GetZonesForPopulationIndicatorResultRequest> { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/AbstractGetIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/AbstractGetIndicatorResultRequest.java index 3d02a9e..7b05c32 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/AbstractGetIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/AbstractGetIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public abstract class AbstractGetIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware, CoserRequestSpeciesAware, CoserRequestIndicatorAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CopyRepositoryRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CopyRepositoryRequest.java index 0b5e56f..f967cb9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CopyRepositoryRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CopyRepositoryRequest.java @@ -32,7 +32,7 @@ import java.util.List; /** * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CopyRepositoryRequest implements CoserRequest, CoserRequestZoneListAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestExtractTypeListAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestExtractTypeListAware.java index 5c1025c..6bd93ba 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestExtractTypeListAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestExtractTypeListAware.java @@ -30,7 +30,7 @@ import java.util.List; /** * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestExtractTypeListAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestFacadeAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestFacadeAware.java index 0f2fe8b..578b094 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestFacadeAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestFacadeAware.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Place this on any request which involve a {@code facade}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestFacadeAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestIndicatorAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestIndicatorAware.java index d71adb1..e4d9870 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestIndicatorAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestIndicatorAware.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Place this on any request which involve a {@code indicator}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestIndicatorAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryResultTypeAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryResultTypeAware.java index 9409017..65ccccd 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryResultTypeAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryResultTypeAware.java @@ -28,7 +28,7 @@ import fr.ifremer.coser.result.ResultType; /** * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestRepositoryResultTypeAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryTypeAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryTypeAware.java index 4e43121..f58cd19 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryTypeAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestRepositoryTypeAware.java @@ -27,7 +27,7 @@ import fr.ifremer.coser.result.CoserRequest; /** * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestRepositoryTypeAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestSpeciesAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestSpeciesAware.java index b1138aa..3a0250a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestSpeciesAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestSpeciesAware.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Place this on any request which involve a {@code species}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestSpeciesAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneAware.java index 4deed25..0e2182f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneAware.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Place this on any request which involve a {@code zone}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestZoneAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneListAware.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneListAware.java index bc17c3d..dd1f0b8 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneListAware.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/CoserRequestZoneListAware.java @@ -28,10 +28,10 @@ import java.util.List; /** * Place this on any request which involve a {@code zone}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface CoserRequestZoneListAware extends CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/DeleteResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/DeleteResultsRequest.java index b9a6edd..72f52eb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/DeleteResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/DeleteResultsRequest.java @@ -34,7 +34,7 @@ import java.util.List; * To delete some results. * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DeleteResultsRequest implements CoserRequest, CoserRequestZoneListAware, CoserRequestRepositoryTypeAware, CoserRequestRepositoryResultTypeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataAndResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataAndResultsRequest.java index 521ee4f..31b9757 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataAndResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataAndResultsRequest.java @@ -32,10 +32,10 @@ import java.util.List; /** * Request to extract data. - * <p/> + * * Created on 3/9/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataAndResultsRequest implements CoserRequest, CoserRequestZoneListAware, CoserRequestExtractTypeListAware { @@ -60,7 +60,7 @@ public class ExtractRawDataAndResultsRequest implements CoserRequest, CoserReque @Override public boolean isFilled() { boolean filled = CollectionUtils.isNotEmpty(extractTypeList) - && CollectionUtils.isNotEmpty(zoneList); + && CollectionUtils.isNotEmpty(zoneList); if (filled) { if (DataType.isNeedSpecies(extractTypeList)) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataRequest.java index 2835174..4365d45 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/ExtractRawDataRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain raw data results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetAllResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetAllResultsRequest.java index 9806e7d..937d5f5 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetAllResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetAllResultsRequest.java @@ -30,7 +30,7 @@ import fr.ifremer.coser.result.repository.ResultRepositoryType; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetAllResultsRequest implements CoserRequest, CoserRequestRepositoryTypeAware, CoserRequestRepositoryResultTypeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultDataRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultDataRequest.java index 85e29d8..c413b9b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultDataRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultDataRequest.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result.request; /** * Request to obtain community indicator results data. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultDataRequest extends AbstractGetIndicatorResultRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultGraphRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultGraphRequest.java index 3577d70..d7c6579 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultGraphRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetCommunityIndicatorResultGraphRequest.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result.request; /** * Request to obtain community indicator results graph. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetCommunityIndicatorResultGraphRequest extends AbstractGetIndicatorResultRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForCommunityIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForCommunityIndicatorResultRequest.java index c6ed9c0..0963f36 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForCommunityIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForCommunityIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForCommunityIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForExtractRawDataAndResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForExtractRawDataAndResultsRequest.java index a68fbf2..22ee296 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForExtractRawDataAndResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForExtractRawDataAndResultsRequest.java @@ -31,10 +31,10 @@ import java.util.List; /** * Request to extract data. - * <p/> + * * Created on 3/9/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForExtractRawDataAndResultsRequest implements CoserRequest, CoserRequestZoneListAware, CoserRequestExtractTypeListAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForPopulationIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForPopulationIndicatorResultRequest.java index 745e690..3bdd3b6 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForPopulationIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetIndicatorsForPopulationIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsForPopulationIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware, CoserRequestSpeciesAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMapResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMapResultRequest.java index 224dec0..3d76bf5 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMapResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMapResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain map results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMapResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware, CoserRequestSpeciesAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMatchingRepositoryTypeForMapResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMatchingRepositoryTypeForMapResultRequest.java index 03d66c9..0dfa9e5 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMatchingRepositoryTypeForMapResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetMatchingRepositoryTypeForMapResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * To find out whihc repository type matchs this request. - * + * * Created on 6/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetMatchingRepositoryTypeForMapResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware, CoserRequestSpeciesAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultDataRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultDataRequest.java index 57bc65a..2d2edb0 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultDataRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultDataRequest.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result.request; /** * Request to obtain population indicator results data. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultDataRequest extends AbstractGetIndicatorResultRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultGraphRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultGraphRequest.java index f6c6d82..9dc9f0d 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultGraphRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetPopulationIndicatorResultGraphRequest.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.result.request; /** * Request to obtain population indicator result as a graph. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetPopulationIndicatorResultGraphRequest extends AbstractGetIndicatorResultRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetResultNameRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetResultNameRequest.java index 8dbdf3f..54c92e9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetResultNameRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetResultNameRequest.java @@ -32,7 +32,7 @@ import java.util.List; /** * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetResultNameRequest implements CoserRequest, CoserRequestExtractTypeListAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForExtractRawDataAndResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForExtractRawDataAndResultsRequest.java index d1f4a26..24c40e5 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForExtractRawDataAndResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForExtractRawDataAndResultsRequest.java @@ -31,10 +31,10 @@ import java.util.List; /** * Request to extract data. - * <p/> + * * Created on 3/9/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForExtractRawDataAndResultsRequest implements CoserRequest, CoserRequestZoneListAware, CoserRequestExtractTypeListAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForMapResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForMapResultRequest.java index 59ae2d6..2d6e4e4 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForMapResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForMapResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain available species for map results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForMapResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForPopulationIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForPopulationIndicatorResultRequest.java index 8e7c3c3..aca9e64 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForPopulationIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesForPopulationIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesForPopulationIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesListForCommunityIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesListForCommunityIndicatorResultRequest.java index 308389e..1eccdb9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesListForCommunityIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetSpeciesListForCommunityIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetSpeciesListForCommunityIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware, CoserRequestZoneAware, CoserRequestIndicatorAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForCommunityIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForCommunityIndicatorResultRequest.java index 43b6795..7f6d8fe 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForCommunityIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForCommunityIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain available zones for community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForCommunityIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataAndResultsRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataAndResultsRequest.java index 5459893..188328b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataAndResultsRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataAndResultsRequest.java @@ -26,10 +26,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to extract data. - * <p/> + * * Created on 3/9/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataAndResultsRequest implements CoserRequest { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataRequest.java index b847e13..528f670 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForExtractRawDataRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain raw data results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForExtractRawDataRequest implements CoserRequest, CoserRequestFacadeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForMapResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForMapResultRequest.java index 6bacb86..6a1a0dd 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForMapResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForMapResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain available zones for map results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForMapResultRequest implements CoserRequest, CoserRequestFacadeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForPopulationIndicatorResultRequest.java b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForPopulationIndicatorResultRequest.java index 7a0df10..fe3cad2 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForPopulationIndicatorResultRequest.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/request/GetZonesForPopulationIndicatorResultRequest.java @@ -27,10 +27,10 @@ import fr.ifremer.coser.result.CoserRequest; /** * Request to obtain available zones for community indicator results. - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForPopulationIndicatorResultRequest implements CoserRequest, CoserRequestFacadeAware { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/result/ExtractRawDataAndResultsResult.java b/coser-business/src/main/java/fr/ifremer/coser/result/result/ExtractRawDataAndResultsResult.java index 3829a74..5a5fc93 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/result/ExtractRawDataAndResultsResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/result/ExtractRawDataAndResultsResult.java @@ -31,7 +31,7 @@ import java.io.File; /** * Created on 3/15/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ExtractRawDataAndResultsResult implements CoserResult { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/result/FileResult.java b/coser-business/src/main/java/fr/ifremer/coser/result/result/FileResult.java index 998c1a1..2005f8f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/result/FileResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/result/FileResult.java @@ -32,12 +32,12 @@ import java.io.InputStream; /** * A result with only one file. - * <p/> + * * A useful method is offered to obtain directly a {@link InputStream} from the result file ({@link #getInputStream()}). - * <p/> + * * Created on 3/4/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class FileResult implements CoserResult { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/result/MapResult.java b/coser-business/src/main/java/fr/ifremer/coser/result/result/MapResult.java index 20eb5c6..37154dc 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/result/MapResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/result/MapResult.java @@ -29,7 +29,7 @@ import java.util.Map; /** * Created on 3/12/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class MapResult implements CoserResult { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/result/VoidResult.java b/coser-business/src/main/java/fr/ifremer/coser/result/result/VoidResult.java index 4da8bcf..7c18437 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/result/VoidResult.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/result/VoidResult.java @@ -27,7 +27,7 @@ import fr.ifremer.coser.result.CoserResult; /** * Created on 3/12/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class VoidResult implements CoserResult { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/util/Charts.java b/coser-business/src/main/java/fr/ifremer/coser/result/util/Charts.java index 08b2927..2e50410 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/util/Charts.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/util/Charts.java @@ -49,18 +49,18 @@ import java.util.Map; /** * Useful methods to generate charts. - * <p/> + * * Created on 3/15/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class Charts { public File generateChartFile(String prefix, - JFreeChart chart, - int width, - int height) { + JFreeChart chart, + int width, + int height) { try { File file = File.createTempFile(prefix, ".png"); file.deleteOnExit(); diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/util/Extracts.java b/coser-business/src/main/java/fr/ifremer/coser/result/util/Extracts.java index e4fce07..c906c91 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/util/Extracts.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/util/Extracts.java @@ -22,7 +22,6 @@ package fr.ifremer.coser.result.util; * #L% */ -import com.google.common.collect.Maps; import fr.ifremer.coser.CoserTechnicalException; import fr.ifremer.coser.result.CoserRequestContext; import fr.ifremer.coser.result.result.ExtractRawDataAndResultsResult; @@ -39,13 +38,12 @@ import java.io.IOException; import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.Map; /** * Useful methods for extract commands. * Created on 3/15/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class Extracts { diff --git a/coser-business/src/main/java/fr/ifremer/coser/result/util/Reports.java b/coser-business/src/main/java/fr/ifremer/coser/result/util/Reports.java index 43fb51c..7640388 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/result/util/Reports.java +++ b/coser-business/src/main/java/fr/ifremer/coser/result/util/Reports.java @@ -75,10 +75,10 @@ import static org.nuiton.i18n.I18n.l; /** * For reports generation. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class Reports { @@ -431,7 +431,7 @@ public class Reports { // get content as w3c document String content = htmlContent.toString(); - content = content.replaceAll("&","&"); + content = content.replaceAll("&", "&"); Document document = CoserUtils.parseDocument(content); // render template output as pdf diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/ClientResultService.java b/coser-business/src/main/java/fr/ifremer/coser/services/ClientResultService.java index b5cbd87..b1ca348 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/ClientResultService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/ClientResultService.java @@ -70,10 +70,10 @@ import static org.nuiton.i18n.I18n.t; /** * Service to be used only by the ui client to extract and publish results. - * <p/> + * * Created on 3/17/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ClientResultService { @@ -96,7 +96,7 @@ public class ClientResultService { /** * Retourne tous les projets qui ont des résultats. - * <p/> + * * De la forme d'une liste de de path (à la tree path) : * ProjetName/SelectionName/ResultName * @@ -148,7 +148,7 @@ public class ClientResultService { /** * Upload user selected result to coser web front-end using common http * client. - * <p/> + * * TODO remove les 4 listes s'il y a mieux. * * @param selectedResults selected result (collection of project/selection/rsufiresult) diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java b/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java index d0850f8..4a872c3 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java @@ -22,26 +22,21 @@ package fr.ifremer.coser.services; -import java.util.ListIterator; -import java.util.UUID; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.command.Command; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ListIterator; +import java.util.UUID; /** * Command service. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CommandService { @@ -55,7 +50,7 @@ public class CommandService { /** * Generate new unique command UUID. - * + * * @return unique command uuid */ public String getUniqueCommandUUID() { @@ -64,11 +59,11 @@ public class CommandService { /** * Perform command on project. Save action on project history file. - * - * @param command command to perform - * @param project project + * + * @param command command to perform + * @param project project * @param container container - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void doAction(Command command, Project project, AbstractDataContainer container) throws CoserBusinessException { if (log.isDebugEnabled()) { @@ -87,25 +82,24 @@ public class CommandService { /** * Undo last command on container. * Undo all operation with same uuid of first action to undo. - * + * * Warning, this method doesn't fire historyCommands events. - * - * @param project project + * + * @param project project * @param container container - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void undoAction(Project project, AbstractDataContainer container) throws CoserBusinessException { ListIterator<Command> itCommand = container.getHistoryCommands().listIterator(container.getHistoryCommands().size()); - + String lastUUID = null; while (itCommand.hasPrevious()) { Command command = itCommand.previous(); - + if (lastUUID != null && !lastUUID.equals(command.getCommandUUID())) { break; - } - else { + } else { command.undoCommand(project, container); lastUUID = command.getCommandUUID(); itCommand.remove(); @@ -115,14 +109,14 @@ public class CommandService { /** * Undo specified command count on container. - * - * @param project project - * @param container container + * + * @param project project + * @param container container * @param commandsCount commands count to undo - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void undoAction(Project project, AbstractDataContainer container, int commandsCount) throws CoserBusinessException { - for (int i = 0; i < commandsCount ; i++) { + for (int i = 0; i < commandsCount; i++) { Command command = container.getHistoryCommands().get(container.getHistoryCommands().size() - 1); command.undoCommand(project, container); container.removeHistoryCommand(command); diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/CommonService.java b/coser-business/src/main/java/fr/ifremer/coser/services/CommonService.java index bd72ea9..6bb8ac7 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/CommonService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/CommonService.java @@ -22,7 +22,26 @@ package fr.ifremer.coser.services; -import static org.nuiton.i18n.I18n.t; +import au.com.bytecode.opencsv.CSVReader; +import au.com.bytecode.opencsv.CSVWriter; +import fr.ifremer.coser.CoserBusinessConfig; +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.data.AbstractDataEntity; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.data.Haul; +import fr.ifremer.coser.data.Length; +import fr.ifremer.coser.data.Strata; +import fr.ifremer.coser.storage.DataStorage; +import fr.ifremer.coser.storage.MemoryDataStorage; +import fr.ifremer.coser.util.ProgressMonitor; +import fr.ifremer.coser.util.ProgressReader; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.util.ArrayUtil; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -41,43 +60,18 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.nuiton.util.ArrayUtil; - -import au.com.bytecode.opencsv.CSVReader; -import au.com.bytecode.opencsv.CSVWriter; -import fr.ifremer.coser.CoserBusinessConfig; -import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserConstants; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.data.AbstractDataEntity; -import fr.ifremer.coser.data.Catch; -import fr.ifremer.coser.data.Haul; -import fr.ifremer.coser.data.Length; -import fr.ifremer.coser.data.Strata; -import fr.ifremer.coser.storage.DataStorage; -import fr.ifremer.coser.storage.MemoryDataStorage; -import fr.ifremer.coser.util.ProgressMonitor; -import fr.ifremer.coser.util.ProgressReader; +import static org.nuiton.i18n.I18n.t; /** * Common methods used by others services only. - * + * * <ul> * <li>csv import/export</li> * <li>file name management</li> * <li>utilities methods</li> * </ul> - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CommonService { @@ -89,10 +83,10 @@ public class CommonService { /** * Load file as csv. Check and affect data in project depending on category type. - * - * @param project project + * + * @param project project * @param category category - * @param file file to load + * @param file file to load * @return data storage with file content * @throws CoserBusinessException */ @@ -102,12 +96,12 @@ public class CommonService { /** * Load file as csv. Check and affect data in project depending on category type. - * - * @param project project + * + * @param project project * @param category category - * @param file file to load + * @param file file to load * @param progress progress monitor (can be null) - * @return data storage with file content + * @return data storage with file content * @throws CoserBusinessException */ public DataStorage loadCSVFile(Project project, Category category, File file, ProgressMonitor progress) throws CoserBusinessException { @@ -116,13 +110,13 @@ public class CommonService { /** * Load file as csv. Check and affect data in project depending on category type. - * - * @param project project - * @param category category - * @param file file to load - * @param progress progress monitor (can be null) + * + * @param project project + * @param category category + * @param file file to load + * @param progress progress monitor (can be null) * @param originalLoading dans le cas d'un reload, la colonne "line" est a prendre en compte - * pour les data (elle est absente dans les jeux de données originaux) + * pour les data (elle est absente dans les jeux de données originaux) * @return data storage with file content * @throws CoserBusinessException */ @@ -144,12 +138,12 @@ public class CommonService { String[] line = csvReader.readNext(); if (line == null || line.length <= 1) { throw new CoserBusinessException(t("Can't read file '%s'. Check CSV file separator", - file.getAbsolutePath())); + file.getAbsolutePath())); } else { if (originalLoading) { checkFileHeader(file, category, line); if (category.isDataCategory()) { - line = (String[])ArrayUtil.concat(new String[]{AbstractDataEntity.PROPERTY_LINE}, line); + line = (String[]) ArrayUtil.concat(new String[]{AbstractDataEntity.PROPERTY_LINE}, line); } } content.add(line); @@ -159,10 +153,10 @@ public class CommonService { // dans coser, la numérotation des lignes commence à 1 int lineIndex = 1; while ((line = csvReader.readNext()) != null) { - if (line.length>1) { + if (line.length > 1) { if (originalLoading && category.isDataCategory()) { // ajout de la colonne "line" en debut (seulement pour les data) - line = (String[])ArrayUtil.concat(new String[]{String.valueOf(lineIndex)}, line); + line = (String[]) ArrayUtil.concat(new String[]{String.valueOf(lineIndex)}, line); lineIndex++; } content.add(line); @@ -173,20 +167,20 @@ public class CommonService { } finally { IOUtils.closeQuietly(csvReader); } - + return content; } /** * Check csv file header names and order depending on file category. - * - * @param file file + * + * @param file file * @param category category - * @param line header line to ckeck - * @throws CoserBusinessException + * @param line header line to ckeck + * @throws CoserBusinessException */ protected void checkFileHeader(File file, Category category, String[] line) throws CoserBusinessException { - + String[] enHeaders = null; String[] frHeaders = null; @@ -218,63 +212,63 @@ public class CommonService { if (frHeaders != null) { if (!Arrays.equals(line, enHeaders) && !Arrays.equals(line, frHeaders)) { throw new CoserBusinessException(t("Wrong header detected in file %s. Found : %s, expected %s or %s", - file.getName(), - StringUtils.join(line, ", "), - StringUtils.join(frHeaders, ", "), - StringUtils.join(enHeaders, ", "))); + file.getName(), + StringUtils.join(line, ", "), + StringUtils.join(frHeaders, ", "), + StringUtils.join(enHeaders, ", "))); } } else { if (!Arrays.equals(line, enHeaders)) { throw new CoserBusinessException(t("Wrong header detected in file %s. Found : %s, expected %s", - file.getName(), - StringUtils.join(line, ", "), - StringUtils.join(enHeaders, ", "))); + file.getName(), + StringUtils.join(line, ", "), + StringUtils.join(enHeaders, ", "))); } } } /** * Get empty storage for category (filled with just header) - * - * @param project project + * + * @param project project * @param category category * @return initialized storage */ public DataStorage getEmptyStorage(Project project, Category category) { - + DataStorage dataStorage = new MemoryDataStorage(); switch (category) { - case CATCH: - dataStorage.add(Catch.EN_HEADERS); - break; - case HAUL: - dataStorage.add(Haul.EN_HEADERS); - break; - case LENGTH: - dataStorage.add(Length.EN_HEADERS); - break; - case STRATA: - dataStorage.add(Strata.EN_HEADERS); - break; + case CATCH: + dataStorage.add(Catch.EN_HEADERS); + break; + case HAUL: + dataStorage.add(Haul.EN_HEADERS); + break; + case LENGTH: + dataStorage.add(Length.EN_HEADERS); + break; + case STRATA: + dataStorage.add(Strata.EN_HEADERS); + break; } - + return dataStorage; } /** * Store project category data in specified file as csv. - * + * * @param content content to save - * @param file file to save to - * @throws CoserBusinessException + * @param file file to save to + * @throws CoserBusinessException */ public void storeData(DataStorage content, File file) throws CoserBusinessException { - + // save content CSVWriter csvWriter = null; try { Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), CoserConstants.CSV_FILE_ENCODING)); - + csvWriter = new CSVWriter(writer, CoserConstants.CSV_SEPARATOR_CHAR); Iterator<String[]> itContent = content.iterator(); while (itContent.hasNext()) { @@ -282,20 +276,18 @@ public class CommonService { } } catch (IOException ex) { throw new CoserBusinessException("Can't save data", ex); - } - finally { + } finally { IOUtils.closeQuietly(csvWriter); } } /** * Store data without quoting every columns with "" (r specific demand). - * - * @param content content to save - * @param file file to save to - * @param project project used only to get species output field (can be null) + * + * @param content content to save + * @param file file to save to + * @param project project used only to get species output field (can be null) * @param category category used to replace species output field if needed (can be null) - * * @throws CoserBusinessException * @deprecated since 1.4, prefer use of {@link #storeDataWhithoutQuote(DataStorage, Writer, Map, Category)} */ @@ -312,15 +304,14 @@ public class CommonService { IOUtils.closeQuietly(writer); } } - + /** * Store data without quoting every columns with "" (r specific demand). - * - * @param content content to save - * @param file file to save to - * @param project project used only to get species output field (can be null) + * + * @param content content to save + * @param file file to save to + * @param project project used only to get species output field (can be null) * @param category category used to replace species output field if needed (can be null) - * * @throws CoserBusinessException * @since 1.4 */ @@ -331,9 +322,9 @@ public class CommonService { Iterator<String[]> itContent = content.iterator(); while (itContent.hasNext()) { String[] contentDatas = itContent.next(); - + // start at 1 to not output "line" column - for (int i = 1 ; i < contentDatas.length ; i++) { + for (int i = 1; i < contentDatas.length; i++) { if (i != 1) { writer.write(CoserConstants.CSV_SEPARATOR_CHAR); @@ -344,7 +335,7 @@ public class CommonService { // for some category, need to swap species output field with // user preference (since 1.3) if ((category == Category.CATCH && i == Catch.INDEX_SPECIES) || - (category == Category.LENGTH && i == Length.INDEX_SPECIES)) { + (category == Category.LENGTH && i == Length.INDEX_SPECIES)) { // can not exists, stay unchanged if (refTaxSpecies.containsKey(contentData)) { contentData = refTaxSpecies.get(contentData); @@ -366,11 +357,11 @@ public class CommonService { /** * Lit le fichier demandé et sauve dans une map les lignes demandées. - * - * @param file file to read + * + * @param file file to read * @param lines lines to save content * @return saved content - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String[]> getOriginalFileContent(File file, Collection<String> lines) throws CoserBusinessException { Map<String, String[]> content = new HashMap<String, String[]>(); @@ -394,14 +385,12 @@ public class CommonService { } lineIndex++; } - } - catch (IOException ex) { + } catch (IOException ex) { throw new CoserBusinessException("Can't read file", ex); - } - finally { + } finally { IOUtils.closeQuietly(csvReader); } - + return content; } @@ -409,7 +398,7 @@ public class CommonService { * Charge un fichier csv (estcomind/estpopind ...) mais sans verification. * C'est a peu pret le meme code qu'au dessus, sauf que le storage est * simplement retourné et que les séparateurs ne sont pas les même. - * + * * @param file file to load * @return data storage with file content * @throws CoserBusinessException @@ -422,8 +411,8 @@ public class CommonService { * Charge un fichier csv (estcomind/estpopind ...) mais sans verification. * C'est a peu pret le meme code qu'au dessus, sauf que le storage est * simplement retourné et que les séparateurs ne sont pas les même. - * - * @param file file to load + * + * @param file file to load * @param separator separator to use to load file * @return data storage with file content * @throws CoserBusinessException @@ -443,24 +432,22 @@ public class CommonService { String[] line = csvReader.readNext(); if (line == null || line.length <= 1) { throw new CoserBusinessException(t("Can't read file '%s'. Check CSV file separator", - file.getAbsolutePath())); - } - else { + file.getAbsolutePath())); + } else { content.add(line); } while ((line = csvReader.readNext()) != null) { - if (line.length>1) { + if (line.length > 1) { content.add(line); } } } catch (IOException ex) { throw new CoserBusinessException("Can't read file", ex); - } - finally { + } finally { IOUtils.closeQuietly(csvReader); } - + return content; } @@ -468,10 +455,10 @@ public class CommonService { * Retourne le nom de stockage d'un fichier de données suivant la categories * de fichier demandé. Les fichiers sont stockés avec leurs noms originaux * (sauf les fichiers de réference) donc il n'est pas fixe. - * - * @param project project (containing originals file names) + * + * @param project project (containing originals file names) * @param category category to get file name - * @param suffix suffix to add into file name + * @param suffix suffix to add into file name * @return storage file name * @deprecated since 1.5, use now {@link Project#getDataStorageFileName(Category, String)} */ @@ -481,18 +468,18 @@ public class CommonService { String result = project.getDataStorageFileName(category, suffix); return result; } - + /** * Lit tout le fichier associé à la categorie demandé, mais ne retourne * que les données correspondant au numéro de lignes demandée. - * + * * Le contenu retourné ne contient pas le numéro de ligne. - * - * @param project project + * + * @param project project * @param category category - * @param lines lines to get content + * @param lines lines to get content * @return content for lines - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String[]> getOriginalContent(Project project, Category category, Collection<String> lines) throws CoserBusinessException { @@ -500,33 +487,33 @@ public class CommonService { if (CollectionUtils.isEmpty(lines)) { return new HashMap<String, String[]>(); } - + File projectsDirectory = config.getRSufiProjectsDirectory(); File projectDirectory = new File(projectsDirectory, project.getName()); File originalDirectory = new File(projectDirectory, CoserConstants.STORAGE_ORIGINAL_DIRECTORY); String storageFileName = getDataStorageFileName(project, category, null); File dataFile = new File(originalDirectory, storageFileName); - + Map<String, String[]> contents = getOriginalFileContent(dataFile, lines); - + return contents; } /** * Retourne le nom d'affichage d'une especes pour les rapports. - * + * * @param project project * @param species species code * @return species display name */ public String getReportDisplayName(Project project, String species) { String displayName = null; - + // load reftax in memory Iterator<String[]> reftax = project.getRefTaxSpecies().iterator(true); while (reftax.hasNext()) { String[] tuple = reftax.next(); - + // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String speciesCode = tuple[3]; if (speciesCode.equals(species)) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java b/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java index eb04dfd..86c8af6 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java @@ -22,29 +22,7 @@ package fr.ifremer.coser.services; -import static org.nuiton.i18n.I18n.t; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.FileManagerFactory; import com.opensymphony.xwork2.ValidationAwareSupport; import com.opensymphony.xwork2.config.Configuration; @@ -55,7 +33,6 @@ import com.opensymphony.xwork2.util.ValueStackFactory; import com.opensymphony.xwork2.validator.ActionValidatorManager; import com.opensymphony.xwork2.validator.DelegatingValidatorContext; import com.opensymphony.xwork2.validator.ValidationException; - import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserConstants.ValidationLevel; @@ -73,22 +50,38 @@ import fr.ifremer.coser.data.Length; import fr.ifremer.coser.data.Strata; import fr.ifremer.coser.storage.DataStorage; import fr.ifremer.coser.util.ProgressMonitor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.nuiton.i18n.I18n.t; /** * Validation service. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlService { private static final Log log = LogFactory.getLog(ControlService.class); protected CoserBusinessConfig config; - + protected ValidationAwareSupport validationSupport; protected DelegatingValidatorContext validationContext; @@ -102,7 +95,7 @@ public class ControlService { /** * Initialise le context xworks. - * + * * @param config configuration */ public ControlService(CoserBusinessConfig config) { @@ -131,8 +124,8 @@ public class ControlService { /** * Valide un seul bean, retourne la liste des erreurs trouvées. - * - * @param bean bean to validate + * + * @param bean bean to validate * @param category result errors category * @return error list */ @@ -142,7 +135,7 @@ public class ControlService { // obligatoire pour les appel dans les thread et swing EDT ActionContext.setContext(context); - for(ValidationLevel validationLevel : ValidationLevel.values()) { + for (ValidationLevel validationLevel : ValidationLevel.values()) { try { validator.validate(bean, validationLevel.getXWorkContext(), validationContext); @@ -177,8 +170,7 @@ public class ControlService { result.add(error); } } - } - finally { + } finally { // vidage par log level validationSupport.clearFieldErrors(); validationSupport.clearActionErrors(); @@ -189,8 +181,7 @@ public class ControlService { if (log.isErrorEnabled()) { log.error("Can't validate bean", ex); } - } - finally { + } finally { validationSupport.clearFieldErrors(); validationSupport.clearActionErrors(); } @@ -199,9 +190,9 @@ public class ControlService { /** * Valide toutes les données du projet. - * - * @param project project - * @param control control a valider + * + * @param project project + * @param control control a valider * @param progress progress monitor (can be null) * @return les erreurs de validation */ @@ -244,7 +235,7 @@ public class ControlService { if (diffCatchLengthErrors != null) { validationErrors.addAll(diffCatchLengthErrors); } - + // validation par croisement de fichiers List<ControlError> crossFileErrors = validationCrossFiles(project, control, progress); if (progress != null) { @@ -267,15 +258,15 @@ public class ControlService { /** * Valide une category entière d'un project. - * - * @param project project - * @param control control a valider + * + * @param project project + * @param control control a valider * @param category category a valider * @param progress progress monitor (can be null) * @return les erreurs de validation (not null) */ public List<ControlError> validateCategoryXWork(Project project, Control control, - Category category, ProgressMonitor progress) { + Category category, ProgressMonitor progress) { // instance des bean utilisé lors de la validation Catch beanCatch = new Catch(); @@ -286,18 +277,18 @@ public class ControlService { // get content depending on category DataStorage dataToCheck = null; switch (category) { - case CATCH: - dataToCheck = control.getCatch(); - break; - case HAUL: - dataToCheck = control.getHaul(); - break; - case LENGTH: - dataToCheck = control.getLength(); - break; - case STRATA: - dataToCheck = control.getStrata(); - break; + case CATCH: + dataToCheck = control.getCatch(); + break; + case HAUL: + dataToCheck = control.getHaul(); + break; + case LENGTH: + dataToCheck = control.getLength(); + break; + case STRATA: + dataToCheck = control.getStrata(); + break; } // update progress @@ -316,7 +307,7 @@ public class ControlService { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.xworks", t(category.getTranslationKey()), progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -326,27 +317,27 @@ public class ControlService { String[] line = itDataToCheck.next(); List<ControlError> errors = null; switch (category) { - case CATCH: - beanCatch.setData(line); - errors = validate(beanCatch, category); - break; - case HAUL: - beanHaul.setData(line); - errors = validate(beanHaul, category); - break; - case LENGTH: - beanLength.setData(line); - errors = validate(beanLength, category); - break; - case STRATA: - beanStrata.setData(line); - errors = validate(beanStrata, category); - break; + case CATCH: + beanCatch.setData(line); + errors = validate(beanCatch, category); + break; + case HAUL: + beanHaul.setData(line); + errors = validate(beanHaul, category); + break; + case LENGTH: + beanLength.setData(line); + errors = validate(beanLength, category); + break; + case STRATA: + beanStrata.setData(line); + errors = validate(beanStrata, category); + break; } if (errors != null) { validationErrors.addAll(errors); } - + // check for duplicated lines String lineNumber = line[AbstractDataEntity.INDEX_LINE]; String uniqueDataKey = getSignificantData(project, category, line); @@ -370,123 +361,122 @@ public class ControlService { } // add current line to error (after : important) error.addLineNumber(lineNumber); - + // small hack to slow down control by initializing cache // because ui will take a lot of time to do it // and user will wait to must time // real dummy call, but do not remove it dataToCheck.indexOf(lineNumber); // init cache - } - else { + } else { uniqueDataKeys.put(uniqueDataKey, lineNumber); } } - + return validationErrors; } /** * Retourne sous forme de clé la partie significative des données. * Donc sans le numéro de ligne suivant la catégorie. - * + * * Utilisé pour la detection des doublons. - * + * * CAPTURES * Vérifier l'unicité sur : "Campagne", "Annee", "Trait", "Espece" - * + * * STRATES * Vérifier l'unicité sur : "Campagne", "Strate" - * + * * TAILLES * Vérifier l'unicité sur : "Campagne", "Annee", "Trait", "Espece", "Sexe", "Maturite", "Longueur" - * + * * TRAITS * Vérifier l'unicité sur : "Campagne", "Annee", "Trait", "Mois" - * - * @param project project + * + * @param project project * @param category category - * @param data data + * @param data data * @return string key */ protected String getSignificantData(Project project, Category category, String[] data) { StringBuilder sb = new StringBuilder(); - for (int index = 0 ; index < data.length ; ++index) { + for (int index = 0; index < data.length; ++index) { // never count index line if (index != AbstractDataEntity.INDEX_LINE) { switch (category) { - case CATCH: - if (index == Catch.INDEX_SURVEY || index == Catch.INDEX_YEAR || index == Catch.INDEX_HAUL) { - sb.append(data[index]).append('|'); - } else if (index == Catch.INDEX_SPECIES) { - sb.append(project.getDisplaySpeciesText(data[index])).append('|'); - } - break; - case HAUL: - if (index == Haul.INDEX_SURVEY || index == Haul.INDEX_YEAR || index == Haul.INDEX_HAUL || index == Haul.INDEX_MONTH) { - sb.append(data[index]).append('|'); - } - break; - case LENGTH: - if (index == Length.INDEX_SURVEY || index == Length.INDEX_YEAR || index == Length.INDEX_HAUL || + case CATCH: + if (index == Catch.INDEX_SURVEY || index == Catch.INDEX_YEAR || index == Catch.INDEX_HAUL) { + sb.append(data[index]).append('|'); + } else if (index == Catch.INDEX_SPECIES) { + sb.append(project.getDisplaySpeciesText(data[index])).append('|'); + } + break; + case HAUL: + if (index == Haul.INDEX_SURVEY || index == Haul.INDEX_YEAR || index == Haul.INDEX_HAUL || index == Haul.INDEX_MONTH) { + sb.append(data[index]).append('|'); + } + break; + case LENGTH: + if (index == Length.INDEX_SURVEY || index == Length.INDEX_YEAR || index == Length.INDEX_HAUL || index == Length.INDEX_SEX || index == Length.INDEX_MATURITY || index == Length.INDEX_LENGTH) { - sb.append(data[index]).append('|'); - } else if (index == Length.INDEX_SPECIES) { - sb.append(project.getDisplaySpeciesText(data[index])).append('|'); - } - break; - case STRATA: - if (index == Strata.INDEX_SURVEY || index == Strata.INDEX_STRATUM) { - sb.append(data[index]).append('|'); - } - break; + sb.append(data[index]).append('|'); + } else if (index == Length.INDEX_SPECIES) { + sb.append(project.getDisplaySpeciesText(data[index])).append('|'); + } + break; + case STRATA: + if (index == Strata.INDEX_SURVEY || index == Strata.INDEX_STRATUM) { + sb.append(data[index]).append('|'); + } + break; } - + } } return sb.toString(); } - + /** * Effectue un calcul global, mais specific a chaque categorie. - * - * @param project project - * @param control control + * + * @param project project + * @param control control * @param category category * @param progress progress monitor * @return error list for category (can be {@code null}) */ protected List<ControlError> validateCategorySpecific(Project project, Control control, - Category category, ProgressMonitor progress) { + Category category, ProgressMonitor progress) { List<ControlError> validationErrors = null; switch (category) { - case CATCH: - validationErrors = validateCategorySpecificCatch(project, control, progress); - break; - case HAUL: - validationErrors = validateCategorySpecificHaul(project, control, progress); - break; - case LENGTH: - validationErrors = validateCategorySpecificLength(project, control, progress); - break; - case STRATA: - validationErrors = validateCategorySpecificStrata(project, control, progress); - break; + case CATCH: + validationErrors = validateCategorySpecificCatch(project, control, progress); + break; + case HAUL: + validationErrors = validateCategorySpecificHaul(project, control, progress); + break; + case LENGTH: + validationErrors = validateCategorySpecificLength(project, control, progress); + break; + case STRATA: + validationErrors = validateCategorySpecificStrata(project, control, progress); + break; } return validationErrors; } /** * Alerte si Somme(CAPTURES$Nombre par CAPTURES$Annee|Strate|Espece) < nobsmin. - * - * @param project project - * @param control control + * + * @param project project + * @param control control * @param progress progress monitor (can be null) * @return error list */ protected List<ControlError> validateCategorySpecificCatch(Project project, - Control control, ProgressMonitor progress) { + Control control, ProgressMonitor progress) { List<ControlError> validationErrors = new ArrayList<ControlError>(); @@ -509,7 +499,7 @@ public class ControlService { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.observation", t(Category.CATCH.getTranslationKey()), progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -517,7 +507,7 @@ public class ControlService { // compute key StringBuilder sb = new StringBuilder(); - for (int tupleIndex = 0 ; tupleIndex < tuple.length; ++tupleIndex) { + for (int tupleIndex = 0; tupleIndex < tuple.length; ++tupleIndex) { if (tupleIndex == Catch.INDEX_YEAR || tupleIndex == Catch.INDEX_HAUL) { sb.append(tuple[tupleIndex]).append(';'); } else if (tupleIndex == Catch.INDEX_SPECIES) { @@ -535,14 +525,12 @@ public class ControlService { Double oldValue = nombreForKey.get(key); Double newValue = oldValue + nombre; nombreForKey.put(key, newValue); - } - else { + } else { nombreForKey.put(key, nombre); // sauvegarde la premiere ligne qui correspond a un regroupement de clé firstLineForKey.put(key, lineNumber); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // par trop grave, normalement les données deviennent // valide au fil de la validation if (log.isWarnEnabled()) { @@ -550,13 +538,13 @@ public class ControlService { } } } - + // now look for invalid data for (Map.Entry<String, Double> sumObservation : nombreForKey.entrySet()) { String key = sumObservation.getKey(); Double value = sumObservation.getValue(); if (value < config.getControlNobsmin()) { - + String lineNumber = firstLineForKey.get(key); ControlError error = new ControlError(); @@ -575,18 +563,16 @@ public class ControlService { /** * Detecte des différences entre les nombres dans captures * et les nombres dans taille. - * - * @param project project - * @param control data container + * + * @param project project + * @param control data container * @param progress progress (can be null) - * + * @return errors * @see PublicationService#getCompareCatchLengthGraph(Project, AbstractDataContainer, Collection) for details * @see CoserBusinessConfig#getControlDiffCatchLength() for option - * - * @return errors */ protected List<? extends ControlError> validateDiffCatchLength(Project project, - Control control, ProgressMonitor progress) { + Control control, ProgressMonitor progress) { int total = control.getCatch().size() - 1 + control.getLength().size() - 1; if (progress != null) { @@ -595,20 +581,20 @@ public class ControlService { } List<SpeciesControlError> validationErrors = new ArrayList<SpeciesControlError>(); - + // data necessary for compute SortedSet<String> setYear = new TreeSet<String>(); Set<String> missingYearLengthSpecies = new HashSet<String>(); - + // look for data (data summed over catch) Map<String, Map<String, Double>> catchForSpeciesYears = new HashMap<String, Map<String, Double>>(); Iterator<String[]> itCatchData = control.getCatch().iterator(true); int lineIndex = 1; // skip header while (itCatchData.hasNext()) { - + // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.diffCatchLength", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -616,7 +602,7 @@ public class ControlService { String[] tuple = itCatchData.next(); String species = tuple[Catch.INDEX_SPECIES]; - + Map<String, Double> speciesCatchForYears = catchForSpeciesYears.get(species); if (speciesCatchForYears == null) { speciesCatchForYears = new HashMap<String, Double>(); @@ -628,31 +614,29 @@ public class ControlService { String nombreValue = tuple[Catch.INDEX_NUMBER]; try { Double nombreDouble = Double.valueOf(nombreValue); - + if (speciesCatchForYears.containsKey(year)) { Double oldValue = speciesCatchForYears.get(year); Double newValue = oldValue + nombreDouble; speciesCatchForYears.put(year, newValue); - } - else { + } else { speciesCatchForYears.put(year, nombreDouble); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse " + nombreValue + " as double"); } } } - + // look for data (data summed over length) Map<String, Map<String, Double>> lengthForSpeciesYears = new HashMap<String, Map<String, Double>>(); Iterator<String[]> itLengthData = control.getLength().iterator(true); while (itLengthData.hasNext()) { - + // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.diffCatchLength", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -672,29 +656,27 @@ public class ControlService { String nombreValue = tuple[Length.INDEX_NUMBER]; try { Double nombreDouble = Double.valueOf(nombreValue); - + if (speciesLengthForYears.containsKey(year)) { Double oldValue = speciesLengthForYears.get(year); Double newValue = oldValue + nombreDouble; speciesLengthForYears.put(year, newValue); - } - else { + } else { speciesLengthForYears.put(year, nombreDouble); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse " + nombreValue + " as double"); } } } - + // check for all species and years for (Map.Entry<String, Map<String, Double>> catchEntries : catchForSpeciesYears.entrySet()) { String species = catchEntries.getKey(); Map<String, Double> catchNumbers = catchEntries.getValue(); Map<String, Double> lengthNumbers = lengthForSpeciesYears.get(species); - + if (lengthNumbers == null) { // on suppose que cette erreur est détectée par un autre controle continue; @@ -703,7 +685,7 @@ public class ControlService { Iterator<String> itYears = setYear.iterator(); while (itYears.hasNext()) { String year = itYears.next(); - + Double catchNumber = catchNumbers.get(year); Double lengthNumber = lengthNumbers.get(year); if (catchNumber == null) { @@ -721,7 +703,7 @@ public class ControlService { error.setLevel(ValidationLevel.WARNING); error.setMessage(t("coser.business.control.error.diffCatchLengthMissingYear")); error.setDetailMessage(t("coser.business.control.error.diffCatchLengthMissingYearDetail", - project.getDisplaySpeciesText(species))); + project.getDisplaySpeciesText(species))); validationErrors.add(error); missingYearLengthSpecies.add(species); } else { @@ -731,14 +713,14 @@ public class ControlService { if (min > 0) { double max = Math.max(catchNumber, lengthNumber); double diff = (max - min) * 100 / max; - + if (diff > config.getControlDiffCatchLength()) { DiffCatchLengthControlError error = new DiffCatchLengthControlError(); error.setSpecies(species); error.setLevel(ValidationLevel.WARNING); error.setMessage(t("coser.business.control.error.diffCatchLength")); error.setDetailMessage(t("coser.business.control.error.diffCatchLengthDetail", - project.getDisplaySpeciesText(species), year)); + project.getDisplaySpeciesText(species), year)); validationErrors.add(error); } } @@ -753,23 +735,23 @@ public class ControlService { } /** - * Alerte si Somme(TAILLES$Nombre par TAILLES$Annee|Strate|Espece) < nobsmin - * + * Alerte si Somme(TAILLES$Nombre par TAILLES$Annee|Strate|Espece) < nobsmin + * * Warning sur les tailles aberrantes par espèce: * <ul> * <li>premiere passe pour calculer l'écart type et la moyenne par espèce * <li>seconde passe pour détecter les valeurs abérentes (> ecart type) * </ul> - * + * * L'ecart étant : racine( somme (x - moyenne)^2 / n) - * - * @param project project - * @param control control + * + * @param project project + * @param control control * @param progress progress (can be null) * @return error list */ protected List<ControlError> validateCategorySpecificLength(Project project, - Control control, ProgressMonitor progress) { + Control control, ProgressMonitor progress) { List<ControlError> validationErrors = new ArrayList<ControlError>(); int total = control.getLength().size() - 1; @@ -795,17 +777,17 @@ public class ControlService { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.observation", t(Category.LENGTH.getTranslationKey()), progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; } - + // compute key StringBuilder sb = new StringBuilder(); - for (int tupleIndex = 0 ; tupleIndex < tuple.length; ++tupleIndex) { + for (int tupleIndex = 0; tupleIndex < tuple.length; ++tupleIndex) { if (tupleIndex == Length.INDEX_YEAR || tupleIndex == Length.INDEX_HAUL || - tupleIndex == Length.INDEX_SPECIES) { + tupleIndex == Length.INDEX_SPECIES) { sb.append(tuple[tupleIndex]).append(';'); } } @@ -820,21 +802,19 @@ public class ControlService { Double oldValue = nombreForKey.get(key); Double newValue = oldValue + nombre; nombreForKey.put(key, newValue); - } - else { + } else { nombreForKey.put(key, nombre); // sauvegarde la premiere ligne qui correspond a un regroupement de clé firstLineForKey.put(key, lineNumber); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // par trop grave, normalement les données deviennent // valide au fil de la validation if (log.isWarnEnabled()) { log.warn("Can't parse " + nombreValue + " as double"); } } - + // store lenght for Standard deviation String lengthValue = tuple[Length.INDEX_LENGTH]; try { @@ -846,13 +826,11 @@ public class ControlService { lengthSumForSpecies.put(key, newValue); Double count = lengthCountForSpecies.get(key); lengthCountForSpecies.put(key, count + 1); - } - else { + } else { lengthSumForSpecies.put(key, nombre); lengthCountForSpecies.put(key, 1d); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // par trop grave, normalement les données deviennent // valide au fil de la validation if (log.isWarnEnabled()) { @@ -860,7 +838,7 @@ public class ControlService { } } } - + // now look for invalid data (observations) for (Map.Entry<String, Double> sumObservation : nombreForKey.entrySet()) { String key = sumObservation.getKey(); @@ -900,7 +878,7 @@ public class ControlService { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 50.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 50.0); progress.setText(t("coser.business.control.step.lengthdeviation", t(Category.LENGTH.getTranslationKey()), progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -913,17 +891,15 @@ public class ControlService { String key = tuple[Length.INDEX_SPECIES]; Double nombre = Double.valueOf(lengthValue); Double value = Math.pow(nombre - avgForSpecies.get(key), 2); - + if (varianceSumForSpecies.containsKey(key)) { Double oldValue = varianceSumForSpecies.get(key); Double newValue = oldValue + value; varianceSumForSpecies.put(key, newValue); - } - else { + } else { varianceSumForSpecies.put(key, value); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // par trop grave, normalement les données deviennent // valide au fil de la validation if (log.isWarnEnabled()) { @@ -931,7 +907,7 @@ public class ControlService { } } } - + // Standard deviation : calcul de l'ecart type par espèce // racine( somme (x - moyenne)^2 / n) Map<String, Double> deviationForSpecies = new HashMap<String, Double>(); @@ -939,15 +915,15 @@ public class ControlService { double avg = Math.sqrt(entry.getValue() / lengthCountForSpecies.get(entry.getKey())); deviationForSpecies.put(entry.getKey(), avg); } - + // Standard deviation : recherche des valeurs aberantes : 3 fois l'écart type itTuple = control.getLength().iterator(true); lineIndex = 1; // skip header while (itTuple.hasNext()) { - + // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 50.0 + 50.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 50.0 + 50.0); progress.setText(t("coser.business.control.step.lengthoutliers", t(Category.LENGTH.getTranslationKey()), progressPercent)); progress.setCurrent(total + lineIndex); ++lineIndex; @@ -976,11 +952,10 @@ public class ControlService { error.setSpecies(species); error.setMessage(t("coser.business.control.error.lengthOutliers", avg, deviation)); error.setDetailMessage(t("coser.business.control.error.lengthOutliersDetail", - project.getDisplaySpeciesText(species), avg, deviation, lengthValue)); + project.getDisplaySpeciesText(species), avg, deviation, lengthValue)); validationErrors.add(error); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // par trop grave, normalement les données deviennent // valide au fil de la validation if (log.isWarnEnabled()) { @@ -994,47 +969,47 @@ public class ControlService { /** * Specific validation for Haul category. - * + * * @param project - * @param control control + * @param control control * @param progress progress * @return {@code null} */ protected List<ControlError> validateCategorySpecificHaul(Project project, - Control control, ProgressMonitor progress) { + Control control, ProgressMonitor progress) { return null; } /** * Specific validation for Strata category. - * - * @param project project - * @param control control + * + * @param project project + * @param control control * @param progress progress * @return {@code null} */ protected List<ControlError> validateCategorySpecificStrata(Project project, - Control control, ProgressMonitor progress) { + Control control, ProgressMonitor progress) { return null; } - + /** * Validation par croisement de fichiers. - * + * * Les erreurs relevé ici porte sur plusieurs fichiers. - * + * * L'ordre de verification de cohérence est : * Strates > Traits > Captures > Taille - * - * @param control control + * + * @param control control * @param progress progress * @return error list */ protected List<ControlError> validationCrossFiles(Project project, Control control, - ProgressMonitor progress) { + ProgressMonitor progress) { int total = control.getCatch().size() + control.getHaul().size() - + control.getStrata().size() + control.getLength().size() - 4; + + control.getStrata().size() + control.getLength().size() - 4; if (progress != null) { progress.setText(t("coser.business.control.step.crossFileChech", 0)); progress.setTotal(total); @@ -1072,20 +1047,20 @@ public class ControlService { Map<String, Integer[]> specyTypes = new HashMap<String, Integer[]>(); // parcourt de toutes les données - while (itReftax.hasNext() ) { + while (itReftax.hasNext()) { String[] tuple = itReftax.next(); // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String speciesId = null; switch (project.getStorageSpeciesType()) { - case C_PERM: - speciesId = tuple[0]; - break; - case C_Valide: - speciesId = tuple[3]; - break; - case L_Valide: - speciesId = tuple[4]; - break; + case C_PERM: + speciesId = tuple[0]; + break; + case C_Valide: + speciesId = tuple[3]; + break; + case L_Valide: + speciesId = tuple[4]; + break; } Integer iNumSys = Integer.valueOf(tuple[1]); refTaxSpecies.put(speciesId, iNumSys); @@ -1109,7 +1084,7 @@ public class ControlService { while (itStrata.hasNext()) { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.crossFileChech", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -1124,7 +1099,7 @@ public class ControlService { while (itHaul.hasNext()) { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.crossFileChech", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -1143,7 +1118,7 @@ public class ControlService { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.crossFileChech", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -1154,7 +1129,7 @@ public class ControlService { surveyNames.add(catchData[Catch.INDEX_SURVEY]); catchYear.add(catchData[Catch.INDEX_YEAR]); catchYearHaulSpecies.add(catchData[Catch.INDEX_YEAR] + "|" + - catchData[Catch.INDEX_HAUL] + "|" + project.getDisplaySpeciesText(species)); + catchData[Catch.INDEX_HAUL] + "|" + project.getDisplaySpeciesText(species)); catchYearHaul.add(catchData[Catch.INDEX_YEAR] + "|" + catchData[Catch.INDEX_HAUL]); catchHaulNames.add(catchData[Catch.INDEX_HAUL]); catchSpeciesNames.add(species); @@ -1177,7 +1152,7 @@ public class ControlService { while (itLength.hasNext()) { // update progress if (progress != null) { - int progressPercent = (int)((double)lineIndex / (double)total * 100.0); + int progressPercent = (int) ((double) lineIndex / (double) total * 100.0); progress.setText(t("coser.business.control.step.crossFileChech", progressPercent)); progress.setCurrent(lineIndex); ++lineIndex; @@ -1188,7 +1163,7 @@ public class ControlService { surveyNames.add(lengthData[Length.INDEX_SURVEY]); lengthYear.add(lengthData[Length.INDEX_YEAR]); lengthYearHaulSpecies.add(lengthData[Length.INDEX_YEAR] + "|" + - lengthData[Length.INDEX_HAUL] + "|" + project.getDisplaySpeciesText(species)); + lengthData[Length.INDEX_HAUL] + "|" + project.getDisplaySpeciesText(species)); lengthYearHaul.add(lengthData[Length.INDEX_YEAR] + "|" + lengthData[Length.INDEX_HAUL]); lengthHaulNames.add(lengthData[Length.INDEX_HAUL]); lengthSpeciesNames.add(species); @@ -1204,9 +1179,7 @@ public class ControlService { error.setMessage(t("coser.business.control.error.nonExistantSpecies")); error.setDetailMessage(t("coser.business.control.error.nonExistantSpeciesDetail", lengthData[Length.INDEX_SPECIES])); crossFilesErrors.add(error); - } - - else { + } else { // ne doit être fait que si l'escepe existe // Contrôle sur le champ TAILLES$Longueur : @@ -1226,22 +1199,22 @@ public class ControlService { // et que la longueur n'est pas valide // alors c'est une erreur if (speciesType.equals(config.getControlTypeFish()) && - speciesNumSys >= bound[0] && speciesNumSys <= bound[1] && - !isValidFishLength(lengthData[Length.INDEX_LENGTH])) { + speciesNumSys >= bound[0] && speciesNumSys <= bound[1] && + !isValidFishLength(lengthData[Length.INDEX_LENGTH])) { ControlError error = new ControlError(); error.setCategory(Category.LENGTH); error.addLineNumber(lengthData[Length.INDEX_LINE]); error.setLevel(ValidationLevel.WARNING); error.setMessage(t("coser.business.control.error.invalidLengthLengthStep")); error.setDetailMessage(t("coser.business.control.error.invalidLengthLengthStepDetail", - lengthData[Length.INDEX_LENGTH], project.getDisplaySpeciesText(species))); + lengthData[Length.INDEX_LENGTH], project.getDisplaySpeciesText(species))); error.setTipMessage(t("coser.business.control.error.invalidLengthLengthStepTip")); crossFilesErrors.add(error); } } } } - + // Vérifier que les mêmes années sont présentes dans fichiers captures // traits et tailles: CAPTURES$Annee, TRAITS$Annee, TAILLES$Annee. if (!catchYear.equals(lengthYear) || !haulYear.equals(lengthYear)) { @@ -1325,7 +1298,7 @@ public class ControlService { error.setTipMessage(t("coser.business.control.error.missingHaulStrataFromStrataTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // traits de captures doivent etre dans traits de traits (fatal) @@ -1338,7 +1311,7 @@ public class ControlService { error.setTipMessage(t("coser.business.control.error.missingHaulHaulFromCatchTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // traits de traits doivent etre dans traits de captures (warning) @@ -1351,7 +1324,7 @@ public class ControlService { error.setTipMessage(t("coser.business.control.error.missingCatchHaulFromHaulTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // traits de tailles doivent etre dans traits de captures (fatal) @@ -1364,7 +1337,7 @@ public class ControlService { error.setTipMessage(t("coser.business.control.error.missingCatchHaulFromLengthTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // traits de captures doivent etre dans traits de tailles (warning) @@ -1377,7 +1350,7 @@ public class ControlService { error.setTipMessage(t("coser.business.control.error.missingLengthHaulFromCatchTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // especes de tailles doivent etre dans especes de captures (fatal) @@ -1388,11 +1361,11 @@ public class ControlService { error.setSpecies(missingCatchSpeciesName); error.setMessage(t("coser.business.control.error.missingCatchSpeciesFromLength")); error.setDetailMessage(t("coser.business.control.error.missingCatchSpeciesFromLengthDetail", - project.getDisplaySpeciesText(missingCatchSpeciesName))); + project.getDisplaySpeciesText(missingCatchSpeciesName))); error.setTipMessage(t("coser.business.control.error.missingCatchSpeciesFromLengthTip")); crossFilesErrors.add(error); } - + // Donc tout ce qui est présent dans TAILLES doit être décrit dans CAPTURES // qui doit être décrit dans TRAITS qui doit être décrit dans STRATES. // especes de captures doivent etre dans especes de tailles (warning) @@ -1403,7 +1376,7 @@ public class ControlService { error.setSpecies(missingLengthSpeciesName); error.setMessage(t("coser.business.control.error.missingLengthSpeciesFromCatch")); error.setDetailMessage(t("coser.business.control.error.missingLengthSpeciesFromCatchDetail", - project.getDisplaySpeciesText(missingLengthSpeciesName))); + project.getDisplaySpeciesText(missingLengthSpeciesName))); error.setTipMessage(t("coser.business.control.error.missingLengthSpeciesFromCatchTip")); crossFilesErrors.add(error); } @@ -1413,7 +1386,7 @@ public class ControlService { /** * Return {@code true} if given length is valid length (cm or half cm). - * + * * @param length lengthto test * @return {@code true} if given length is valid length (cm or half cm) */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java b/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java index 278af9e..b52f29f 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java @@ -22,8 +22,44 @@ package fr.ifremer.coser.services; -import static org.nuiton.i18n.I18n.t; -import static org.nuiton.i18n.I18n.n; +import fr.ifremer.coser.CoserBusinessConfig; +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserUtils; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.RSufiResult; +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.bean.SpeciesFieldType; +import fr.ifremer.coser.command.Command; +import fr.ifremer.coser.command.DeleteLineCommand; +import fr.ifremer.coser.command.MergeSpeciesCommand; +import fr.ifremer.coser.command.ModifyFieldCommand; +import fr.ifremer.coser.control.ControlError; +import fr.ifremer.coser.data.AbstractDataEntity; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.data.Haul; +import fr.ifremer.coser.data.Length; +import fr.ifremer.coser.data.Strata; +import fr.ifremer.coser.storage.DataStorage; +import fr.ifremer.coser.util.Coordinate; +import fr.ifremer.coser.util.ProgressMonitor; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.math.util.MathUtils; +import org.nuiton.math.matrix.DimensionHelper; +import org.nuiton.math.matrix.MatrixFactory; +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.MatrixProvider; import java.beans.Introspector; import java.io.BufferedOutputStream; @@ -55,57 +91,16 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Pattern; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.ListUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.math.util.MathUtils; -import org.nuiton.math.matrix.DimensionHelper; -import org.nuiton.math.matrix.MatrixFactory; -import org.nuiton.math.matrix.MatrixND; -import org.nuiton.math.matrix.MatrixProvider; - -import fr.ifremer.coser.CoserBusinessConfig; -import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserConstants; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.RSufiResult; -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.bean.SpeciesFieldType; -import fr.ifremer.coser.command.Command; -import fr.ifremer.coser.command.DeleteLineCommand; -import fr.ifremer.coser.command.MergeSpeciesCommand; -import fr.ifremer.coser.command.ModifyFieldCommand; -import fr.ifremer.coser.control.ControlError; -import fr.ifremer.coser.data.AbstractDataEntity; -import fr.ifremer.coser.data.Catch; -import fr.ifremer.coser.data.Haul; -import fr.ifremer.coser.data.Length; -import fr.ifremer.coser.data.Strata; -import fr.ifremer.coser.storage.DataStorage; -import fr.ifremer.coser.util.Coordinate; -import fr.ifremer.coser.util.ProgressMonitor; +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; /** * Service business method relative to project. - * + * * Interessant à savoir, l'ordre pour traiter les fichiers correctement est: * {@code Strates > Traits > Captures > Tailles} - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProjectService { @@ -128,7 +123,7 @@ public class ProjectService { /** * Return existing project name list sorted by project name. - * + * * @return projects list */ public List<String> getProjectNames() { @@ -143,7 +138,7 @@ public class ProjectService { } } } - + Collections.sort(result); return result; @@ -151,16 +146,16 @@ public class ProjectService { /** * Create new project. - * + * * Do (ordered): * - project existence test * - data loading * - data copying (after loading check) - * - * @param project project to create + * + * @param project project to create * @param categoriesAndFiles additional files to load - * @param maps maps file - * @param progress progress monitor (can be null) + * @param maps maps file + * @param progress progress monitor (can be null) * @return project with filled data * @throws CoserBusinessException if project can't be created */ @@ -169,7 +164,7 @@ public class ProjectService { if (!projectsDirectory.isDirectory()) { projectsDirectory.mkdirs(); } - + // check project existence String projectName = project.getName(); File projectDirectory = new File(projectsDirectory, projectName); @@ -192,7 +187,7 @@ public class ProjectService { } progress.setTotal(total); } - + Control control = new Control(); // load each files @@ -201,7 +196,7 @@ public class ProjectService { for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) { Category category = categoryAndFile.getKey(); File dataFile = categoryAndFile.getValue(); - + // test file existence if (!dataFile.exists()) { throw new CoserBusinessException(t("Can't read file %s for category %s", dataFile.getAbsolutePath(), t(category.getTranslationKey()))); @@ -236,10 +231,10 @@ public class ProjectService { File storageDataFile = new File(originalDirectory, storageFileName); FileUtils.copyFile(dataFile, storageDataFile); - // les fichiers autres (reftax) sont stockes a la base + // les fichiers autres (reftax) sont stockes a la base } else { File storageDataFile = new File(projectDirectory, - category.getStorageFileName()); + category.getStorageFileName()); FileUtils.copyFile(dataFile, storageDataFile); } } catch (IOException ex) { @@ -272,10 +267,10 @@ public class ProjectService { * Sauve seulement les informations concernant le projet et les cartes * si elle ont été modifiée par rapport à la liste des cartes actuellement * dans le projet. - * + * * @param project project - * @param maps maps - * @throws CoserBusinessException + * @param maps maps + * @throws CoserBusinessException */ public void saveProject(Project project, List<File> maps) throws CoserBusinessException { File projectsDirectory = config.getRSufiProjectsDirectory(); @@ -311,13 +306,13 @@ public class ProjectService { /** * Update project maps with new maps. - * + * * Théoriquement, si les deux listes sont identiques, cette methode ne fait rien. - * - * @param project project to update maps + * + * @param project project to update maps * @param projectDirectory project directory - * @param newMaps new maps to set - * @throws CoserBusinessException + * @param newMaps new maps to set + * @throws CoserBusinessException */ protected Project updateProjectMaps(Project project, File projectDirectory, List<File> newMaps) throws CoserBusinessException { @@ -327,7 +322,7 @@ public class ProjectService { if (currentMaps == null) { currentMaps = new ArrayList<File>(); } - + // bien faire attention aux instances de liste utilisées // le code n'est pas evident List<File> mapsList = new ArrayList<File>(currentMaps); @@ -368,12 +363,12 @@ public class ProjectService { /** * Open project without loading data. - * + * * Just load non category data (reftax). - * + * * @param projectName project name to open * @return loaded project with data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project openProject(String projectName) throws CoserBusinessException { return openProject(projectName, null); @@ -381,13 +376,13 @@ public class ProjectService { /** * Open project without loading data. - * + * * Just load non category data (reftax). - * - * @param projectName project name to open + * + * @param projectName project name to open * @param parentDirectory optional custom parent directory (for results) * @return loaded project with data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project openProject(String projectName, File parentDirectory) throws CoserBusinessException { @@ -406,13 +401,12 @@ public class ProjectService { // load only additional files if (!category.isDataCategory()) { File inputFile = new File(projectDirectory, - category.getStorageFileName()); - + category.getStorageFileName()); + if (inputFile.isFile()) { DataStorage dataStorage = commonService.loadCSVFile(project, category, inputFile); addProjectContent(project, null, category, dataStorage, false); - } - else { + } else { // si on arrive ici et qu'un fichier de reference // n'existe pas, c'est grave throw new CoserBusinessException(t("Missing file %s", inputFile)); @@ -523,10 +517,10 @@ public class ProjectService { /** * Load rsufi result in specified directory. - * + * * @param selectionDirectory selection directory * @return rsufi results list - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected List<RSufiResult> loadRSufiResults(File selectionDirectory) throws CoserBusinessException { @@ -540,11 +534,11 @@ public class ProjectService { RSufiResult rsufiResult = getRSufiResult(resultDirectory); rsufiResult.setName(resultDirectory.getName()); results.add(rsufiResult); - + // maps dir exists File mapsDir = new File(resultDirectory, CoserConstants.STORAGE_MAPS_DIRECTORY); rsufiResult.setMapsAvailable(mapsDir.isDirectory()); - + // other files dir File othersDir = new File(resultDirectory, CoserConstants.STORAGE_RESULT_FILES); List<File> otherFiles = new ArrayList<File>(); @@ -564,15 +558,15 @@ public class ProjectService { /** * Retourne un object {@code RSufiResult} initialise avec les données * du resultat du répertoire demandé. - * + * * @param resultDirectory result directory (base) * @return initialized RSufiResult - * @throws CoserBusinessException + * @throws CoserBusinessException */ public RSufiResult getRSufiResult(File resultDirectory) throws CoserBusinessException { RSufiResult rsufiResult = new RSufiResult(); rsufiResult.setName(resultDirectory.getName()); - + // relecture des informations du resultat (properties) File resultPropertiesFile = new File(resultDirectory, "result.properties"); InputStream inputStream = null; @@ -588,8 +582,7 @@ public class ProjectService { } } catch (IOException ex) { throw new CoserBusinessException("Can't read result properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(inputStream); } return rsufiResult; @@ -597,13 +590,13 @@ public class ProjectService { /** * Load control data in an initialized project. - * + * * @param project project * @return project with data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project loadControlData(Project project) throws CoserBusinessException { - + File projectsDirectory = config.getRSufiProjectsDirectory(); File projectDirectory = new File(projectsDirectory, project.getName()); @@ -626,21 +619,19 @@ public class ProjectService { DataStorage dataStorage = commonService.loadCSVFile(project, category, inputFile); addProjectContent(project, control, category, dataStorage, false); fileLoaded++; - } - else { + } else { if (log.isDebugEnabled()) { log.debug("Can't find file " + inputFile); } } - + // load deleted file if exists storageFileName = commonService.getDataStorageFileName(project, category, CoserConstants.STORAGE_DELECTED_SUFFIX); inputFile = new File(controlDirectory, storageFileName); DataStorage dataStorage = null; if (inputFile.isFile()) { dataStorage = commonService.loadCSVFile(project, category, inputFile); - } - else { + } else { dataStorage = commonService.getEmptyStorage(project, category); if (log.isDebugEnabled()) { log.debug("Can't find file " + inputFile); @@ -654,7 +645,7 @@ public class ProjectService { if (fileLoaded == 0) { File originalDirectory = new File(projectDirectory, CoserConstants.STORAGE_ORIGINAL_DIRECTORY); for (Category category : Category.values()) { - + if (category.isDataCategory()) { String storageFileName = commonService.getDataStorageFileName(project, category, null); File storageDataFile = new File(originalDirectory, storageFileName); @@ -663,13 +654,12 @@ public class ProjectService { if (storageDataFile.isFile()) { DataStorage dataStorage = commonService.loadCSVFile(project, category, storageDataFile, null, true); addProjectContent(project, control, category, dataStorage, false); - } - else { + } else { // si on arrive ici et qu'un fichier original // n'existe pas, c'est grave throw new CoserBusinessException(t("Missing file %s", storageDataFile)); } - + // deleted data DataStorage dataStorage = commonService.getEmptyStorage(project, category); addProjectContent(project, control, category, dataStorage, true); @@ -695,26 +685,24 @@ public class ProjectService { } } catch (IOException ex) { throw new CoserBusinessException("Can't read control properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(inputStream); } - } - else { + } else { // FIX future NPE control.setHistoryCommands(new ArrayList<Command>()); } - + return project; } /** * Load selection data in an initialized project. - * - * @param project project + * + * @param project project * @param selection selection to fill * @return project with data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project loadSelectionData(Project project, Selection selection) throws CoserBusinessException { return loadSelectionData(config.getRSufiProjectsDirectory(), project, selection); @@ -722,12 +710,12 @@ public class ProjectService { /** * Load selection data in an initialized project form specific directory. - * + * * @param projectsDirectory directory containing projects - * @param project project - * @param selection selection to fill + * @param project project + * @param selection selection to fill * @return project with data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project loadSelectionData(File projectsDirectory, Project project, Selection selection) throws CoserBusinessException { @@ -750,13 +738,12 @@ public class ProjectService { if (inputFile.isFile()) { DataStorage dataStorage = commonService.loadCSVFile(project, category, inputFile); addProjectContent(project, selection, category, dataStorage, false); - } - else { + } else { throw new CoserBusinessException(t("Missing file %s", inputFile)); } } } - + // relecture des commandes de la selection (properties) File selectionPropertiesFile = new File(selectionDirectory, selectionName + ".selection"); InputStream inputStream = null; @@ -774,8 +761,7 @@ public class ProjectService { } } catch (IOException ex) { throw new CoserBusinessException("Can't read selection properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(inputStream); } @@ -784,17 +770,17 @@ public class ProjectService { /** * Enregistre les fichiers de données apres validation. - * + * * @param project project to save - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void saveProjectControl(Project project) throws CoserBusinessException { - + // tout ce qui suit doit exister à ce stade File projectsDirectory = config.getRSufiProjectsDirectory(); String projectName = project.getName(); File projectDirectory = new File(projectsDirectory, projectName); - + Control control = project.getControl(); // creation du dossier de control (il peut deja exister) @@ -802,7 +788,7 @@ public class ProjectService { controlDirectory.mkdirs(); for (Category category : Category.values()) { if (category.isDataCategory()) { - + // save main content String storageFileName = commonService.getDataStorageFileName(project, category, CoserConstants.STORAGE_CONTROL_SUFFIX); File controlFile = new File(controlDirectory, storageFileName); @@ -811,7 +797,7 @@ public class ProjectService { } DataStorage content = getProjectContent(project, control, category, false); commonService.storeData(content, controlFile); - + // save deleted content (if needed) DataStorage contentDeleted = getProjectContent(project, control, category, true); // if more content than header @@ -836,25 +822,24 @@ public class ProjectService { if (log.isDebugEnabled()) { log.debug("Saving control properties file : " + propertiesFile); } - + } catch (IOException ex) { throw new CoserBusinessException("Can't save control properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(outputStream); } } - + /** * Marque le controle comme valider et sauve le projet. - * + * * Genère également les PDF des rapports de contrôle. - * - * @param project project to save + * + * @param project project to save * @param validationErrors controls errors used to fill pdf * @throws CoserBusinessException - * @since 1.3 + * @since 1.3 */ public void validControl(Project project, List<ControlError> validationErrors) throws CoserBusinessException { @@ -871,12 +856,12 @@ public class ProjectService { File controlReportPdf = new File(controlDirectory, "control.pdf"); publicationService.extractControlLogAsPDF(project, control, validationErrors, controlReportPdf); } - + /** * Marque la selection comme validée et sauve le projet. - * + * * Genère également les PDF des rapports de selection. - * + * * @param project project to save * @throws CoserBusinessException * @since 1.3 @@ -900,10 +885,10 @@ public class ProjectService { /** * Creer une instance de selection "non sauvegardee" avec les données * de control (validée) du projet. - * + * * @param project project to create selection * @return selection - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Selection initProjectSelection(Project project) throws CoserBusinessException { @@ -936,14 +921,14 @@ public class ProjectService { /** * Initialise une nouvelle selection à partir des données de controle * et de la definition de la selection du fichier fournit. - * - * @param project project (containing data in control) + * + * @param project project (containing data in control) * @param selectionFile selection file * @return initialized selection - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Selection initProjectSelectionFromFile(Project project, File selectionFile) throws CoserBusinessException { - + Selection selection = initProjectSelection(project); selection.setName(null); //clear name (can't be used) @@ -957,11 +942,10 @@ public class ProjectService { selectionStream.close(); } catch (IOException ex) { throw new CoserBusinessException("Can't read selection properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(selectionStream); } - + // filter years filterDataYearsAndGetStrata(project, selection, selection.getSelectedYears()); // applying merges commands @@ -976,8 +960,8 @@ public class ProjectService { /** * Copy loaded control data to new created selection. - * - * @return selection initialized with + * + * @return selection initialized with */ protected Selection copyControlDataToSelection(Project project, Selection selection) { // create new selection @@ -1002,8 +986,8 @@ public class ProjectService { /** * Create and save project selection. - * - * @param project project to create selection + * + * @param project project to create selection * @param selection selection to create * @throws CoserBusinessException */ @@ -1018,11 +1002,10 @@ public class ProjectService { // creation du dossier de la selection courante File selectionDirectory = new File(selectionsDirectory, selection.getName()); - + if (selectionDirectory.isDirectory()) { throw new CoserBusinessException(t("Selection %s already exists", selection.getName())); - } - else { + } else { selectionDirectory.mkdirs(); saveProjectSelection(project, selection); project.addSelections(selection); @@ -1031,8 +1014,8 @@ public class ProjectService { /** * Save project selection. - * - * @param project project to save selection + * + * @param project project to save selection * @param selection selection to save * @throws CoserBusinessException */ @@ -1080,11 +1063,10 @@ public class ProjectService { } } catch (IOException ex) { throw new CoserBusinessException("Can't save selection properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(outputStream); } - + // fichier en plus (demande client) // quand la selection est validé (le fichier list espece (4 listes) if (selection.isValidated()) { @@ -1092,20 +1074,20 @@ public class ProjectService { fillListSpeciesFile(selection, listSpeciesFile); } } - + /** * Create new rsufi result list in directory structure. - * + * * RSufiResult is added to selection result list by this method. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param rsufiResult new result to save * @param othersFiles others files and directory - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void saveRsufiResults(Project project, Selection selection, - RSufiResult rsufiResult, List<File> othersFiles) throws CoserBusinessException { + RSufiResult rsufiResult, List<File> othersFiles) throws CoserBusinessException { File projectsDirectory = config.getRSufiProjectsDirectory(); File projectDirectory = new File(projectsDirectory, project.getName()); @@ -1181,11 +1163,11 @@ public class ProjectService { /** * Save existing rsufi result. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param rsufiResult new result to save - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void editRsufiResults(Project project, Selection selection, RSufiResult rsufiResult, List<File> othersFile) throws CoserBusinessException { @@ -1200,7 +1182,7 @@ public class ProjectService { // property file try { saveRSufiResult(rsufiResultDirectory, rsufiResult); - + // remove some files Collection<File> toDeletes = CollectionUtils.subtract(rsufiResult.getOtherFiles(), othersFile); for (File toDelete : toDeletes) { @@ -1237,17 +1219,17 @@ public class ProjectService { /** * Save rsufi result (only properties file). - * + * * @param rsufiResultDirectory rsufiresult directory - * @param rsufiResult rsufi result - * @throws CoserBusinessException + * @param rsufiResult rsufi result + * @throws CoserBusinessException */ public void saveRSufiResult(File rsufiResultDirectory, RSufiResult rsufiResult) throws CoserBusinessException { OutputStream outputStream = null; try { // sauvegarde des informations du resultat (properties) - File propertiesFile = new File(rsufiResultDirectory,"result.properties"); + File propertiesFile = new File(rsufiResultDirectory, "result.properties"); Properties props = rsufiResult.toProperties(); outputStream = new FileOutputStream(propertiesFile); props.store(outputStream, null); @@ -1264,9 +1246,9 @@ public class ProjectService { /** * Delete a rsufi result. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param rsufiResult rsufi result to delete * @throws CoserBusinessException * @since 1.3 @@ -1287,7 +1269,7 @@ public class ProjectService { results.remove(rsufiResult); // this way to fire change event (do not remove) selection.setRsufiResults(results); - + // s'il n'y a plus de résultat, suppprimer le dossier // result File[] resultFiles = resultsDirectory.listFiles(); @@ -1301,14 +1283,14 @@ public class ProjectService { /** * Sauve une liste ordonnées de commande dans le fichier specifié. - * - * @param props proparties to add command to + * + * @param props proparties to add command to * @param historyCommand command list to save * @param propertyPrefix property prefix - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected void addHistoryCommandsToProperties(Properties props, List<Command> historyCommand, - String propertyPrefix) throws CoserBusinessException { + String propertyPrefix) throws CoserBusinessException { int commandIndex = 0; for (Command command : historyCommand) { @@ -1321,11 +1303,11 @@ public class ProjectService { /** * Load history command list from file. - * - * @param props properties to parse + * + * @param props properties to parse * @param propertyPrefix property prefix * @return command list (never null) - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected List<Command> getHistoryCommandsFromProperties(Properties props, final String propertyPrefix) throws CoserBusinessException { List<Command> historyCommand = new ArrayList<Command>(); @@ -1333,6 +1315,7 @@ public class ProjectService { // take care of property name order List<String> propertiesNames = new ArrayList<String>(props.stringPropertyNames()); Collections.sort(propertiesNames, new Comparator<String>() { + @Override public int compare(String o1, String o2) { int result = -1; @@ -1341,21 +1324,19 @@ public class ProjectService { int int1 = Integer.parseInt(o1.substring(propertyPrefix.length() + 1)); int int2 = Integer.parseInt(o2.substring(propertyPrefix.length() + 1)); result = int1 - int2; - } - else { + } else { result = o1.compareTo(o2); } - } - else { + } else { result = o1.compareTo(o2); } return result; } - + }); for (String propertyName : propertiesNames) { - + if (propertyName.startsWith(propertyPrefix + ".")) { String commandAsString = props.getProperty(propertyName); Command command = convertLineToCommand(commandAsString); @@ -1368,10 +1349,10 @@ public class ProjectService { /** * Convert a command to string info - * + * * @param command command to convert * @return string command - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected String convertCommandToLine(Command command) { @@ -1381,16 +1362,16 @@ public class ProjectService { args.add(command.getComment() == null ? "" : command.getComment()); args.add(command.toStringRepresentation()); String result = CoserUtils.convertBracketString(args); - + return result; } /** * Convert a string line to parameterized command. - * + * * @param line line to convert * @return command - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Command convertLineToCommand(String line) throws CoserBusinessException { @@ -1410,132 +1391,124 @@ public class ProjectService { } try { - result = (Command)Class.forName(commandFQN).newInstance(); + result = (Command) Class.forName(commandFQN).newInstance(); result.setCommandUUID(commandUUID); result.setComment(commandComment); result.fromStringRepresentation(commandArgs); } catch (Exception ex) { throw new CoserBusinessException("Can't init command intance", ex); } - + return result; } /** * Set content into project depending on category type. - * - * @param project project - * @param category category - * @param content content to set + * + * @param project project + * @param category category + * @param content content to set * @param deletedContent if content means deleted objects for {@code category} */ protected void addProjectContent(Project project, AbstractDataContainer container, - Category category, DataStorage content, boolean deletedContent) { - + Category category, DataStorage content, boolean deletedContent) { + switch (category) { - case CATCH: - if (!deletedContent) { - container.setCatch(content); - } - else { - container.setDeletedCatch(content); - } - break; - case HAUL: - if (!deletedContent) { - container.setHaul(content); - } - else { - container.setDeletedHaul(content); - } - break; - case LENGTH: - if (!deletedContent) { - container.setLength(content); - } - else { - container.setDeletedLength(content); - } - break; - case STRATA: - if (!deletedContent) { - container.setStrata(content); - } - else { - container.setDeletedStrata(content); - } - break; - case REFTAX_SPECIES: - project.setRefTaxSpecies(content); - break; - case TYPE_ESPECES: - project.setTypeEspeces(content); - break; + case CATCH: + if (!deletedContent) { + container.setCatch(content); + } else { + container.setDeletedCatch(content); + } + break; + case HAUL: + if (!deletedContent) { + container.setHaul(content); + } else { + container.setDeletedHaul(content); + } + break; + case LENGTH: + if (!deletedContent) { + container.setLength(content); + } else { + container.setDeletedLength(content); + } + break; + case STRATA: + if (!deletedContent) { + container.setStrata(content); + } else { + container.setDeletedStrata(content); + } + break; + case REFTAX_SPECIES: + project.setRefTaxSpecies(content); + break; + case TYPE_ESPECES: + project.setTypeEspeces(content); + break; } } /** * Set content into project depending on category type. - * - * @param project project - * @param container data container - * @param category category + * + * @param project project + * @param container data container + * @param category category * @param deletedContent if content means deleted objects for {@code category} */ protected DataStorage getProjectContent(Project project, AbstractDataContainer container, - Category category, boolean deletedContent) { - + Category category, boolean deletedContent) { + DataStorage content = null; - + switch (category) { - case CATCH: - if (!deletedContent) { - content = container.getCatch(); - } - else { - content = container.getDeletedCatch(); - } - break; - case HAUL: - if (!deletedContent) { - content = container.getHaul(); - } - else { - content = container.getDeletedHaul(); - } - break; - case LENGTH: - if (!deletedContent) { - content = container.getLength(); - } - else { - content = container.getDeletedLength(); - } - break; - case STRATA: - if (!deletedContent) { - content = container.getStrata(); - } - else { - content = container.getDeletedStrata(); - } - break; + case CATCH: + if (!deletedContent) { + content = container.getCatch(); + } else { + content = container.getDeletedCatch(); + } + break; + case HAUL: + if (!deletedContent) { + content = container.getHaul(); + } else { + content = container.getDeletedHaul(); + } + break; + case LENGTH: + if (!deletedContent) { + content = container.getLength(); + } else { + content = container.getDeletedLength(); + } + break; + case STRATA: + if (!deletedContent) { + content = container.getStrata(); + } else { + content = container.getDeletedStrata(); + } + break; } - + return content; } /** * Supprime une données via son index. - * + * * Used in control ui. - * - * @param project project - * @param control control - * @param category category - * @param index index to delete + * + * @param project project + * @param control control + * @param category category + * @param index index to delete * @param commandUUID command UUID - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void deleteData(Project project, Control control, Category category, String index, String commandUUID) throws CoserBusinessException { @@ -1549,14 +1522,14 @@ public class ProjectService { /** * Supprime une données via son index. - * + * * Used in control ui. - * - * @param project project - * @param control control + * + * @param project project + * @param control control * @param category category - * @param index index to delete - * @throws CoserBusinessException + * @param index index to delete + * @throws CoserBusinessException */ public void deleteData(Project project, Control control, Category category, String index) throws CoserBusinessException { deleteData(project, control, category, index, null); @@ -1564,40 +1537,40 @@ public class ProjectService { /** * Replace une valeur d'un champs si nécéssaire. - * + * * If {@code currentValue} is not equals to current data value for fieldName, * no replacement is performed. - * - * @param project project - * @param category category - * @param headerName headerName - * @param searchString current value + * + * @param project project + * @param category category + * @param headerName headerName + * @param searchString current value * @param replaceString new value - * @param data current data - * @param isRegex is regex - * @param commandUUID commandUUID + * @param data current data + * @param isRegex is regex + * @param commandUUID commandUUID * @return modification flag - * @throws CoserBusinessException + * @throws CoserBusinessException */ public boolean replaceFieldValue(Project project, Category category, String headerName, - String searchString, String replaceString, String[] data, boolean isRegex, String commandUUID) throws CoserBusinessException { + String searchString, String replaceString, String[] data, boolean isRegex, String commandUUID) throws CoserBusinessException { boolean result = false; AbstractDataEntity beanData = null; switch (category) { - case CATCH: - beanData = new Catch(); - break; - case HAUL: - beanData = new Haul(); - break; - case LENGTH: - beanData = new Length(); - break; - case STRATA: - beanData = new Strata(); - break; + case CATCH: + beanData = new Catch(); + break; + case HAUL: + beanData = new Haul(); + break; + case LENGTH: + beanData = new Length(); + break; + case STRATA: + beanData = new Strata(); + break; } beanData.setData(data); @@ -1605,7 +1578,7 @@ public class ProjectService { try { String fieldName = Introspector.decapitalize(headerName); String stringFieldProperty = fieldName + "AsString"; - String currentValue = (String)PropertyUtils.getProperty(beanData, stringFieldProperty); + String currentValue = (String) PropertyUtils.getProperty(beanData, stringFieldProperty); String escapeSearchString = searchString; if (!isRegex) { @@ -1625,61 +1598,61 @@ public class ProjectService { command.setCategory(category); commandService.doAction(command, project, project.getControl()); - + result = true; } } catch (Exception ex) { throw new CoserBusinessException("Can't replace inner field value", ex); } - + return result; } /** * Replace all bean data. Compare current and new value, and build command * for each diff. - * - * @param project project - * @param control control - * @param category category - * @param data new data to set - * @throws CoserBusinessException + * + * @param project project + * @param control control + * @param category category + * @param data new data to set + * @throws CoserBusinessException */ public void replaceData(Project project, Control control, Category category, String[] data) throws CoserBusinessException { - + // build bean for current and new data String lineNumber = data[AbstractDataEntity.INDEX_LINE]; int lineIndex = -1; AbstractDataEntity currentBeanData = null; AbstractDataEntity newBeanData = null; switch (category) { - case CATCH: - currentBeanData = new Catch(); - newBeanData = new Catch(); - lineIndex = control.getCatch().indexOf(lineNumber); - currentBeanData.setData(control.getCatch().get(lineIndex)); - break; - case HAUL: - currentBeanData = new Haul(); - newBeanData = new Haul(); - lineIndex = control.getHaul().indexOf(lineNumber); - currentBeanData.setData(control.getHaul().get(lineIndex)); - break; - case LENGTH: - currentBeanData = new Length(); - newBeanData = new Length(); - lineIndex = control.getLength().indexOf(lineNumber); - currentBeanData.setData(control.getLength().get(lineIndex)); - break; - case STRATA: - currentBeanData = new Strata(); - newBeanData = new Strata(); - lineIndex = control.getStrata().indexOf(lineNumber); - currentBeanData.setData(control.getStrata().get(lineIndex)); - break; + case CATCH: + currentBeanData = new Catch(); + newBeanData = new Catch(); + lineIndex = control.getCatch().indexOf(lineNumber); + currentBeanData.setData(control.getCatch().get(lineIndex)); + break; + case HAUL: + currentBeanData = new Haul(); + newBeanData = new Haul(); + lineIndex = control.getHaul().indexOf(lineNumber); + currentBeanData.setData(control.getHaul().get(lineIndex)); + break; + case LENGTH: + currentBeanData = new Length(); + newBeanData = new Length(); + lineIndex = control.getLength().indexOf(lineNumber); + currentBeanData.setData(control.getLength().get(lineIndex)); + break; + case STRATA: + currentBeanData = new Strata(); + newBeanData = new Strata(); + lineIndex = control.getStrata().indexOf(lineNumber); + currentBeanData.setData(control.getStrata().get(lineIndex)); + break; } newBeanData.setData(data); - + String commandUUID = commandService.getUniqueCommandUUID(); // inspect beans @@ -1687,9 +1660,9 @@ public class ProjectService { String propertyName = Introspector.decapitalize(propertyHeader); String stringFieldProperty = propertyName + "AsString"; try { - String currentValue = (String)PropertyUtils.getProperty(currentBeanData, stringFieldProperty); - String newValue = (String)PropertyUtils.getProperty(newBeanData, stringFieldProperty); - + String currentValue = (String) PropertyUtils.getProperty(currentBeanData, stringFieldProperty); + String newValue = (String) PropertyUtils.getProperty(newBeanData, stringFieldProperty); + if (!currentValue.equals(newValue)) { ModifyFieldCommand command = new ModifyFieldCommand(); command.setCommandUUID(commandUUID); @@ -1698,7 +1671,7 @@ public class ProjectService { command.setCurrentValue(currentValue); command.setNewValue(newValue); command.setCategory(category); - + commandService.doAction(command, project, control); } } catch (Exception ex) { @@ -1709,14 +1682,14 @@ public class ProjectService { /** * Recharge les données de control et les copies dans la selection. - * + * * Utilisé lors d'un rechargement utilisateur, ou lors de la mise à jour * des années. - * - * @param project project + * + * @param project project * @param selection selection to copy data to * @return project - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project loadControlDataToSelection(Project project, Selection selection) throws CoserBusinessException { Project newProject = loadControlData(project); @@ -1726,12 +1699,12 @@ public class ProjectService { /** * Find all defined year in model. - * + * * Le parcours est fait sur le fichier "haul", c'est potentiellement * le plus petit. - * + * * Used in selection ui. - * + * * @param selection selection to search into * @return year list */ @@ -1753,17 +1726,17 @@ public class ProjectService { /** * Filter data on selected years and return resulting strata name sorted * by names. - * + * * This methods set {@link Selection#setSelectedYears(List)}, and use * it to known if control data need to be reloaded (don't set it yourself). - * + * * Used in selection ui. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param selectedYears selected years * @return zones - * @throws CoserBusinessException + * @throws CoserBusinessException */ public List<String> filterDataYearsAndGetStrata(Project project, Selection selection, List<String> selectedYears) throws CoserBusinessException { @@ -1785,8 +1758,7 @@ public class ProjectService { if (!selectedYears.contains(year)) { itHaul.remove(); - } - else { + } else { String strates = tupleHaul[Haul.INDEX_STRATUM]; if (!result.contains(strates)) { result.add(strates); @@ -1797,7 +1769,7 @@ public class ProjectService { if (log.isDebugEnabled()) { log.debug("Haul data filtered by " + selectedYears); } - + // manage catch Iterator<String[]> itCatch = selection.getCatch().iterator(true); while (itCatch.hasNext()) { @@ -1808,11 +1780,11 @@ public class ProjectService { itCatch.remove(); } } - + if (log.isDebugEnabled()) { log.debug("Catch data filtered by " + selectedYears); } - + // manage length Iterator<String[]> itLength = selection.getLength().iterator(true); while (itLength.hasNext()) { @@ -1823,7 +1795,7 @@ public class ProjectService { itLength.remove(); } } - + if (log.isDebugEnabled()) { log.debug("Length data filtered by " + selectedYears); } @@ -1839,16 +1811,16 @@ public class ProjectService { /** * Update data to remove non selected strata. - * + * * Attention, les identifiants des traits sont année/traits * Le traits tout seul serait dupliquée. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param selectedStrata selected strata */ public void filterDataStrata(Project project, Selection selection, List<String> selectedStrata) { - + Collection<String> existentYearsHauls = new HashSet<String>(); // manage strata file @@ -1870,8 +1842,7 @@ public class ProjectService { if (!selectedStrata.contains(stratum)) { itHaul.remove(); - } - else { + } else { // sauvegarde les traits qui existent encore // apres la suppression des strates String year = tupleHaul[Haul.INDEX_YEAR]; @@ -1903,7 +1874,7 @@ public class ProjectService { itLength.remove(); } } - + // only place to do it selection.setSelectedStrata(selectedStrata); } @@ -1911,7 +1882,7 @@ public class ProjectService { /** * Retourne la liste des type d'especes definie dans le projet sous forme * de map avec leur commentaire (sauf "Tous"). - * + * * @param project project to search into * @return project species type */ @@ -1923,12 +1894,12 @@ public class ProjectService { Iterator<String[]> itTuples = project.getTypeEspeces().iterator(true); while (itTuples.hasNext()) { String[] tuple = itTuples.next(); - + String type = tuple[0]; String comment = tuple[1]; String numSysMin = tuple[2]; String numSysMax = tuple[3]; - + // pour le cas "Tous", min est max sont a 0, donc pas filtrable if (!numSysMin.equals(numSysMax)) { types.put(type, comment); @@ -1937,12 +1908,12 @@ public class ProjectService { return types; } - + /** * Update data to remove non selected species. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param selectedSpecies selected species */ public void filterDataSpecies(Project project, Selection selection, List<String> selectedSpecies) { @@ -1972,10 +1943,10 @@ public class ProjectService { // only place to do it selection.setSelectedSpecies(selectedSpecies); } - + /** * Touve toutes les especes qui ont des tailles pour toutes les années. - * + * * @param selection selection to search into * @return year list */ @@ -1989,7 +1960,7 @@ public class ProjectService { String year = tuple[Haul.INDEX_YEAR]; years.add(year); } - + // get all species with years Map<String, Set<String>> yearsForSpecies = new HashMap<String, Set<String>>(); Iterator<String[]> itLength = selection.getLength().iterator(true); @@ -2005,7 +1976,7 @@ public class ProjectService { } speciesYears.add(annee); } - + // on retire toutes les especes qui n'ont pas des années // completes List<String> completeSpecies = new ArrayList<String>(); @@ -2017,25 +1988,25 @@ public class ProjectService { return completeSpecies; } - + /** * Recherche les especes qui ont au moins une maturité sur l'ensemble des * données. - * + * * @param selection selection to search into * @return year list */ public Collection<String> getSpeciesWithMaturity(Selection selection) { Set<String> speciesWithMaturity = new HashSet<String>(); - + // get all species with years Iterator<String[]> itLength = selection.getLength().iterator(true); while (itLength.hasNext()) { String[] tupleLength = itLength.next(); String species = tupleLength[Length.INDEX_SPECIES]; String maturity = tupleLength[Length.INDEX_MATURITY]; - + if ("m".equalsIgnoreCase(maturity)) { speciesWithMaturity.add(species); } @@ -2046,18 +2017,18 @@ public class ProjectService { /** * Get species name in project with data in [{@code beginYear}-{@code endYear}]. - * + * * Used in selection ui. - * + * * Cette liste est issue du fichier captures (petit fichier, mais suffisant). - * + * * Les especes sont determinées : - * - en lisant les traits pour determiner les traits à partir des zones - * - en lisant les captures pour determiner les especes à partir des traits - * - en filtrant la liste des especes - * - * @param container data container - * @param project project (can be {@code null}, no filtering) + * - en lisant les traits pour determiner les traits à partir des zones + * - en lisant les captures pour determiner les especes à partir des traits + * - en filtrant la liste des especes + * + * @param container data container + * @param project project (can be {@code null}, no filtering) * @param filterSpecyType filterSpecyType (can be {@code null}, no filtering) * @return species */ @@ -2085,22 +2056,22 @@ public class ProjectService { // "C_Perm";"NumSys";"NivSys";"C_VALIDE";"L_VALIDE";"AA_VALIDE";"C_TxPère";"Taxa" String[] tuple = refTaxIterator.next(); Integer iNumSys = Integer.valueOf(tuple[1]); - + String specyId = null; switch (project.getStorageSpeciesType()) { - case C_PERM: - specyId = tuple[0]; - break; - case C_Valide: - specyId = tuple[3]; - break; - case L_Valide: - specyId = tuple[4]; - break; + case C_PERM: + specyId = tuple[0]; + break; + case C_Valide: + specyId = tuple[3]; + break; + case L_Valide: + specyId = tuple[4]; + break; } speciesNumSys.put(specyId, iNumSys); } - + // load specy type map SpecyTypeName > [min, max] // iteration sur les type d'especes Map<String, Integer[]> mapType = new HashMap<String, Integer[]>(); @@ -2109,20 +2080,20 @@ public class ProjectService { // "Types";"Commentaire";"NumSys min";"NumSys max","Code" String[] tuple = itTypeSpecies.next(); String specyType = tuple[0]; - + if (filterSpecyType != null && filterSpecyType.contains(specyType)) { Integer iMinNumSys = Integer.valueOf(tuple[2]); Integer iMaxNumSys = Integer.valueOf(tuple[3]); mapType.put(specyType, new Integer[]{iMinNumSys, iMaxNumSys}); } } - + // iteration sur les especes trouvées Iterator<String> itSpecies = result.iterator(); while (itSpecies.hasNext()) { String specy = itSpecies.next(); Integer specyNumSys = speciesNumSys.get(specy); - + if (specyNumSys == null) { // ca ne peut pas arriver, ce cs est valider // par un control @@ -2132,17 +2103,17 @@ public class ProjectService { itSpecies.remove(); continue; } - + // test si le numsys est dans les bornes d'un // des type d'espece demandé boolean foundInFilter = false; for (Integer[] bornes : mapType.values()) { if (specyNumSys >= bornes[0] - && specyNumSys <= bornes[1]){ + && specyNumSys <= bornes[1]) { foundInFilter = true; } } - + if (!foundInFilter) { itSpecies.remove(); } @@ -2156,15 +2127,15 @@ public class ProjectService { /** * Test que le nom de la nouvelle espece existe dans le Reftax actuellement * utilisé par le projet. - * + * * Used in selection ui. - * - * @param project project (avec reftax) + * + * @param project project (avec reftax) * @param newSpeciesName species code to test * @return {@code true} if specy name exist */ public boolean isSpeciesNameExist(Project project, String newSpeciesName) { - + boolean result = false; Iterator<String[]> itTuple = project.getRefTaxSpecies().iterator(true); @@ -2173,15 +2144,15 @@ public class ProjectService { // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String specyCode = null; switch (project.getStorageSpeciesType()) { - case C_PERM: - specyCode = tuple[0]; - break; - case C_Valide: - specyCode = tuple[3]; - break; - case L_Valide: - specyCode = tuple[4]; - break; + case C_PERM: + specyCode = tuple[0]; + break; + case C_Valide: + specyCode = tuple[3]; + break; + case L_Valide: + specyCode = tuple[4]; + break; } if (specyCode.equals(newSpeciesName)) { result = true; @@ -2192,31 +2163,31 @@ public class ProjectService { /** * Fusion d'especes. - * + * * Used un selection ui. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param newSpeciesName new specy name (after merge) - * @param comment comment - * @param speciesNames species name to merge + * @param comment comment + * @param speciesNames species name to merge * @return project - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Project mergeSpecies(Project project, Selection selection, String newSpeciesName, String comment, String... speciesNames) throws CoserBusinessException { if (!isSpeciesNameExist(project, newSpeciesName)) { throw new CoserBusinessException(t("Species %s doesn't exist in referential", - project.getDisplaySpeciesText(newSpeciesName))); + project.getDisplaySpeciesText(newSpeciesName))); } // check if new species name is not present in current selection // species list (collision) List<String> selectionSpecies = getProjectSpecies(selection, project, null); if (selectionSpecies.contains(newSpeciesName) && - !ArrayUtils.contains(speciesNames, newSpeciesName)) { + !ArrayUtils.contains(speciesNames, newSpeciesName)) { throw new CoserBusinessException(t("Species %s already exists in current selection", - project.getDisplaySpeciesText(newSpeciesName))); + project.getDisplaySpeciesText(newSpeciesName))); } MergeSpeciesCommand command = new MergeSpeciesCommand(); @@ -2230,26 +2201,26 @@ public class ProjectService { /** * Effort d'échantillonnage: nombre de traits par strate par année. - * + * * lengthunique=function(x){length(unique(x))} # nombre d'éléments unique dans x - * - * haulcount=tapply(TRAITS$Trait,list(stratum=TRAITS$Strate,year=TRAITS$Anneer),FUN=lengthunique) + * + * haulcount=tapply(TRAITS$Trait,list(stratum=TRAITS$Strate,year=TRAITS$Anneer),FUN=lengthunique) * haulcount[is.na(haulcount)]=0 * total=apply(haulcount,2,sum) * haulcount=rbind(haulcount,total) * if(language==2) tab=cbind(Strate=dimnames(haulcount)[[1]],haulcount) * else tab=cbind(Stratum=dimnames(haulcount)[[1]],haulcount) - * + * * Can return {@code null} if there is not enought data to build matrix. - * - * @param project project + * + * @param project project * @param selection selection * @return sampling effort as matrix */ public MatrixND getSamplingEffort(Project project, Selection selection) { // map strate > "year,integer" - Map<String, Map<String, Double>> dynMatrix = new HashMap<String, Map<String,Double>>(); + Map<String, Map<String, Double>> dynMatrix = new HashMap<String, Map<String, Double>>(); Set<String> lineNames = new HashSet<String>(); Set<String> columns = new HashSet<String>(); @@ -2267,13 +2238,11 @@ public class ProjectService { haulCountForStrata = new HashMap<String, Double>(); haulCountForStrata.put(year, 1.0); dynMatrix.put(strata, haulCountForStrata); - } - else { + } else { Double haulCountForYear = haulCountForStrata.get(year); if (haulCountForYear == null) { haulCountForStrata.put(year, 1.0); - } - else { + } else { haulCountForYear++; haulCountForStrata.put(year, haulCountForYear); } @@ -2286,8 +2255,8 @@ public class ProjectService { if (!lineNames2.isEmpty() && !columnsNames2.isEmpty()) { Collections.sort(lineNames2); Collections.sort(columnsNames2); - matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.samplingeffort"), new List<?>[] { - lineNames2 , columnsNames2}); + matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.samplingeffort"), new List<?>[]{ + lineNames2, columnsNames2}); for (Map.Entry<String, Map<String, Double>> dynMatrixEntry : dynMatrix.entrySet()) { for (Map.Entry<String, Double> haulCountForYearEntry : dynMatrixEntry.getValue().entrySet()) { @@ -2301,27 +2270,27 @@ public class ProjectService { /** * Occurrence : pourcentage des traits dans lesquels une espèce est présentes - * + * * years=seq(min(CAPTURES$Annee), max(CAPTURES$Annee)) * nyears=length(years) * catch=CAPTURES[CAPTURES$Nombre>0,] #prendre seulement données positives * - * #compter nombre de traits par année où chaque espèce est présent + * #compter nombre de traits par année où chaque espèce est présent * occurence=tapply(catch$Trait,list(species=catch$Espece,year=catch$Annee),lengthunique) - * occurrence[is.na(occurence)]<-0 + * occurrence[is.na(occurence)]<-0 + * + * rapport.func=function(x,v) {return (x/v);} * - * rapport.func=function(x,v) {return (x/v);} - * * #diviser nombre de traits avec présence par nombre total de traits - * pct.occur=apply(occurence,1,rapport.func,v=haulcount)# haulcount de 1) - * pct.occur=t(round(pct.occur*100,2)) # multiplier par 100 et arrondir à 2 décimales + * pct.occur=apply(occurence,1,rapport.func,v=haulcount)# haulcount de 1) + * pct.occur=t(round(pct.occur*100,2)) # multiplier par 100 et arrondir à 2 décimales + * + * colnames(pct.occur)=colnames(haulcount) #affectation noms colonnes matrice + * rownames(pct.occur)=rownames(occur) #nom des espèces * - * colnames(pct.occur)=colnames(haulcount) #affectation noms colonnes matrice - * rownames(pct.occur)=rownames(occur) #nom des espèces - * * #calculerl l'occurrence moyenne à travers les années - * provi.oc=round(apply(pct.occur,1,mean),2) - * pct.occur=cbind(pct.occur,MeanOccurence=provi.oc) + * provi.oc=round(apply(pct.occur,1,mean),2) + * pct.occur=cbind(pct.occur,MeanOccurence=provi.oc) * * @param project * @param selection @@ -2351,8 +2320,7 @@ public class ProjectService { Set<String> hauls = new HashSet<String>(); hauls.add(haul); traitsCountPerYear.put(year, hauls); - } - else { + } else { traitCountPerYear.add(haul); } @@ -2364,15 +2332,13 @@ public class ProjectService { hauls.add(haul); haulCountForStrata.put(year, hauls); dynMatrix.put(species, haulCountForStrata); - } - else { + } else { Set<String> traitCountPerYear2 = haulCountForStrata.get(year); if (traitCountPerYear2 == null) { Set<String> hauls = new HashSet<String>(); hauls.add(haul); haulCountForStrata.put(year, hauls); - } - else { + } else { traitCountPerYear2.add(haul); } } @@ -2382,67 +2348,67 @@ public class ProjectService { Collections.sort(lineNames2); List<String> columnsNames2 = new ArrayList<String>(columns); Collections.sort(columnsNames2); - MatrixND matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.occurrence"), new List<?>[] { - lineNames2 , columnsNames2}); - + MatrixND matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.occurrence"), new List<?>[]{ + lineNames2, columnsNames2}); + for (Map.Entry<String, Map<String, Set<String>>> dynMatrixEntry : dynMatrix.entrySet()) { for (Map.Entry<String, Set<String>> haulCountForYearEntry : dynMatrixEntry.getValue().entrySet()) { - double occurence = (double)haulCountForYearEntry.getValue().size() / - (double) traitsCountPerYear.get(haulCountForYearEntry.getKey()).size(); + double occurence = (double) haulCountForYearEntry.getValue().size() / + (double) traitsCountPerYear.get(haulCountForYearEntry.getKey()).size(); occurence = MathUtils.round(occurence * 100.0, 2); - + matrix.setValue(dynMatrixEntry.getKey(), haulCountForYearEntry.getKey(), occurence); } } return matrix; - + } /** * Densité: nombre par km2 par espèce par année - * + * * years=sort(unique(TRAITS$Annee)) - * + * * #surface total pour toutes les strates * totsurface=sum(STRATES$Surface) - * - * #ordonner table STRATES par nom des strates + * + * #ordonner table STRATES par nom des strates * STRATES=STRATES[order(STRATES$Strate),] - * + * * #combiner les 3 tables de données dans une seule table tab * tab=merge(CAPTURES,STRATES,by.x=c("Annee","Trait"),by.y=c("Annee","Trait")) * tab=merge(tab,TRAITS, by.x=c("Annee","Trait"),by.y=c("Annee","Trait")) - * + * * species=sort(unique(CAPTURES$Espece)) - * + * * #calculer la densité moyenne par année par strate par espèce * densparstrate=tapply(tab$Nombre/tab$SurfaceBalayee,list(tab$Espece, tab$Annee, tab$Strate), mean) * densparstrate[is.na(densparstrate)]=0 # remplace NA par 0 - * + * * #surface par annee et strate et espèce * surfaceparstrate=tapply(tab$Surface, list(tab$Espece, tab$Annee, tab$Strate), unique) - * - * #multiplier la densité par la surface de la strate pour obtenir nombre par année-strate + * + * #multiplier la densité par la surface de la strate pour obtenir nombre par année-strate * nombreparstrate= surfaceparstrate* densparstrate - * + * * #sommer nombre sur strates par année pour chaque espèce et diviser par surface totale * densiteparannee=apply(nombreparstrate,c(1,2),sum)/totsurface - * + * * #densité moyenne pour la période * densitemoyenneespece=apply(densiteparanne,1,mean) - * - * @param project project + * + * @param project project * @param selection selection * @return density as matrix */ public MatrixND getDensity(Project project, Selection selection) { - + // map species > "year, all density as double" Map<String, Map<String, Map<String, Set<Double>>>> densityPerSpecyStrataYear = new HashMap<String, Map<String, Map<String, Set<Double>>>>(); Set<String> speciesList = new HashSet<String>(); Set<String> yearsList = new HashSet<String>(); - + // load map strataname > stratasurface Map<String, Double> startaAndSurface = new HashMap<String, Double>(); double totalSourface = 0; @@ -2455,14 +2421,13 @@ public class ProjectService { Double surface = Double.valueOf(stringSurface); totalSourface += surface; startaAndSurface.put(stataName, surface); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't convert surface '" + stringSurface + "' as double"); } } } - + // load map traitname > stratename Map<String, String> haulAndStratas = new HashMap<String, String>(); Map<String, Double> haulAndSweptSurface = new HashMap<String, Double>(); @@ -2473,13 +2438,12 @@ public class ProjectService { String haulKey = tuple[Haul.INDEX_YEAR] + ";" + haul; String strataName = tuple[Haul.INDEX_STRATUM]; haulAndStratas.put(haul, strataName); - + String sweptSurfaceAsString = tuple[Haul.INDEX_SWEPT_SURFACE]; try { Double sweptSurface = Double.valueOf(sweptSurfaceAsString); haulAndSweptSurface.put(haulKey, sweptSurface); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't convert swept surface '" + sweptSurfaceAsString + "' as double"); } @@ -2489,7 +2453,7 @@ public class ProjectService { // on conserve egalement les surfaces associé a chaque species/year // pour post traiement Map<String, Double> surfacesParStrates = new HashMap<String, Double>(); - + // calcul de la densité Iterator<String[]> itData = selection.getCatch().iterator(true); while (itData.hasNext()) { @@ -2500,10 +2464,10 @@ public class ProjectService { String haul = tuple[Catch.INDEX_HAUL]; String numberAsString = tuple[Catch.INDEX_NUMBER]; String strata = haulAndStratas.get(haul); - + speciesList.add(species); yearsList.add(year); - + // compute density // densparstrate=tapply(tab$Nombre/tab$SurfaceBalayee,list(tab$Espece, tab$Annee, tab$Strate), mean) try { @@ -2515,8 +2479,7 @@ public class ProjectService { log.warn("Can't find swept surface for " + year + ";" + haul); } density = 0.0; - } - else { + } else { density = number / sweptSurface; } @@ -2530,8 +2493,7 @@ public class ProjectService { strataDensityPerYear.put(strata, densities); specyDensityPerStrataYear.put(year, strataDensityPerYear); densityPerSpecyStrataYear.put(species, specyDensityPerStrataYear); - } - else { + } else { Map<String, Set<Double>> strataDensityPerYear = specyDensityPerStrataYear.get(year); if (strataDensityPerYear == null) { strataDensityPerYear = new HashMap<String, Set<Double>>(); @@ -2545,8 +2507,7 @@ public class ProjectService { specyYearDensity = new HashSet<Double>(); specyYearDensity.add(density); strataDensityPerYear.put(strata, specyYearDensity); - } - else { + } else { specyYearDensity.add(density); } } @@ -2554,10 +2515,9 @@ public class ProjectService { // surfaceparstrate Double surface = startaAndSurface.get(strata); - + surfacesParStrates.put(species + ";" + year + ";" + strata, surface); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't convert number '" + numberAsString + "' as double"); } @@ -2569,9 +2529,9 @@ public class ProjectService { Collections.sort(sortedSpecies); List<String> sortedYears = new ArrayList<String>(yearsList); Collections.sort(sortedYears); - MatrixND matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.density"), new List<?>[] { - sortedSpecies , sortedYears}); - + MatrixND matrix = MatrixFactory.getInstance().create(n("coser.business.matrix.density"), new List<?>[]{ + sortedSpecies, sortedYears}); + for (Map.Entry<String, Map<String, Map<String, Set<Double>>>> dynMatrixEntry : densityPerSpecyStrataYear.entrySet()) { String specy = dynMatrixEntry.getKey(); for (Map.Entry<String, Map<String, Set<Double>>> haulCountForYearEntry : dynMatrixEntry.getValue().entrySet()) { @@ -2581,7 +2541,7 @@ public class ProjectService { // densiteparannee=apply(nombreparstrate,c(1,2),sum)/totsurface double totalNombreparstrate = 0; for (Map.Entry<String, Set<Double>> densityForYear : haulCountForYearEntry.getValue().entrySet()) { - + // maen density double totalDensity = 0; double densityCount = 0; @@ -2607,26 +2567,26 @@ public class ProjectService { matrix.setValue(specy, year, densiteparannee); } } - + return matrix; } - + /** * Présentation du graphique : histogramme de distribution en tailles par * espèce, par strate et par année (une planche par espèce et par année) * pour toute la série. Avec la possibilité de voir regroupé l'ensemble des * années. - * + * * Données. TAILLES$Nombres et TAILLES$Longueur * Calcul. Sommer TAILLES$Nombres par classe de longueur (TAILLES$Longueur) * sur tous les traits d'une année (ou tous les années si regroupé) - * + * * Seconde version : matrix proxy et provider. - * + * * Cette methode utilise directement les noms de visualisation des especes * au lieu de leurs codes (trop compliqué de faire un rendu basé sur le code). - * - * @param project project + * + * @param project project * @param dataContainer data container * @return matrix proxy with 4 dimension */ @@ -2677,8 +2637,7 @@ public class ProjectService { double length = Double.parseDouble(lengthAsString); length = getHalfStepValue(length); lengthSet.add(length); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse length as double : " + lengthAsString); } @@ -2700,13 +2659,13 @@ public class ProjectService { } MatrixND matrix = MatrixFactory.getInstance().createProxy(n("coser.business.matrix.lengthstructure"), - new List<?>[] { lengthSem , speciesSem, strataSem, yearsSem}, - new String[] {n("coser.business.common.length"), - n("coser.business.common.species"), - n("coser.business.common.strata"), - n("coser.business.common.years")}, - new LengthStructureMatrixProvider(project, dataContainer)); - + new List<?>[]{lengthSem, speciesSem, strataSem, yearsSem}, + new String[]{n("coser.business.common.length"), + n("coser.business.common.species"), + n("coser.business.common.strata"), + n("coser.business.common.years")}, + new LengthStructureMatrixProvider(project, dataContainer)); + return matrix; } @@ -2718,7 +2677,7 @@ public class ProjectService { protected Project project; protected AbstractDataContainer container; - + public LengthStructureMatrixProvider(Project project, AbstractDataContainer container) { this.project = project; this.container = container; @@ -2735,10 +2694,10 @@ public class ProjectService { /** * Length structure matrix provider filler part. - * - * @param project project + * + * @param project project * @param dataContainer data container - * @param matrix non proxy matrix to fill (inited with 0.0) + * @param matrix non proxy matrix to fill (inited with 0.0) */ public void fillLengthStructureMatrix(Project project, AbstractDataContainer dataContainer, MatrixND matrix) { @@ -2770,7 +2729,7 @@ public class ProjectService { } continue; } - + // quitte l'iteration courante si les dimensions demandée // ne sont pas dans la matrice reduite String speciesText = project.getDisplaySpeciesText(species); @@ -2801,14 +2760,12 @@ public class ProjectService { double currentNumber = matrix.getValue(dimHelper.get(length, speciesText, strata, year)); currentNumber += number; matrix.setValue(dimHelper.get(length, speciesText, strata, year), currentNumber); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse number as double : " + numberAsString); } } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse length as double : " + lengthAsString); } @@ -2818,11 +2775,11 @@ public class ProjectService { /** * Retourne la valeur au demi pas la plus proche. - * + * * 38.0 > 38.0 * 38.1 > 38.0 * 38.6 > 38.5 - * + * * @param value value to get hasl step * @return half step value */ @@ -2835,8 +2792,7 @@ public class ProjectService { // on prend le pas ou demi pas le plus proche if (floor == round) { value = floor; - } - else { + } else { value = floor + 0.5; } return value; @@ -2844,13 +2800,13 @@ public class ProjectService { /** * Extrait les données de la selection pour rSufi. - * - * @param project project - * @param selection selection - * @param directory directory to extract file to + * + * @param project project + * @param selection selection + * @param directory directory to extract file to * @param onlyDataTable extract only data table without additionnal information * @return extracted directory - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File extractRSUfiData(Project project, Selection selection, File directory, boolean onlyDataTable) throws CoserBusinessException { @@ -2892,7 +2848,7 @@ public class ProjectService { // date de creation du projet DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, config.getLocale()); - out.println(t("coser.business.extract.creationdate") + dateFormat.format(project.getCreationDate())); + out.println(t("coser.business.extract.creationdate") + dateFormat.format(project.getCreationDate())); // add selection additional files File projectsDirectory = config.getRSufiProjectsDirectory(); @@ -2910,21 +2866,20 @@ public class ProjectService { } catch (IOException ex) { throw new CoserBusinessException("Can't save project information file", ex); - } - finally { + } finally { IOUtils.closeQuietly(out); } } - + return exportDirectory; } /** * Ecrit le fichier ListEspeces.txt dans le fichier specifiés. - * + * * Est utilisé lors de l'extraction des données RSUfi et lors de * la sauvegarde d'une selection validée (demande client). - * + * * @param selection selection * @param ouputFile output file * @throws CoserBusinessException ection @@ -2939,10 +2894,10 @@ public class ProjectService { PrintStream out = null; try { out = new PrintStream(new BufferedOutputStream(new FileOutputStream(ouputFile))); - + // header out.println("Espece\tListAll\tListIdent\tListLong\tListMat"); - + for (String species : allSpecies) { String listIdent = occDensSpecies.contains(species) ? "1" : "0"; String listLong = sizeAllYearSpecies.contains(species) ? "1" : "0"; @@ -2951,8 +2906,7 @@ public class ProjectService { } } catch (FileNotFoundException ex) { throw new CoserBusinessException("Can't extract rsufi files", ex); - } - finally { + } finally { IOUtils.closeQuietly(out); } } @@ -2961,11 +2915,11 @@ public class ProjectService { * Look for project survey name in rsufi result. * Read estcomind file to known that. * Used in webservice to know map file names. - * + * * @param resultDirectory result directory - * @param rSufiResult rsufi result + * @param rSufiResult rsufi result * @return survey name - * @throws CoserBusinessException + * @throws CoserBusinessException */ public String getProjectSurveyName(File resultDirectory, RSufiResult rSufiResult) throws CoserBusinessException { String result = null; @@ -2979,14 +2933,14 @@ public class ProjectService { while (StringUtils.isEmpty(result) && itEstComIndData.hasNext()) { result = itEstComIndData.next()[0]; } - + return result; } /** * Get all strata's haul coordinates of given strata. - * - * @param selection project's selection + * + * @param selection project's selection * @param strataCollection starta collection to get haul * @return haul collection * @throws CoserBusinessException @@ -2995,7 +2949,7 @@ public class ProjectService { public List<Coordinate> getStrataHaulCoordinate(Selection selection, Collection<String> strataCollection) throws CoserBusinessException { List<Coordinate> hauls = new ArrayList<Coordinate>(); - + // serie cache to compute serie index List<String> serieCache = new ArrayList<String>(); @@ -3029,14 +2983,14 @@ public class ProjectService { hauls.add(coordinate); } } - + return hauls; } /** * Retourne une map de toutes les selections par projet dans le but de * selectionner une selection pour la rejouer dans l'ui. - * + * * @return all selections * @since 1.2 */ @@ -3078,8 +3032,8 @@ public class ProjectService { * Open selection (without opening associated project) without associated * data (just properties info). * Selection history commands are loaded too (for replay). - * - * @param projectName project containing selection + * + * @param projectName project containing selection * @param selectionName selection name to open in project * @return opened selection * @throws CoserBusinessException @@ -3117,8 +3071,7 @@ public class ProjectService { } } catch (IOException ex) { throw new CoserBusinessException("Can't read selection properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(inputStream); } return selection; @@ -3129,7 +3082,7 @@ public class ProjectService { * en parametres. * Fait attention a ne pas conserver dans les listes des especes qui * ne sont pas dans la liste L1 (liste de toutes les especes). - * + * * @param selection * @param selectedSpeciesOccDens * @param selectedSpeciesSizeAllYear @@ -3137,15 +3090,15 @@ public class ProjectService { * @since 1.2 */ public void fillListsSelection(Selection selection, List<String> selectedSpeciesOccDens, - List<String> selectedSpeciesSizeAllYear, List<String> selectedSpeciesMaturity) { - + List<String> selectedSpeciesSizeAllYear, List<String> selectedSpeciesMaturity) { + List<String> allSpecies = selection.getSelectedSpecies(); - + // filters species that doesn't exists anymore List<String> localSpeciesOccDens = ListUtils.retainAll(selectedSpeciesOccDens, allSpecies); List<String> localSpeciesSizeAllYear = ListUtils.retainAll(selectedSpeciesSizeAllYear, allSpecies); List<String> localSpeciesMaturity = ListUtils.retainAll(selectedSpeciesMaturity, allSpecies); - + // save lists selection.setSelectedSpeciesOccDens(localSpeciesOccDens); selection.setSelectedSpeciesSizeAllYear(localSpeciesSizeAllYear); @@ -3158,12 +3111,12 @@ public class ProjectService { * a renseigner dans le projet. * La map est triée sur le "VALEUR" et non sur la clé (pour la visualisation * soit triée suivant la représentation de l'utilisateur). - * + * * Les données sont issues du reftax. - * - * @param project le projet pour avoir accès au reftax + * + * @param project le projet pour avoir accès au reftax * @param outputField meme algorithm, mais renvoi une map de correspondance - * pour le champ de sortie + * pour le champ de sortie * @since 1.3 */ public LinkedHashMap<String, String> getReftaxSpeciesDisplayFieldMap(Project project, boolean outputField) { @@ -3177,43 +3130,43 @@ public class ProjectService { String value = null; switch (project.getStorageSpeciesType()) { - case C_Valide: - key = tuple[3]; - break; - case C_PERM: - key = tuple[0]; - break; - case L_Valide: - key = tuple[4]; - break; + case C_Valide: + key = tuple[3]; + break; + case C_PERM: + key = tuple[0]; + break; + case L_Valide: + key = tuple[4]; + break; } - SpeciesFieldType valueField = outputField ? project.getOutputSpeciesType(): - project.getDisplaySpeciesType(); + SpeciesFieldType valueField = outputField ? project.getOutputSpeciesType() : + project.getDisplaySpeciesType(); switch (valueField) { - case C_Valide: - value = tuple[3]; - break; - case C_PERM: - value = tuple[0]; - break; - case L_Valide: - value = tuple[4]; - break; + case C_Valide: + value = tuple[3]; + break; + case C_PERM: + value = tuple[0]; + break; + case L_Valide: + value = tuple[4]; + break; } - + speciesMap.put(key, value); } - + return CoserUtils.sortByValue(speciesMap); } /** * Save existing rsufi result. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param rsufiResult new result to save * @throws CoserBusinessException * @since 1.4 diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java b/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java index a2b44dd..d36f6a9 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java @@ -22,31 +22,27 @@ package fr.ifremer.coser.services; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Color; -import java.awt.Shape; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.StringWriter; -import java.io.Writer; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - +import com.itextpdf.text.DocumentException; +import fr.ifremer.coser.CoserBusinessConfig; +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserUtils; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.RSufiResult; +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.command.CategoryLineCommand; +import fr.ifremer.coser.command.Command; +import fr.ifremer.coser.control.ControlError; +import fr.ifremer.coser.control.ControlErrorGroup; +import fr.ifremer.coser.control.DiffCatchLengthControlError; +import fr.ifremer.coser.control.SpeciesControlError; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.data.Length; +import fr.ifremer.coser.storage.DataStorage; +import fr.ifremer.coser.storage.MemoryDataStorage; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.keyvalue.MultiKey; import org.apache.commons.collections4.map.MultiKeyMap; @@ -75,37 +71,35 @@ import org.nuiton.util.FileUtil; import org.w3c.dom.Document; import org.xhtmlrenderer.pdf.ITextRenderer; -import com.itextpdf.text.DocumentException; +import java.awt.Color; +import java.awt.Shape; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; -import fr.ifremer.coser.CoserBusinessConfig; -import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserConstants; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.RSufiResult; -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.command.CategoryLineCommand; -import fr.ifremer.coser.command.Command; -import fr.ifremer.coser.control.ControlError; -import fr.ifremer.coser.control.ControlErrorGroup; -import fr.ifremer.coser.control.DiffCatchLengthControlError; -import fr.ifremer.coser.control.SpeciesControlError; -import fr.ifremer.coser.data.Catch; -import fr.ifremer.coser.data.Length; -import fr.ifremer.coser.storage.DataStorage; -import fr.ifremer.coser.storage.MemoryDataStorage; +import static org.nuiton.i18n.I18n.t; /** * Publication service (charts, reports, export, pdf...) - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class PublicationService { @@ -123,9 +117,9 @@ public class PublicationService { /** * Retourne les graphiques de comparaison entre le nombre de capture et * le nombre dans les tailles pour toutes les especes. - * - * @param project project - * @param container data container + * + * @param project project + * @param container data container * @param speciesCollection utilisé pour n'avoir qu'une partie des especes (can be null) * @return chart */ @@ -140,7 +134,7 @@ public class PublicationService { while (itCatchData.hasNext()) { String[] tuple = itCatchData.next(); String species = tuple[Catch.INDEX_SPECIES]; - + Map<String, Double> speciesCatchForYears = catchForSpeciesYears.get(species); if (speciesCatchForYears == null) { speciesCatchForYears = new HashMap<String, Double>(); @@ -152,8 +146,7 @@ public class PublicationService { int intYear = Integer.parseInt(year); minYear = Math.min(minYear, intYear); maxYear = Math.max(maxYear, intYear); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse " + year + "as int"); } @@ -161,23 +154,21 @@ public class PublicationService { String nombreValue = tuple[Catch.INDEX_NUMBER]; try { Double nombreDouble = Double.valueOf(nombreValue); - + if (speciesCatchForYears.containsKey(year)) { Double oldValue = speciesCatchForYears.get(year); Double newValue = oldValue + nombreDouble; speciesCatchForYears.put(year, newValue); - } - else { + } else { speciesCatchForYears.put(year, nombreDouble); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse " + nombreValue + " as double"); } } } - + // look for data (data summed over length) Map<String, Map<String, Double>> lengthForSpeciesYears = new HashMap<String, Map<String, Double>>(); Iterator<String[]> itLengthData = container.getLength().iterator(true); @@ -195,17 +186,15 @@ public class PublicationService { String nombreValue = tuple[Length.INDEX_NUMBER]; try { Double nombreDouble = Double.valueOf(nombreValue); - + if (speciesLengthForYears.containsKey(year)) { Double oldValue = speciesLengthForYears.get(year); Double newValue = oldValue + nombreDouble; speciesLengthForYears.put(year, newValue); - } - else { + } else { speciesLengthForYears.put(year, nombreDouble); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse " + nombreValue + " as double"); } @@ -222,22 +211,22 @@ public class PublicationService { if (speciesCollection != null && !speciesCollection.contains(species)) { continue; } - + Map<String, Double> catchNumbers = catchEntries.getValue(); Map<String, Double> lengthNumbers = lengthForSpeciesYears.get(species); - - + + //SortedMap<String, Double> catchForYears = new TreeMap<String, Double>(); //SortedMap<String, Double> lengthForYears = new TreeMap<String, Double>(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - for (int year = minYear ; year <= maxYear ; ++year) { + for (int year = minYear; year <= maxYear; ++year) { Double catchNumber = catchNumbers.get(String.valueOf(year)); - + // laisse les abscents de captures apparentes //if (catchNumber == null) { // catchNumber = 0.0; //} - dataset.setValue(catchNumber, t(Category.CATCH.getTranslationKey()), (Integer)year); + dataset.setValue(catchNumber, t(Category.CATCH.getTranslationKey()), (Integer) year); if (lengthNumbers != null) { Double lengthNumber = lengthNumbers.get(String.valueOf(year)); @@ -245,12 +234,12 @@ public class PublicationService { //if (lengthNumber == null) { // lengthNumber = 0.0; //} - dataset.setValue(lengthNumber, t(Category.LENGTH.getTranslationKey()), (Integer)year); + dataset.setValue(lengthNumber, t(Category.LENGTH.getTranslationKey()), (Integer) year); } } JFreeChart chart = displayGraph(dataset, t("coser.business.chart.compareCatchLengthNumberTitle", - project.getDisplaySpeciesText(species))); + project.getDisplaySpeciesText(species))); charts.put(species, chart); } @@ -267,18 +256,18 @@ public class PublicationService { valueAxis.setUpperMargin(0.1); CategoryItemRenderer renderer = new LineAndShapeRenderer(); - + // agrandit la 2eme serie Shape firstShape = ShapeUtilities.createDiamond(5F); renderer.setSeriesShape(0, firstShape); - + CategoryToolTipGenerator cttg = new StandardCategoryToolTipGenerator("{0}: {2}", NumberFormat.getInstance()); renderer.setBaseToolTipGenerator(cttg); CategoryPlot plot = new CategoryPlot(categoryDataSet, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, - JFreeChart.DEFAULT_TITLE_FONT, plot, true); + JFreeChart.DEFAULT_TITLE_FONT, plot, true); return chart; } @@ -286,19 +275,19 @@ public class PublicationService { /** * Export la liste d'erreurs dans un fichier html avec la liste des graphes * si necessaire. - * + * * Genere les graphes en fin de fichier avec des liens html pour voir les * graphes depuis les erreurs. - * - * @param project project - * @param container data container + * + * @param project project + * @param container data container * @param validationErrors errors list * @return export html file - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File exportErrorsAsHTML(Project project, AbstractDataContainer container, - List<ControlError> validationErrors) throws CoserBusinessException { - + List<ControlError> validationErrors) throws CoserBusinessException { + File exportHtmlFile = null; Writer out = null; try { @@ -318,31 +307,31 @@ public class PublicationService { } return exportHtmlFile; } - + /** * Export la liste d'erreurs dans un fichier html avec la liste des graphes * si necessaire. - * + * * Genere les graphes en fin de fichier avec des liens html pour voir les * graphes depuis les erreurs. - * - * @param project project - * @param container data container - * @param validationErrors errors list + * + * @param project project + * @param container data container + * @param validationErrors errors list * @param includeProjectInfo add project info to generate persistant pdf * @return export html file - * @throws CoserBusinessException - * @throws IOException + * @throws CoserBusinessException + * @throws IOException */ protected void exportErrorsAsHTML(Project project, AbstractDataContainer container, - List<ControlError> validationErrors, Writer out, boolean includeProjectInfo) throws CoserBusinessException, IOException { + List<ControlError> validationErrors, Writer out, boolean includeProjectInfo) throws CoserBusinessException, IOException { List<String> speciesGraph = new ArrayList<String>(); File imageDirectory = FileUtil.createTempDirectory("coser-images-", "-tmp"); imageDirectory.deleteOnExit(); out.write("<html><head>"); - out.write("<title>" + t("coser.business.publication.errorexporttitle", project.getName())+ "</title>"); + out.write("<title>" + t("coser.business.publication.errorexporttitle", project.getName()) + "</title>"); out.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"); out.write("</head><body>"); @@ -366,12 +355,12 @@ public class PublicationService { } if (validationError instanceof SpeciesControlError) { - SpeciesControlError diffError = (SpeciesControlError)validationError; + SpeciesControlError diffError = (SpeciesControlError) validationError; speciesGraph.add(diffError.getSpecies()); } childErrors.add(validationError); } - + Map<String, JFreeChart> charts = getCompareCatchLengthGraph(project, container, speciesGraph); // render output html @@ -424,10 +413,10 @@ public class PublicationService { } out.write(")"); } - + // ajout d'un graph si necessaire if (error instanceof DiffCatchLengthControlError) { - DiffCatchLengthControlError diffError = (DiffCatchLengthControlError)error; + DiffCatchLengthControlError diffError = (DiffCatchLengthControlError) error; String species = diffError.getSpecies(); out.write(" (<a href='#graph" + species + "'>" + t("coser.business.publication.errorgraph") + "</a>)"); } @@ -436,7 +425,7 @@ public class PublicationService { if (StringUtils.isNotEmpty(error.getTipMessage())) { out.write("<p style='font-style:italic'>" + tipMessage + "</p>"); } - + out.write("</li>"); } out.write("</ul>"); @@ -464,12 +453,11 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur un control au format html. - * + * * @param project project * @param control data container * @return extractedFile - * @throws CoserBusinessException - * + * @throws CoserBusinessException * @see AbstractDataContainer#getHistoryCommands() */ public File extractControlLogAsHTML(Project project, Control control) throws CoserBusinessException { @@ -494,16 +482,16 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur un control au format html * dans un flux donné. - * + * * @param project project * @param control data container - * @param out output stream - * @throws CoserBusinessException - * @throws IOException + * @param out output stream + * @throws CoserBusinessException + * @throws IOException */ protected void extractControlLogAsHTML(Project project, Control control, Writer out) throws CoserBusinessException, IOException { out.write("<html><head>"); - out.write("<title>" + t("coser.business.publication.controllogexporttitle", project.getName())+ "</title>"); + out.write("<title>" + t("coser.business.publication.controllogexporttitle", project.getName()) + "</title>"); out.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>"); out.write("</head><body>"); @@ -521,19 +509,18 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur un control au format pdf. - * - * @param project project - * @param control data container - * @param validationErrors - * @param pdfFile output pdf file + * + * @param project project + * @param control data container + * @param validationErrors + * @param pdfFile output pdf file * @return extractedFile * @throws CoserBusinessException * @sincee 1.3 - * * @see AbstractDataContainer#getHistoryCommands() */ public void extractControlLogAsPDF(Project project, Control control, - List<ControlError> validationErrors, File pdfFile) throws CoserBusinessException { + List<ControlError> validationErrors, File pdfFile) throws CoserBusinessException { OutputStream os = null; try { @@ -567,12 +554,11 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur une selection au format html. - * - * @param project project + * + * @param project project * @param selection data container * @return extractedFile - * @throws CoserBusinessException - * + * @throws CoserBusinessException * @see AbstractDataContainer#getHistoryCommands() */ public File extractSelectionLogAsHTML(Project project, Selection selection) throws CoserBusinessException { @@ -587,7 +573,7 @@ public class PublicationService { out = new OutputStreamWriter(new FileOutputStream(exportHtmlFile), "utf-8"); extractSelectionLogAsHTML(project, selection, out); - + } catch (IOException ex) { throw new CoserBusinessException("Can't export logs", ex); } finally { @@ -599,19 +585,18 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur une selection au format html * dans le flux donné. - * - * @param project project + * + * @param project project * @param selection data container - * @param out output stream + * @param out output stream * @return extractedFile - * @throws IOException - * @throws CoserBusinessException - * + * @throws IOException + * @throws CoserBusinessException * @see AbstractDataContainer#getHistoryCommands() */ protected void extractSelectionLogAsHTML(Project project, Selection selection, Writer out) throws IOException, CoserBusinessException { out.write("<html><head>"); - out.write("<title>" + t("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName())+ "</title>"); + out.write("<title>" + t("coser.business.publication.selectionlogexporttitle", selection.getName(), project.getName()) + "</title>"); out.write("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>"); out.write("</head><body>"); @@ -646,10 +631,10 @@ public class PublicationService { /** * Extrait la partie "detail projet" vers le flux. - * + * * @param project project - * @param out stream - * @throws IOException + * @param out stream + * @throws IOException */ protected void extractProjectReport(Project project, Writer out) throws IOException { @@ -657,13 +642,13 @@ public class PublicationService { // date du rapport out.write("<div style='text-align:right;font-style:italic'>" + - t("coser.business.publication.date") +" : " + - dateFormat.format(new Date()) + "</div>"); + t("coser.business.publication.date") + " : " + + dateFormat.format(new Date()) + "</div>"); // partie projet out.write("<h2>" + t("coser.business.publication.projectdetails") + "</h2>"); out.write("<ul>"); - out.write("<li>" + t("coser.business.publication.creationdate") + " : " + dateFormat.format(project.getCreationDate()) + "</li>"); + out.write("<li>" + t("coser.business.publication.creationdate") + " : " + dateFormat.format(project.getCreationDate()) + "</li>"); out.write("<li>" + t("coser.business.publication.author") + " : " + project.getAuthor() + "</li>"); out.write("<li>" + t("coser.business.publication.catchfilename") + " : " + commonService.getDataStorageFileName(project, Category.CATCH, null) + "</li>"); out.write("<li>" + t("coser.business.publication.lengthfilename") + " : " + commonService.getDataStorageFileName(project, Category.LENGTH, null) + "</li>"); @@ -677,14 +662,13 @@ public class PublicationService { /** * Extrait les logs des modifications faites sur une selection au format pdf. - * - * @param project project + * + * @param project project * @param selection data container * @return extractedFile * @throws CoserBusinessException - * @since 1.3 - * * @see AbstractDataContainer#getHistoryCommands() + * @since 1.3 */ public void extractSelectionLogAsPDF(Project project, Selection selection, File pdfFile) throws CoserBusinessException { @@ -720,12 +704,12 @@ public class PublicationService { * Partie commune aux export qui effectue en 2 passe la recuperation * des lignes d'erreur, la recuperation des données correspondant à * ces lignes dans les fichiers originaux et la sortie des erreurs. - * - * @param project project + * + * @param project project * @param container data container - * @param out output stream - * @throws CoserBusinessException - * @throws IOException + * @param out output stream + * @throws CoserBusinessException + * @throws IOException */ protected void extractHistoryCommandReport(Project project, AbstractDataContainer container, Writer out) throws CoserBusinessException, IOException { @@ -734,28 +718,28 @@ public class PublicationService { Set<String> lengthLines = new HashSet<String>(); Set<String> haulLines = new HashSet<String>(); Set<String> strataLines = new HashSet<String>(); - + for (Command command : container.getHistoryCommands()) { Category category = null; String line = null; if (command instanceof CategoryLineCommand) { - category = ((CategoryLineCommand)command).getCategory(); - line = ((CategoryLineCommand)command).getLineNumber(); + category = ((CategoryLineCommand) command).getCategory(); + line = ((CategoryLineCommand) command).getLineNumber(); } if (category != null && line != null) { switch (category) { - case CATCH: - catchLines.add(line); - break; - case LENGTH: - lengthLines.add(line); - break; - case HAUL: - haulLines.add(line); - break; - case STRATA: - strataLines.add(line); - break; + case CATCH: + catchLines.add(line); + break; + case LENGTH: + lengthLines.add(line); + break; + case HAUL: + haulLines.add(line); + break; + case STRATA: + strataLines.add(line); + break; } } } @@ -765,7 +749,7 @@ public class PublicationService { Map<String, String[]> lengthContent = commonService.getOriginalContent(project, Category.LENGTH, lengthLines); Map<String, String[]> haulContent = commonService.getOriginalContent(project, Category.HAUL, haulLines); Map<String, String[]> strataContent = commonService.getOriginalContent(project, Category.STRATA, strataLines); - + // third, generate html report out.write("<h2>" + t("coser.business.publication.datamodification") + "</h2>"); out.write("<ol>"); @@ -773,25 +757,25 @@ public class PublicationService { Category category = null; String line = null; if (command instanceof CategoryLineCommand) { - category = ((CategoryLineCommand)command).getCategory(); - line = ((CategoryLineCommand)command).getLineNumber(); + category = ((CategoryLineCommand) command).getCategory(); + line = ((CategoryLineCommand) command).getLineNumber(); } out.write("<li>"); if (category != null && line != null) { String[] data = null; switch (category) { - case CATCH: - data = catchContent.get(line); - break; - case LENGTH: - data = lengthContent.get(line); - break; - case HAUL: - data = haulContent.get(line); - break; - case STRATA: - data = strataContent.get(line); - break; + case CATCH: + data = catchContent.get(line); + break; + case LENGTH: + data = lengthContent.get(line); + break; + case HAUL: + data = haulContent.get(line); + break; + case STRATA: + data = strataContent.get(line); + break; } out.write(command.getLogString(project, container) + "<br/>"); out.write("<tt style='color:#5F5A59'>" + StringUtils.join(data, ", ") + "</tt>"); @@ -810,24 +794,24 @@ public class PublicationService { /** * Generate community graph for selected indicator. * Used by web ui. - * - * @param project project - * @param resultDirectory result directory - * @param rsufiResult rsufiresult + * + * @param project project + * @param resultDirectory result directory + * @param rsufiResult rsufiresult * @param codeTypeEspecesFile le fichier contenant les code type espece (specifique au projet) - * @param indicator indicator - * @param list indicator's list (can be {@code null} : none selected) - * @param zoneDisplayName zone full name - * @param indicatorName indicatorName localized - * @param unit data unit - * @param locale locale + * @param indicator indicator + * @param list indicator's list (can be {@code null} : none selected) + * @param zoneDisplayName zone full name + * @param indicatorName indicatorName localized + * @param unit data unit + * @param locale locale * @return generated graph image (temp file) * @throws CoserBusinessException */ public File getRsufiResultComChart(Project project, File resultDirectory, - RSufiResult rsufiResult, File codeTypeEspecesFile, String indicator, - String list, String zoneDisplayName, String indicatorName, String unit, - Locale locale) throws CoserBusinessException { + RSufiResult rsufiResult, File codeTypeEspecesFile, String indicator, + String list, String zoneDisplayName, String indicatorName, String unit, + Locale locale) throws CoserBusinessException { File result = null; @@ -874,7 +858,7 @@ public class PublicationService { Double estimation = Double.parseDouble(tuple[5]); Double ecart = Double.parseDouble(tuple[6]); int year = Integer.parseInt(tuple[4]); - + if (year < minYear) { minYear = year; } @@ -882,7 +866,7 @@ public class PublicationService { maxYear = year; } graphData.put(year, new Double[]{estimation, ecart}); - + // si les données sont énormes, on affiche les données // / multiplicator et on le mentionne dans la légende if (estimation > 1e9) { @@ -902,7 +886,7 @@ public class PublicationService { // get graph title String chartTitle = zoneDisplayName; chartTitle += " - " + indicatorName; - + // ajout de la traduction de la liste d'indicateur // les liste sont a1, T1, T2 ... String listLetter = String.valueOf(localList.charAt(0)); @@ -923,8 +907,7 @@ public class PublicationService { } else { chartTitle += " - " + "All List " + localList.charAt(1); } - } - else { + } else { // ajout de la traduction du nom de liste plus le numéro if ("fr".equals(locale.getLanguage())) { chartTitle += " - " + tuple[0] + " Liste " + localList.charAt(1); @@ -937,21 +920,20 @@ public class PublicationService { break; } } - + // generate dataset with sorted data DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); - for (int indexYear = minYear ; indexYear <= maxYear ; ++indexYear) { + for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { Double[] entry = graphData.get(indexYear); if (entry != null) { Double estimation = entry[0] / multiplicator; Double ecart = entry[1] / multiplicator; - statisticalDataset.add(estimation, ecart, "Serie1", (Comparable)indexYear); - } - else { - statisticalDataset.add(null, null, "Serie1", (Comparable)indexYear); + statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); + } else { + statisticalDataset.add(null, null, "Serie1", (Comparable) indexYear); } } - + // configure chart //CategoryAxis categoryAxis = new CategoryAxis(t("coser.business.common.year")); // FIXME echatellier 20110414 hack just for year, need a real locale object here @@ -970,30 +952,29 @@ public class PublicationService { if (multiplicator != 1) { // affiche par exemple : cm * 1000 legendY += " (" + unit + "*" + multiplicator + ")"; - } - else if (StringUtils.isNotEmpty(unit)) { + } else if (StringUtils.isNotEmpty(unit)) { legendY += " (" + unit + ")"; } ValueAxis valueAxis = new NumberAxis(legendY); valueAxis.setUpperMargin(0.1); - + CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); - + // n'affiche pas les nombre sur le graphique //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator(); //renderer.setBaseItemLabelGenerator(itemLabelGenerator); //renderer.setBaseItemLabelsVisible(true); - + CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(chartTitle, - JFreeChart.DEFAULT_TITLE_FONT, plot, true); - + JFreeChart.DEFAULT_TITLE_FONT, plot, true); + // remove series legend chart.removeLegend(); // white background chart.setBackgroundPaint(Color.WHITE); - + try { result = File.createTempFile("coser-chart-", ".png"); result.deleteOnExit(); @@ -1008,23 +989,23 @@ public class PublicationService { /** * Generate population graph for selected species and indicator. - * - * @param project project + * + * @param project project * @param resultDirectory result directory - * @param rsufiResult rsufi result - * @param species species - * @param indicator indicator + * @param rsufiResult rsufi result + * @param species species + * @param indicator indicator * @param zoneDisplayName zone full name - * @param indicatorName indicatorName localized - * @param unit data unit - * @param locale locale + * @param indicatorName indicatorName localized + * @param unit data unit + * @param locale locale * @return generated image file (temp file) - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getRsufiResultPopChart(Project project, File resultDirectory, - RSufiResult rsufiResult, String species, String indicator, - String zoneDisplayName, String indicatorName, String unit, Locale locale) throws CoserBusinessException { - + RSufiResult rsufiResult, String species, String indicator, + String zoneDisplayName, String indicatorName, String unit, Locale locale) throws CoserBusinessException { + File result = null; // le fichier estcomind @@ -1060,7 +1041,7 @@ public class PublicationService { maxYear = year; } graphData.put(year, new Double[]{estimation, ecart}); - + // si les données sont énormes, on affiche les données // / multiplicator et on le mentionne dans la légende if (estimation > 1e9) { @@ -1080,22 +1061,21 @@ public class PublicationService { String title = zoneDisplayName; title += " - " + indicatorName; title += " - " + commonService.getReportDisplayName(project, species); - + // generate dataset with sorted data - DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); - for (int indexYear = minYear ; indexYear <= maxYear ; ++indexYear) { + DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); + for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { Double[] entry = graphData.get(indexYear); if (entry != null) { Double estimation = entry[0] / multiplicator; Double ecart = entry[1] / multiplicator; - statisticalDataset.add(estimation, ecart, "Serie1", (Comparable)indexYear); - } - else { - statisticalDataset.add(null, null, "Serie1", (Comparable)indexYear); + statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); + } else { + statisticalDataset.add(null, null, "Serie1", (Comparable) indexYear); } } - - + + // configure chart //CategoryAxis categoryAxis = new CategoryAxis(t("coser.business.common.year")); // FIXME echatellier 20110414 hack just for year, need a real locale object here @@ -1114,30 +1094,29 @@ public class PublicationService { if (multiplicator != 1) { // affiche par exemple : cm * 1000 legendY += " (" + unit + "*" + multiplicator + ")"; - } - else if (StringUtils.isNotEmpty(unit)) { + } else if (StringUtils.isNotEmpty(unit)) { legendY += " (" + unit + ")"; } ValueAxis valueAxis = new NumberAxis(legendY); valueAxis.setUpperMargin(0.1); - + CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); - + // n'affiche pas les nombre sur le graphique //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator(); //renderer.setBaseItemLabelGenerator(itemLabelGenerator); //renderer.setBaseItemLabelsVisible(true); - + CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, - JFreeChart.DEFAULT_TITLE_FONT, plot, true); - + JFreeChart.DEFAULT_TITLE_FONT, plot, true); + // remove series legend chart.removeLegend(); // white background chart.setBackgroundPaint(Color.WHITE); - + try { result = File.createTempFile("coser-chart-", ".png"); result.deleteOnExit(); @@ -1153,25 +1132,25 @@ public class PublicationService { /** * Generate community graph for selected indicators. * Used by web ui extraction. - * - * @param project project - * @param resultDirectory result directory - * @param rsufiResult rsufiresult + * + * @param project project + * @param resultDirectory result directory + * @param rsufiResult rsufiresult * @param codeTypeEspecesFile le fichier contenant les code type espece (specifique au projet) - * @param indicator indicator - * @param zoneDisplayName zone full name - * @param indicatorName indicatorName localized - * @param unit data unit - * @param locale locale - * @param width graph width - * @param height graph height + * @param indicator indicator + * @param zoneDisplayName zone full name + * @param indicatorName indicatorName localized + * @param unit data unit + * @param locale locale + * @param width graph width + * @param height graph height * @return generated graph image (temp file) and data - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, Object[]> getRsufiResultComCharts(Project project, File resultDirectory, - RSufiResult rsufiResult, File codeTypeEspecesFile, Collection<String> indicators, - String zoneDisplayName, MultiKeyMap indicatorMap, Locale locale, - int width, int height) throws CoserBusinessException { + RSufiResult rsufiResult, File codeTypeEspecesFile, Collection<String> indicators, + String zoneDisplayName, MultiKeyMap indicatorMap, Locale locale, + int width, int height) throws CoserBusinessException { Map<String, Object[]> result = new HashMap<String, Object[]>(); @@ -1213,7 +1192,7 @@ public class PublicationService { Double estimation = Double.parseDouble(tuple[5]); Double ecart = Double.parseDouble(tuple[6]); int year = Integer.parseInt(tuple[4]); - + if (year < minYear) { minYear = year; } @@ -1226,7 +1205,7 @@ public class PublicationService { indicatorGraphData.put(indicatorCode, graphData); } graphData.put(year, new Double[]{estimation, ecart}); - + // si les données sont énormes, on affiche les données // / multiplicator et on le mentionne dans la légende if (estimation > 1e9) { @@ -1235,7 +1214,7 @@ public class PublicationService { if (estimation > 1e6 && multiplicator < 1000000) { multiplicator = 1000; } - + // for data part DataStorage subDataStorage = indicatorStorages.get(indicatorCode); if (subDataStorage == null) { @@ -1258,8 +1237,8 @@ public class PublicationService { for (String indicator : indicatorGraphData.keySet()) { // get graph title String chartTitle = zoneDisplayName; - String indicatorName = (String)indicatorMap.get(indicator, locale.getLanguage()); - String unit = (String)indicatorMap.get(indicator, "unit"); + String indicatorName = (String) indicatorMap.get(indicator, locale.getLanguage()); + String unit = (String) indicatorMap.get(indicator, "unit"); chartTitle += " - " + indicatorName; // ajout de la traduction de la liste d'indicateur @@ -1296,21 +1275,21 @@ public class PublicationService { break; } } - + // generate dataset with sorted data Map<Integer, Double[]> graphData = indicatorGraphData.get(indicator); DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); - for (int indexYear = minYear ; indexYear <= maxYear ; ++indexYear) { + for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { Double[] entry = graphData.get(indexYear); if (entry != null) { Double estimation = entry[0] / multiplicator; Double ecart = entry[1] / multiplicator; - statisticalDataset.add(estimation, ecart, "Serie1", (Comparable)indexYear); + statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); } else { - statisticalDataset.add(null, null, "Serie1", (Comparable)indexYear); + statisticalDataset.add(null, null, "Serie1", (Comparable) indexYear); } } - + // configure chart //CategoryAxis categoryAxis = new CategoryAxis(t("coser.business.common.year")); // FIXME echatellier 20110414 hack just for year, need a real locale object here @@ -1345,7 +1324,7 @@ public class PublicationService { CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(chartTitle, - JFreeChart.DEFAULT_TITLE_FONT, plot, true); + JFreeChart.DEFAULT_TITLE_FONT, plot, true); // remove series legend chart.removeLegend(); @@ -1376,25 +1355,25 @@ public class PublicationService { /** * Generate population graph for selected species and indicator. - * - * @param project project + * + * @param project project * @param resultDirectory result directory - * @param rsufiResult rsufi result - * @param species species - * @param indicator indicator + * @param rsufiResult rsufi result + * @param species species + * @param indicator indicator * @param zoneDisplayName zone full name - * @param indicatorName indicatorName localized - * @param unit data unit - * @param locale locale - * @param width graph width - * @param height graph height + * @param indicatorName indicatorName localized + * @param unit data unit + * @param locale locale + * @param width graph width + * @param height graph height * @return generated image file (temp file) - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, Object[]> getRsufiResultPopCharts(Project project, File resultDirectory, - RSufiResult rsufiResult, Collection<String> species, Collection<String> indicators, - String zoneDisplayName, MultiKeyMap indicatorMap, Locale locale, - int width, int height) throws CoserBusinessException { + RSufiResult rsufiResult, Collection<String> species, Collection<String> indicators, + String zoneDisplayName, MultiKeyMap indicatorMap, Locale locale, + int width, int height) throws CoserBusinessException { Map<String, Object[]> result = new HashMap<String, Object[]>(); @@ -1430,13 +1409,13 @@ public class PublicationService { if (year > maxYear) { maxYear = year; } - Map<Integer, Double[]> graphData = (Map<Integer, Double[]>)indicatorGraphData.get(indicatorCode, speciesCode); + Map<Integer, Double[]> graphData = (Map<Integer, Double[]>) indicatorGraphData.get(indicatorCode, speciesCode); if (graphData == null) { graphData = new HashMap<Integer, Double[]>(); indicatorGraphData.put(indicatorCode, speciesCode, graphData); } graphData.put(year, new Double[]{estimation, ecart}); - + // si les données sont énormes, on affiche les données // / multiplicator et on le mentionne dans la légende if (estimation > 1e9) { @@ -1445,9 +1424,9 @@ public class PublicationService { if (estimation > 1e6 && multiplicator < 1000000) { multiplicator = 1000; } - + // for data part - DataStorage subDataStorage = (DataStorage)indicatorStorages.get(indicatorCode, speciesCode); + DataStorage subDataStorage = (DataStorage) indicatorStorages.get(indicatorCode, speciesCode); if (subDataStorage == null) { subDataStorage = new MemoryDataStorage(); if ("fr".equals(locale.getLanguage())) { @@ -1465,31 +1444,31 @@ public class PublicationService { // avec l'extraction des données, on peut demander a générer un graphique // sur un indicateur qui n'est pas présent dans le projet courant, // dans ce cas, on retourne null - for (MultiKey indicatorSpecies : (Set<MultiKey>)indicatorGraphData.keySet()) { - String indicator = (String)indicatorSpecies.getKey(0); - String aSpecies = (String)indicatorSpecies.getKey(1); + for (MultiKey indicatorSpecies : (Set<MultiKey>) indicatorGraphData.keySet()) { + String indicator = (String) indicatorSpecies.getKey(0); + String aSpecies = (String) indicatorSpecies.getKey(1); // get graph title String title = zoneDisplayName; - String indicatorName = (String)indicatorMap.get(indicator, locale.getLanguage()); - String unit = (String)indicatorMap.get(indicator, "unit"); + String indicatorName = (String) indicatorMap.get(indicator, locale.getLanguage()); + String unit = (String) indicatorMap.get(indicator, "unit"); title += " - " + indicatorName; title += " - " + commonService.getReportDisplayName(project, aSpecies); - + // generate dataset with sorted data DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset(); - Map<Integer, Double[]> graphData = (Map<Integer, Double[]>)indicatorGraphData.get(indicator, aSpecies); - for (int indexYear = minYear ; indexYear <= maxYear ; ++indexYear) { + Map<Integer, Double[]> graphData = (Map<Integer, Double[]>) indicatorGraphData.get(indicator, aSpecies); + for (int indexYear = minYear; indexYear <= maxYear; ++indexYear) { Double[] entry = graphData.get(indexYear); if (entry != null) { Double estimation = entry[0] / multiplicator; Double ecart = entry[1] / multiplicator; - statisticalDataset.add(estimation, ecart, "Serie1", (Comparable)indexYear); + statisticalDataset.add(estimation, ecart, "Serie1", (Comparable) indexYear); } else { - statisticalDataset.add(null, null, "Serie1", (Comparable)indexYear); + statisticalDataset.add(null, null, "Serie1", (Comparable) indexYear); } } - - + + // configure chart //CategoryAxis categoryAxis = new CategoryAxis(t("coser.business.common.year")); // FIXME echatellier 20110414 hack just for year, need a real locale object here @@ -1508,39 +1487,38 @@ public class PublicationService { if (multiplicator != 1) { // affiche par exemple : cm * 1000 legendY += " (" + unit + "*" + multiplicator + ")"; - } - else if (StringUtils.isNotEmpty(unit)) { + } else if (StringUtils.isNotEmpty(unit)) { legendY += " (" + unit + ")"; } ValueAxis valueAxis = new NumberAxis(legendY); valueAxis.setUpperMargin(0.1); - + CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); - + // n'affiche pas les nombre sur le graphique //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator(); //renderer.setBaseItemLabelGenerator(itemLabelGenerator); //renderer.setBaseItemLabelsVisible(true); - + CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, - JFreeChart.DEFAULT_TITLE_FONT, plot, true); - + JFreeChart.DEFAULT_TITLE_FONT, plot, true); + // remove series legend chart.removeLegend(); // white background chart.setBackgroundPaint(Color.WHITE); - + try { File chartFile = File.createTempFile("coser-chart-", ".png"); chartFile.deleteOnExit(); ChartUtilities.saveChartAsPNG(chartFile, chart, width, height); //ByteArrayOutputStream out = new ByteArrayOutputStream(); //ChartUtilities.writeChartAsPNG(out, chart, width, height); - + // data extraction - DataStorage subDataStorage = (DataStorage)indicatorStorages.get(indicator, aSpecies); + DataStorage subDataStorage = (DataStorage) indicatorStorages.get(indicator, aSpecies); StringWriter writer = new StringWriter(); commonService.storeDataWhithoutQuote(subDataStorage, writer, null, null); @@ -1557,16 +1535,16 @@ public class PublicationService { /** * Genere un sous fichier CSV (qui contient un sous ensemble de estPopInd) * et qui a servit a generer le graphique. - * + * * @param resultDirectory result directory - * @param rsufiResult rsufi result - * @param indicator indicator - * @param list indicator's list (if {@code null} look for pop indicators or no list selected + * @param rsufiResult rsufi result + * @param indicator indicator + * @param list indicator's list (if {@code null} look for pop indicators or no list selected * @return generated csv file (temp file) - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getRsufiResultComChartData(File resultDirectory, - RSufiResult rsufiResult, String indicator, String list) throws CoserBusinessException { + RSufiResult rsufiResult, String indicator, String list) throws CoserBusinessException { File result = null; @@ -1601,7 +1579,7 @@ public class PublicationService { if (StringUtils.isBlank(localList)) { localList = indicatorList; } - + if (indicatorList.equals(localList)) { subDataStorage.add(tuple); } @@ -1619,16 +1597,16 @@ public class PublicationService { /** * Genere un sous fichier CSV (qui contient un sous ensemble de estPopInd) * et qui a servit a generer le graphique. - * + * * @param resultDirectory result directory - * @param rsufiResult rsufi result - * @param species species - * @param indicator indicator + * @param rsufiResult rsufi result + * @param species species + * @param indicator indicator * @return generated csv file (temp file) - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getRsufiResultPopChartData(File resultDirectory, - RSufiResult rsufiResult, String species, String indicator) throws CoserBusinessException { + RSufiResult rsufiResult, String species, String indicator) throws CoserBusinessException { File result = null; diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/WebResultService.java b/coser-business/src/main/java/fr/ifremer/coser/services/WebResultService.java index 89d00c5..79acc6d 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/WebResultService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/WebResultService.java @@ -83,10 +83,10 @@ import static org.nuiton.i18n.I18n.t; /** * Service to be used only by the web server to manage results. - * <p/> + * * Created on 3/18/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class WebResultService { @@ -180,7 +180,7 @@ public class WebResultService { /** * Traite le fichier uploade par l'application client et l'enregistre * dans le stockage coté web. - * <p/> + * * Le nouveau fichier uploadé est mergé avec l'ancien, c'est à dire: * <ul> * <li>dezipage dans un fichier temporaire @@ -191,7 +191,7 @@ public class WebResultService { * <li>copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire * mais seulement pour ceux des zones concernés (partie difficile) * </ul> - * <p/> + * * TODO chatellier 20110125 l'algorithme n'est pour l'instant pas performant * et contient pas mal de code dupliqué, mais pour la v1.0 ca ira. * @@ -601,7 +601,7 @@ public class WebResultService { * Fait le menage dans le dossier courant des projets en supprimant * tout les resulat qui ont un result id present dans la liste * {@code newResultIds}. - * <p/> + * * Supprime egalement les selections qui n'ont plus de résultats et * les projets qui n'ont plus de selection. * @@ -729,7 +729,7 @@ public class WebResultService { /** * Recupere dans un repertoire donné, les zoneid des resultat avec * pour chaque id, le nom du projet associé. - * <p/> + * * Les boolean sont des grands {@code Boolean} car si la valeur * est {@code null}, on ne tient pas compte du critere lors de la recherche. * diff --git a/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java b/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java index 4133f02..ecb9bd4 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java +++ b/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java @@ -22,8 +22,52 @@ package fr.ifremer.coser.services; -import static org.nuiton.i18n.I18n.t; -import static org.nuiton.i18n.I18n.l; +import com.itextpdf.text.DocumentException; +import fr.ifremer.coser.CoserBusinessConfig; +import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.CoserConstants; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserUtils; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.RSufiResult; +import fr.ifremer.coser.bean.RSufiResultPath; +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.storage.DataStorage; +import fr.ifremer.coser.storage.MemoryDataStorage; +import fr.ifremer.coser.util.DataType; +import fr.ifremer.coser.util.InputStreamKnownSizeBody; +import fr.ifremer.coser.util.ProgressMonitor; +import fr.ifremer.coser.util.ProgressStream; +import freemarker.cache.ClassTemplateLoader; +import freemarker.ext.beans.BeansWrapper; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.collections4.keyvalue.MultiKey; +import org.apache.commons.collections4.map.MultiKeyMap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.MultiPartEmail; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntity; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.impl.client.DefaultHttpClient; +import org.nuiton.util.FileUtil; +import org.nuiton.util.StringUtil; +import org.nuiton.util.ZipUtil; +import org.w3c.dom.Document; +import org.xhtmlrenderer.pdf.ITextRenderer; import java.io.File; import java.io.FileFilter; @@ -55,73 +99,23 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Matcher; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.collections4.keyvalue.MultiKey; -import org.apache.commons.collections4.map.MultiKeyMap; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringEscapeUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.mail.EmailException; -import org.apache.commons.mail.MultiPartEmail; -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.mime.HttpMultipartMode; -import org.apache.http.entity.mime.MultipartEntity; -import org.apache.http.entity.mime.content.StringBody; -import org.apache.http.impl.client.DefaultHttpClient; -import org.nuiton.util.FileUtil; -import org.nuiton.util.StringUtil; -import org.nuiton.util.ZipUtil; -import org.w3c.dom.Document; -import org.xhtmlrenderer.pdf.ITextRenderer; - -import com.itextpdf.text.DocumentException; - -import fr.ifremer.coser.CoserBusinessConfig; -import fr.ifremer.coser.CoserBusinessException; -import fr.ifremer.coser.CoserConstants; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserUtils; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.RSufiResult; -import fr.ifremer.coser.bean.RSufiResultPath; -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.storage.DataStorage; -import fr.ifremer.coser.storage.MemoryDataStorage; -import fr.ifremer.coser.util.DataType; -import fr.ifremer.coser.util.InputStreamKnownSizeBody; -import fr.ifremer.coser.util.ProgressMonitor; -import fr.ifremer.coser.util.ProgressStream; -import freemarker.cache.ClassTemplateLoader; -import freemarker.ext.beans.BeansWrapper; -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; +import static org.nuiton.i18n.I18n.l; +import static org.nuiton.i18n.I18n.t; /** * Service specifique à l'interface web de visualisation et à la partie UI * qui sert a envoyer les resultats vers l'interface web. - * + * * Ce service, contrairement aux autres a un état, les indicateurs et zones * chargées persistent après chargement, car elle ne peuvent pas changer * tant que l'application est en cours d'utilisation. - * + * * Il faut garder à l'esprit que les projets n'ont pas forcement * de données publiées, donc le chargement du projet est possible, mais * pas les données de controle et les données de selection (donc plutot * travailler sur les fichiers estcomind/estpopind que sur les 4 tables). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ * @deprecated since 1.5, should never be used, code too ugly and *simple* (dummy simple?) */ @Deprecated @@ -170,9 +164,9 @@ public class WebService { /** * Charge les indicateurs disponible depuis le fichier des indicateurs. * (indid, indname) - * + * * @return indicators map - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected MultiKeyMap getIndicatorsMap() throws CoserBusinessException { @@ -196,51 +190,50 @@ public class WebService { /** * Get indicator translation by checking correct locale. - * + * * @param indicator indicator code - * @param locale locale + * @param locale locale * @return indicator translation */ protected String getIndicatorValue(String indicator, String localeCode) throws CoserBusinessException { String localLocaleCode = localeCode; if (!"fr".equals(localLocaleCode) && !"es".equals(localLocaleCode) - && !"unit".equals(localLocaleCode)) { + && !"unit".equals(localLocaleCode)) { localLocaleCode = "en"; // en by default } - return (String)getIndicatorsMap().get(indicator, localLocaleCode); + return (String) getIndicatorsMap().get(indicator, localLocaleCode); } /** * Charge les zones disponibles depuis le fichier des zones. * (zoneid, zonename) - * + * * @return zones map - * @throws CoserBusinessException + * @throws CoserBusinessException */ public DataStorage getZonesMap() throws CoserBusinessException { if (zonesMap == null) { File zoneFile = config.getWebZonesFile(); - + // l'operation n'est pas obligatoire pour tous les clients // lourd, le fichier peut donc ne pas exister if (zoneFile.isFile()) { zonesMap = commonService.loadCSVFile(zoneFile); - } - else { + } else { // fait volontairement un return new, n'affecte pas l'etat du // service return new MemoryDataStorage(); } } - + return zonesMap; } /** * Retourne les nom d'une zone (avec la facade, l'année et la serie) en * fonction de l'id de la zone. - * + * * @param zoneId zone id * @return zone name (or {@code null} if not found) * @throws CoserBusinessException @@ -261,16 +254,15 @@ public class WebService { /** * Retourne tous les projets qui ont des résultats. - * - * De la forme d'une liste de de path (à la tree path) : + * + * De la forme d'une liste de de path (à la tree path) : * ProjetName/SelectionName/ResultName - * - * @param beginDate begin date (can be null) - * @param endDate end date (can be null) + * + * @param beginDate begin date (can be null) + * @param endDate end date (can be null) * @param onlyPubliableResult select only publiable results - * * @return results paths - * @throws CoserBusinessException + * @throws CoserBusinessException */ public List<RSufiResultPath> findAllProjectWithResult(Date beginDate, Date endDate, boolean onlyPubliableResult) throws CoserBusinessException { List<RSufiResultPath> results = new ArrayList<RSufiResultPath>(); @@ -321,15 +313,15 @@ public class WebService { /** * Test if result is valid with filtering. - * - * @param rsufiResult rsufi result to test - * @param beginDate begin date (can be null) - * @param endDate end date (can be null) + * + * @param rsufiResult rsufi result to test + * @param beginDate begin date (can be null) + * @param endDate end date (can be null) * @param onlyPubliableResult select only publiable results * @return if result is valid candidate */ protected boolean isCandidateResult(RSufiResult rsufiResult, Date beginDate, - Date endDate, boolean onlyPubliableResult) { + Date endDate, boolean onlyPubliableResult) { boolean result = true; @@ -350,9 +342,9 @@ public class WebService { /** * Extract directory to custom directory. - * - * @param selectedResults selected result paths - * @param extractDirectory extract directory (can be null) + * + * @param selectedResults selected result paths + * @param extractDirectory extract directory (can be null) * @param publishDataResults result paths flaged with results export * @return extracted file (no automatically deleted) * @throws CoserBusinessException @@ -364,8 +356,7 @@ public class WebService { // create zip file name not random name if (extractDirectory == null) { prepareZip = File.createTempFile("Coserextract-", ".zip"); - } - else { + } else { // cas extraction vers un répertoire specifique DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); String zipName = "Coserextract" + dateFormat.format(new Date()) + ".zip"; @@ -380,7 +371,7 @@ public class WebService { project = projectService.openProject(project.getName()); OneResultFileFilter oneRFF = new OneResultFileFilter(config.getRSufiProjectsDirectory(), - project, path.getSelection(), path.getRsufiResult(), publishDataResults.contains(path)); + project, path.getSelection(), path.getRsufiResult(), publishDataResults.contains(path)); mFileFilters.add(oneRFF); } @@ -395,30 +386,30 @@ public class WebService { } catch (IOException ex) { throw new CoserBusinessException("Can't prepare upload data", ex); } - + return prepareZip; } /** * Upload user selected result to coser web front-end using common http * client. - * + * * TODO remove les 4 listes s'il y a mieux. - * - * @param selectedResults selected result (collection of project/selection/rsufiresult) - * @param indicatorsResults results selected as indicator results - * @param mapResults results selected as map result + * + * @param selectedResults selected result (collection of project/selection/rsufiresult) + * @param indicatorsResults results selected as indicator results + * @param mapResults results selected as map result * @param publishDataResults results selected as results published with data - * @param login remote admin login - * @param password remote admin password - * @param progress progress monitor + * @param login remote admin login + * @param password remote admin password + * @param progress progress monitor * @return upload error status or {@code null} if no error - * @throws CoserBusinessException + * @throws CoserBusinessException */ public String performResultUpload(Collection<RSufiResultPath> selectedResults, - Collection<RSufiResultPath> indicatorsResults, Collection<RSufiResultPath> mapResults, - Collection<RSufiResultPath> publishDataResults, String login, - String password, ProgressMonitor progress) throws CoserBusinessException { + Collection<RSufiResultPath> indicatorsResults, Collection<RSufiResultPath> mapResults, + Collection<RSufiResultPath> publishDataResults, String login, + String password, ProgressMonitor progress) throws CoserBusinessException { String uploadStatus = null; @@ -439,7 +430,7 @@ public class WebService { File prepareZip = performResultExtract(selectedResults, publishDataResults, null); progress.setText(t("coser.business.uploadresult.sendzip")); - progress.setTotal((int)prepareZip.length()); + progress.setTotal((int) prepareZip.length()); // then upload zip file to website try { @@ -456,7 +447,7 @@ public class WebService { // file param ProgressStream stream = new ProgressStream(new FileInputStream(prepareZip), progress); InputStreamKnownSizeBody fileBody = new InputStreamKnownSizeBody(stream, prepareZip.length(), - "application/zip", prepareZip.getName()); + "application/zip", prepareZip.getName()); reqEntity.addPart("resultFile", fileBody); HttpPost httppost = new HttpPost(config.getWebUploadURL()); @@ -476,25 +467,25 @@ public class WebService { } catch (IOException ex) { throw new CoserBusinessException("Can't upload file", ex); } - + prepareZip.delete(); - + return uploadStatus; } /** * Modifie les types et options de certains résultats rsufi (map result, * data sources result). - * - * @param selectedResults selected result (collection of project/selection/rsufiresult) - * @param indicatorsResults results selected as indicator results - * @param mapResults map results + * + * @param selectedResults selected result (collection of project/selection/rsufiresult) + * @param indicatorsResults results selected as indicator results + * @param mapResults map results * @param publishDataResults publish data results - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected void modifyRSufiResults(Collection<RSufiResultPath> selectedResults, - Collection<RSufiResultPath> indicatorsResults, Collection<RSufiResultPath> mapResults, - Collection<RSufiResultPath> publishDataResults) throws CoserBusinessException { + Collection<RSufiResultPath> indicatorsResults, Collection<RSufiResultPath> mapResults, + Collection<RSufiResultPath> publishDataResults) throws CoserBusinessException { // TODO echatellier 20110117 revoir ce code @@ -546,9 +537,9 @@ public class WebService { /** * Met à jour les fichiers de propriétés des resultats (maps, dataSource) * and check for duplicated couple (zoneid/resulttype (map) upload). - * + * * @param selectedResults result id to check - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected void checkDataCollision(Collection<RSufiResultPath> selectedResults) throws CoserBusinessException { @@ -563,7 +554,7 @@ public class WebService { String resultZoneTypeId = rsufiResult.getZone() + String.valueOf(rsufiResult.isMapsResult()); if (resultZoneTypeIds.contains(resultZoneTypeId)) { throw new CoserBusinessException(t("coser.business.resultupload.duplicatedresult", - project.getName(), selection.getName(), rsufiResult.getName(), rsufiResult.getZone())); + project.getName(), selection.getName(), rsufiResult.getName(), rsufiResult.getZone())); } else { resultZoneTypeIds.add(resultZoneTypeId); } @@ -574,18 +565,19 @@ public class WebService { * Aggrege plusieurs file filters. */ protected static class MultipleFileFilter implements FileFilter { + protected Collection<FileFilter> fileFilters = new ArrayList<FileFilter>(); public void add(FileFilter f) { fileFilters.add(f); } - + /* * @see java.io.FileFilter#accept(java.io.File) */ @Override public boolean accept(File pathname) { - + boolean result = false; Iterator<FileFilter> it = fileFilters.iterator(); while (it.hasNext() && !result) { @@ -597,18 +589,22 @@ public class WebService { /** * Filter pour un resultat donné. - * + * * Attention, implémentation que ne doit fonctionner que avec ZipUtil * car meme si on refuse en répertoire, il redemande quand même * les fils (et il faut qu'il les demande) */ protected class OneResultFileFilter implements FileFilter { + protected File projectsDirectory; /** Doit etre un project chargé avec nom de fichier originaux. */ protected Project project; + protected Selection selection; + protected RSufiResult rsufi; + protected boolean exportWithData; public OneResultFileFilter(File projectsDirectory, Project project, Selection selection, RSufiResult rsufi, boolean exportWithData) { @@ -649,10 +645,10 @@ public class WebService { // - sauf le répertoire result // - ou le resultat entierrement result = (currentPathName.startsWith(projectPath) - && !currentPathName.startsWith(selectionsPath)) - || (currentPathName.startsWith(selectionPath) - && !currentPathName.startsWith(resultsPath)) - || currentPathName.startsWith(resultPath); + && !currentPathName.startsWith(selectionsPath)) + || (currentPathName.startsWith(selectionPath) + && !currentPathName.startsWith(resultsPath)) + || currentPathName.startsWith(resultPath); // cas ou les données sources ne doivent pas être exporter // condition sur les noms de fichiers ? @@ -685,7 +681,7 @@ public class WebService { /** * Traite le fichier uploade par l'application client et l'enregistre * dans le stockage coté web. - * + * * Le nouveau fichier uploadé est mergé avec l'ancien, c'est à dire: * <ul> * <li>dezipage dans un fichier temporaire @@ -694,15 +690,15 @@ public class WebService { * <li>suppression des selections vides * <li>suppression des projets vides * <li>copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire - * mais seulement pour ceux des zones concernés (partie difficile) + * mais seulement pour ceux des zones concernés (partie difficile) * </ul> - * + * * TODO chatellier 20110125 l'algorithme n'est pour l'instant pas performant * et contient pas mal de code dupliqué, mais pour la v1.0 ca ira. - * - * @param login user login + * + * @param login user login * @param archiveFile uploaded file - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void registerNewUploadedResults(String login, File archiveFile) throws CoserBusinessException { @@ -765,16 +761,16 @@ public class WebService { for (Map.Entry<String, String> noMapsResultZoneId : noMapsResultZoneIds.entrySet()) { if (mapsResults.containsValue(noMapsResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.deleted", - getZoneFullName(noMapsResultZoneId.getKey()), - noMapsResultZoneId.getValue()) + "\n"); + getZoneFullName(noMapsResultZoneId.getKey()), + noMapsResultZoneId.getValue()) + "\n"); count++; } } for (Map.Entry<String, String> mapsResultZoneId : mapsResultZoneIds.entrySet()) { if (!mapsResults.containsValue(mapsResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.added", - getZoneFullName(mapsResultZoneId.getKey()), - mapsResultZoneId.getValue()) + "\n"); + getZoneFullName(mapsResultZoneId.getKey()), + mapsResultZoneId.getValue()) + "\n"); count++; } } @@ -784,17 +780,17 @@ public class WebService { for (Map.Entry<String, String> noIndicatorsResultZoneId : noIndicatorsResultZoneIds.entrySet()) { if (indicatorResults.containsValue(noIndicatorsResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.deleted", - getZoneFullName(noIndicatorsResultZoneId.getKey()), - noIndicatorsResultZoneId.getValue()) + "\n"); + getZoneFullName(noIndicatorsResultZoneId.getKey()), + noIndicatorsResultZoneId.getValue()) + "\n"); count++; } - + } for (Map.Entry<String, String> indicatorsResultZoneId : indicatorsResultZoneIds.entrySet()) { if (!indicatorResults.containsValue(indicatorsResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.added", - getZoneFullName(indicatorsResultZoneId.getKey()), - indicatorsResultZoneId.getValue()) + "\n"); + getZoneFullName(indicatorsResultZoneId.getKey()), + indicatorsResultZoneId.getValue()) + "\n"); count++; } } @@ -804,17 +800,17 @@ public class WebService { for (Map.Entry<String, String> noDataResultZoneId : noDataResultZoneIds.entrySet()) { if (dataResults.containsValue(noDataResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.deleted", - getZoneFullName(noDataResultZoneId.getKey()), - noDataResultZoneId.getValue()) + "\n"); + getZoneFullName(noDataResultZoneId.getKey()), + noDataResultZoneId.getValue()) + "\n"); count++; } - + } for (Map.Entry<String, String> dataResultZoneId : dataResultZoneIds.entrySet()) { if (!dataResults.containsValue(dataResultZoneId.getValue())) { content.append(" - " + t("coser.business.notificationmail.added", - getZoneFullName(dataResultZoneId.getKey()), - dataResultZoneId.getValue()) + "\n"); + getZoneFullName(dataResultZoneId.getKey()), + dataResultZoneId.getValue()) + "\n"); count++; } } @@ -834,14 +830,14 @@ public class WebService { * N'utilise pas la methode de commons-fileutils, car lorsqu'un répertoire * est refusé, il ne descend pas dans les sous répertoire alors que dans * notre cas il le faut. - * - * @param srcDir source directory to copy - * @param destDir destination directory + * + * @param srcDir source directory to copy + * @param destDir destination directory * @param indicatorsFileFilter file filter for file to copy - * @throws IOException + * @throws IOException */ protected void customCopyDirectory(File srcDir, - File destDir, FileFilter indicatorsFileFilter) throws IOException { + File destDir, FileFilter indicatorsFileFilter) throws IOException { List<File> files = FileUtil.getFilteredElements(srcDir, null, true); for (File file : files) { if (indicatorsFileFilter.accept(file)) { @@ -850,8 +846,7 @@ public class WebService { File destFile = new File(destDir, path); if (file.isDirectory()) { destFile.mkdirs(); - } - else { + } else { FileUtils.copyFile(file, destFile); } } @@ -860,13 +855,13 @@ public class WebService { /** * Met à jour certaines proprietes apres la mise à jour des données. - * - * @throws CoserBusinessException + * + * @throws CoserBusinessException */ protected void updateDataProperties() throws CoserBusinessException { File webProperties = config.getWebPropertiesFile(); - + Properties props = new Properties(); InputStream iStream = null; OutputStream oStream = null; @@ -875,14 +870,13 @@ public class WebService { iStream = new FileInputStream(webProperties); props.load(iStream); } - + props.setProperty("updateDate", String.valueOf(new Date().getTime())); oStream = new FileOutputStream(webProperties); props.store(oStream, "Update data"); } catch (IOException ex) { throw new CoserBusinessException("Can't save properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(iStream); IOUtils.closeQuietly(oStream); } @@ -890,11 +884,11 @@ public class WebService { /** * Retourne la date de dernière mise à jour des données du site web. - * + * * Retourne une date bidon, si pas de dernière mise à jour. - * + * * @return last data update date - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Date getLastDataUpdateDate() throws CoserBusinessException { Date dataUpdateDate = null; @@ -906,44 +900,43 @@ public class WebService { try { stream = new FileInputStream(webProperties); props.load(stream); - + if (props.containsKey("updateDate")) { String date = props.getProperty("updateDate"); long time = Long.parseLong(date); dataUpdateDate = new Date(time); } - + } catch (IOException ex) { throw new CoserBusinessException("Can't read properties file", ex); - } - finally { + } finally { IOUtils.closeQuietly(stream); } } - + if (dataUpdateDate == null) { dataUpdateDate = new Date(0); } - + return dataUpdateDate; } /** * Recupere dans un repertoire donné, les zoneid des resultat avec * pour chaque id, le nom du projet associé. - * + * * Les boolean sont des grands {@code Boolean} car si la valeur * est {@code null}, on ne tient pas compte du critere lors de la recherche. - * - * @param scanDirectory le repertoire a scanner + * + * @param scanDirectory le repertoire a scanner * @param indicatorResults if true get indicator results - * @param mapResults if true get map results - * @param dataResults if true get data allowed result + * @param mapResults if true get map results + * @param dataResults if true get data allowed result * @return une map de resultid/nom visuel des projets - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Map<String, String> getZonesIds(File scanDirectory, Boolean indicatorResults, - Boolean mapResults, Boolean dataResults) throws CoserBusinessException { + Boolean mapResults, Boolean dataResults) throws CoserBusinessException { Map<String, String> resultIds = new HashMap<String, String>(); File[] projectFiles = scanDirectory.listFiles(); @@ -965,16 +958,16 @@ public class WebService { RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); // return result depending on result type - if ( ( indicatorResults == null || rsufiResult.isIndicatorsResult() == indicatorResults ) - && - ( mapResults == null || rsufiResult.isMapsResult() == mapResults ) - && - ( dataResults == null || rsufiResult.isDataAllowed() == dataResults)) { + if ((indicatorResults == null || rsufiResult.isIndicatorsResult() == indicatorResults) + && + (mapResults == null || rsufiResult.isMapsResult() == mapResults) + && + (dataResults == null || rsufiResult.isDataAllowed() == dataResults)) { String resultResultId = rsufiResult.getZone(); if (StringUtils.isNotBlank(resultResultId)) { String resultPath = projectFile.getName() + "/" + - selectionFile.getName() + "/" + - resultFile.getName(); + selectionFile.getName() + "/" + + resultFile.getName(); resultIds.put(resultResultId, resultPath); } } @@ -995,11 +988,11 @@ public class WebService { * Retourne un file filter qui ne copiera que les dossiers resultat * correspondant au type demandé. Pour un resultat, le filtre devra * egalement copier les dossiers projet et selection correspondants. - * + * * @param scanDirectory directory containing result to copy - * @param mapResults result type to get + * @param mapResults result type to get * @return aggragated file filter - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected FileFilter getCopyFileFilter(File scanDirectory, boolean mapResults) throws CoserBusinessException { @@ -1024,8 +1017,8 @@ public class WebService { RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); // return result depending on result type - if ( (mapResults && rsufiResult.isMapsResult()) || - (!mapResults && rsufiResult.isIndicatorsResult())) { + if ((mapResults && rsufiResult.isMapsResult()) || + (!mapResults && rsufiResult.isIndicatorsResult())) { Project p = new Project(projectFile.getName()); Selection s = new Selection(selectionFile.getName()); @@ -1050,13 +1043,13 @@ public class WebService { * Fait le menage dans le dossier courant des projets en supprimant * tout les resulat qui ont un result id present dans la liste * {@code newResultIds}. - * + * * Supprime egalement les selections qui n'ont plus de résultats et * les projets qui n'ont plus de selection. - * + * * @param projectsDirectory projectsDirectory - * @param newResultIds new ids - * @throws CoserBusinessException + * @param newResultIds new ids + * @throws CoserBusinessException */ protected void cleanCurrentProjectDirectory(File projectsDirectory, Collection<String> newResultIds) throws CoserBusinessException { @@ -1066,14 +1059,14 @@ public class WebService { for (File projectFile : projectFiles) { if (projectFile.isDirectory()) { int projectSelectionCount = 0; - + File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY); File[] selectionFiles = selectionsDirectory.listFiles(); if (selectionFiles != null) { for (File selectionFile : selectionFiles) { if (selectionFile.isDirectory()) { int selectionResultCount = 0; - + File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY); File[] resultFiles = resultsDirectory.listFiles(); if (resultFiles != null) { @@ -1117,9 +1110,9 @@ public class WebService { /** * Envoi un mail de notification apres la publication des resultat à la * liste des adresses email renseignées dans la configuration. - * - * @param login user login - * @param count updated data count + * + * @param login user login + * @param count updated data count * @param detail body mail detail */ protected void sendNewResultNotifications(String login, int count, String detail) { @@ -1146,9 +1139,9 @@ public class WebService { /** * Get facades list (as facadeid/facadename). - * + * * @return facades map - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getFacades() throws CoserBusinessException { Map<String, String> facades = new LinkedHashMap<String, String>(); @@ -1166,16 +1159,16 @@ public class WebService { /** * Pour une zone principale, recupere la liste des couples sous-zone / * campagne qui sont disponible dans cette zone principale. - * - * @param facade facade (le nom de la facade principale) (can be {@code null} : don't filter on facade) + * + * @param facade facade (le nom de la facade principale) (can be {@code null} : don't filter on facade) * @param onlyWithSource retourn zone liste with available source data - * @param forMap look in map directory + * @param forMap look in map directory * @return couple subzoneid/sub - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getZoneForFacade(String facade, boolean onlyWithSource, boolean forMap) throws CoserBusinessException { Map<String, String> zonesForFacade = new HashMap<String, String>(); - + // get subzone for main zone Collection<String> subZones = new ArrayList<String>(); Iterator<String[]> itZone = getZonesMap().iterator(true); @@ -1190,14 +1183,13 @@ public class WebService { File projectsDirectory = null; if (forMap) { projectsDirectory = config.getWebMapsProjectsDirectory(); - } - else { + } else { projectsDirectory = config.getWebIndicatorsProjectsDirectory(); } // get survey names in subZones collection File[] projectFiles = projectsDirectory.listFiles(); - + // project iteration if (projectFiles != null) { for (File projectFile : projectFiles) { @@ -1211,13 +1203,13 @@ public class WebService { if (selectionFile.isDirectory()) { File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY); File[] resultFiles = resultsDirectory.listFiles(); - + // result iteration if (resultFiles != null) { for (File resultFile : resultFiles) { if (resultFile.isDirectory()) { RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); - + if (!onlyWithSource || rsufiResult.isDataAllowed()) { String resultZoneId = rsufiResult.getZone(); if (subZones.contains(resultZoneId)) { @@ -1227,7 +1219,7 @@ public class WebService { int zoneIndex = getZonesMap().indexOf(zoneid); String[] zoneData = getZonesMap().get(zoneIndex); String zoneName = zoneData[3] + " - " + zoneData[4] + " - " + zoneData[5]; - + zonesForFacade.put(zoneid, zoneName); } } @@ -1248,11 +1240,11 @@ public class WebService { * Retourne les zones disponible par facade. * * @return couple facadeid/list<zoneid> - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, List<String>> getZoneByFacade() throws CoserBusinessException { Map<String, List<String>> zonesByFacade = new HashMap<String, List<String>>(); - + // get subzone for main zone Iterator<String[]> itZone = getZonesMap().iterator(true); while (itZone.hasNext()) { @@ -1273,9 +1265,9 @@ public class WebService { /** * Recupere la liste des cartes pour chaque id de zone sous forme de Map. - * + * * @return zone images map - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getZonePictures() throws CoserBusinessException { Map<String, String> result = new HashMap<String, String>(); @@ -1289,13 +1281,13 @@ public class WebService { return result; } - + /** * Recupere la liste des meta info pour chaque id de zone sous forme de Map. - * + * * @param locale locale * @return zone meta info map - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getZoneMetaInfo(Locale locale) throws CoserBusinessException { Map<String, String> result = new HashMap<String, String>(); @@ -1318,11 +1310,11 @@ public class WebService { /** * Recuperer la liste des populations pour une zone donnée. - * - * @param zone zone id - * @return map species nom info>nom officiel + * + * @param zone zone id * @param forMap for map directory - * @throws CoserBusinessException + * @return map species nom info>nom officiel + * @throws CoserBusinessException */ public Map<String, String> getSpecies(String zone, boolean forMap) throws CoserBusinessException { return getSpecies(Collections.singleton(zone), forMap); @@ -1330,10 +1322,10 @@ public class WebService { /** * Recuperer la liste des populations pour un ensemble de zones donnée. - * - * @param zones zones ids - * @return map species nom info>nom officiel + * + * @param zones zones ids * @param forMap for map directory + * @return map species nom info>nom officiel * @throws CoserBusinessException */ public Map<String, String> getSpecies(Collection<String> zones, boolean forMap) throws CoserBusinessException { @@ -1343,8 +1335,7 @@ public class WebService { File projectsDirectory = null; if (forMap) { projectsDirectory = config.getWebMapsProjectsDirectory(); - } - else { + } else { projectsDirectory = config.getWebIndicatorsProjectsDirectory(); } @@ -1363,16 +1354,16 @@ public class WebService { if (selectionFile.isDirectory()) { File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY); File[] resultFiles = resultsDirectory.listFiles(); - + // result iteration if (resultFiles != null) { for (File resultFile : resultFiles) { if (resultFile.isDirectory()) { RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); - + // extraction des especes pour le résultat demandé if (rsufiResult.getZone() != null && zones.contains(rsufiResult.getZone())) { - + // load project (without data to get reftax data) Project project = projectService.openProject(projectFile.getName(), projectsDirectory); @@ -1388,34 +1379,34 @@ public class WebService { } } } - + return result; } /** * Recupere la liste de toutes les especes nom sci et nom off à partir * d'un resultat. - * - * @param project project + * + * @param project project * @param resultDirectory rsufi result directory - * @param rsufiResult rsufi result + * @param rsufiResult rsufi result * @return map with each species code/species name - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Map<String, String> getRsufiResultSpecies(Project project, File resultDirectory, RSufiResult rsufiResult) throws CoserBusinessException { Map<String, String> result = new HashMap<String, String>(); - + // load reftax in memory Map<String, String> speciesNames = new HashMap<String, String>(); Iterator<String[]> reftax = project.getRefTaxSpecies().iterator(true); while (reftax.hasNext()) { String[] tuple = reftax.next(); - + // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String speciesCode = tuple[3]; // nom + auteur (sans ajout de parenthese : important) String speciesName = tuple[4] + " " + tuple[5]; - + speciesNames.put(speciesCode, speciesName); } @@ -1443,12 +1434,12 @@ public class WebService { /** * Retourne les indicateurs calculés avec leurs traductions scientifique * pour la zone et l'especes souhaitées. - * - * @param zone zone id + * + * @param zone zone id * @param species especes (if {@code null} look for com indicators) - * @param locale locale + * @param locale locale * @return la liste des indicateurs - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getIndicators(String zone, String species, Locale locale) throws CoserBusinessException { Map<String, String> indicators = new TreeMap<String, String>(); @@ -1479,11 +1470,10 @@ public class WebService { if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) { Map<String, String> resultIndicators = null; - + if (species == null) { resultIndicators = getRsufiResultComIndicators(resultFile, rsufiResult, locale); - } - else { + } else { resultIndicators = getRsufiResultPopIndicators(resultFile, rsufiResult, species, locale); } indicators.putAll(resultIndicators); @@ -1503,14 +1493,15 @@ public class WebService { } // Pour extraction + /** * Retourne les indicateurs calculés avec leurs traductions scientifique * pour les zones souhaitées. Retournes les indicateurs de populations * de de communauté à la fois. - * - * @param zones zones id + * + * @param zones zones id * @param dataTypes data type - * @param locale locale + * @param locale locale * @return la liste des indicateurs * @throws CoserBusinessException * @since 1.4 @@ -1569,13 +1560,13 @@ public class WebService { /** * Recupere la liste de toutes les especes nom sci et nom off à partir * d'un resultat. - * + * * @param resultDirectory rsufi result directory - * @param rsufiResult result - * @param species to get indicator (can be {@code null} to not filter on species) - * @param locale locale + * @param rsufiResult result + * @param species to get indicator (can be {@code null} to not filter on species) + * @param locale locale * @return indicator for species - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Map<String, String> getRsufiResultPopIndicators(File resultDirectory, RSufiResult rsufiResult, String species, Locale locale) throws CoserBusinessException { @@ -1590,7 +1581,7 @@ public class WebService { Iterator<String[]> estPopIndIterator = dataStorage.iterator(true); while (estPopIndIterator.hasNext()) { String[] tuple = estPopIndIterator.next(); - + String specyCode = tuple[3]; if (species == null || specyCode.equals(species)) { @@ -1605,16 +1596,16 @@ public class WebService { return result; } - + /** * Recupere la liste de toutes les especes nom sci et nom off à partir * d'un resultat. - * + * * @param resultDirectory rsufi result directory - * @param rsufiResult result - * @param locale locale + * @param rsufiResult result + * @param locale locale * @return indicator for species - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Map<String, String> getRsufiResultComIndicators(File resultDirectory, RSufiResult rsufiResult, Locale locale) throws CoserBusinessException { @@ -1643,12 +1634,12 @@ public class WebService { /** * Retourne les listes sur lequel l'indicateur fournit a ete calculé. - * - * @param zone zone id + * + * @param zone zone id * @param indicator indicator - * @param locale locale + * @param locale locale * @return la liste des indicateurs - * @throws CoserBusinessException + * @throws CoserBusinessException */ public Map<String, String> getIndicatorLists(String zone, String indicator, Locale locale) throws CoserBusinessException { // linked hash map (doit respecter l'ordre d'insertion) @@ -1682,9 +1673,9 @@ public class WebService { // le fichier contenant le code type espece (utile // pour les traductions des list d'indicateur) File codeTypeEspecesFile = new File(projectFile, CoserConstants.Category.TYPE_ESPECES.getStorageFileName()); - + Map<String, String> resultIndicators = getRsufiResultComIndicatorLists(resultFile, - rsufiResult, codeTypeEspecesFile, indicator, locale); + rsufiResult, codeTypeEspecesFile, indicator, locale); indicators.putAll(resultIndicators); break; } @@ -1704,16 +1695,16 @@ public class WebService { /** * Recupere les nom des listes sur lesquelle ont été calculé les * indicateurs avec leurs traductions. - * + * * @param resultDirectory rsufi result directory - * @param rsufiResult result - * @param indicator indicator - * @param locale locale + * @param rsufiResult result + * @param indicator indicator + * @param locale locale * @return indicator for species - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected Map<String, String> getRsufiResultComIndicatorLists(File resultDirectory, - RSufiResult rsufiResult, File codeTypeEspecesFile, String indicator, Locale locale) throws CoserBusinessException { + RSufiResult rsufiResult, File codeTypeEspecesFile, String indicator, Locale locale) throws CoserBusinessException { // linked hash map (doit respecter l'ordre d'insertion) Map<String, String> result = new LinkedHashMap<String, String>(); @@ -1754,8 +1745,7 @@ public class WebService { } else { translation = "All List " + list.charAt(1); } - } - else { + } else { // ajout de la traduction du nom de liste plus le numéro if (locale != null && "fr".equals(locale.getLanguage())) { translation = tupleType[0] + " Liste " + list.charAt(1); @@ -1778,14 +1768,14 @@ public class WebService { /** * Retourne les indicateurs calculés avec leurs traductions scientifique * pour la zone et l'especes souhaitées. - * - * @param zone zone id - * @param species especes (if {@code null} look for com indicators + * + * @param zone zone id + * @param species especes (if {@code null} look for com indicators * @param indicator indicator - * @param list indicator's list (if {@code null} look for pop indicators or no list selected - * @param locale locale + * @param list indicator's list (if {@code null} look for pop indicators or no list selected + * @param locale locale * @return la liste des indicateurs - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getChart(String zone, String species, String indicator, String list, Locale locale) throws CoserBusinessException { File result = null; @@ -1826,17 +1816,16 @@ public class WebService { // le fichier contenant le code type espece (utile // pour les traductions des list d'indicateur) File codeTypeEspecesFile = new File(projectFile, CoserConstants.Category.TYPE_ESPECES.getStorageFileName()); - + // title = surveyName - indicateur result = publicationService.getRsufiResultComChart(project, resultFile, - rsufiResult, codeTypeEspecesFile, indicator, list, - zoneDisplayName, indicatorName, unit, locale); - } - else { + rsufiResult, codeTypeEspecesFile, indicator, list, + zoneDisplayName, indicatorName, unit, locale); + } else { // title = surveyName - indicateur - species result = publicationService.getRsufiResultPopChart(project, resultFile, - rsufiResult, species, indicator, zoneDisplayName, indicatorName, - unit, locale); + rsufiResult, species, indicator, zoneDisplayName, indicatorName, + unit, locale); } break; } @@ -1852,18 +1841,18 @@ public class WebService { return result; } - + /** * Retourne les indicateurs calculés avec leurs traductions scientifique * pour la zone et l'especes souhaitées. - * - * @param zone zone id - * @param species especes (if {@code null} look for com indicators + * + * @param zone zone id + * @param species especes (if {@code null} look for com indicators * @param indicator indicator - * @param list indicator's list (if {@code null} look for pop indicators or no list selected - * @param locale locale + * @param list indicator's list (if {@code null} look for pop indicators or no list selected + * @param locale locale * @return la liste des indicateurs - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getChartData(String zone, String species, String indicator, String list, Locale locale) throws CoserBusinessException { File result = null; @@ -1907,25 +1896,25 @@ public class WebService { return result; } - + /** * Generate chart data (as csv for population and as zip for community). - * - * @param projectsDirectory projects storage directory - * @param projectDirectory current project directory + * + * @param projectsDirectory projects storage directory + * @param projectDirectory current project directory * @param selectionDirectory selection directory - * @param resultDirectory rsufi result directory - * @param rSufiResult rsufi result - * @param species species (can be null for community) - * @param indicator indicator - * @param list indicator's list (if {@code null} look for pop indicators or no list selected - * @param locale locale + * @param resultDirectory rsufi result directory + * @param rSufiResult rsufi result + * @param species species (can be null for community) + * @param indicator indicator + * @param list indicator's list (if {@code null} look for pop indicators or no list selected + * @param locale locale * @return generated file (auto delete when jvm shutdown) - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected File getChartDataFile(File projectsDirectory, File projectDirectory, File selectionDirectory, - File resultDirectory, RSufiResult rSufiResult, String species, String indicator, String list, - Locale locale) throws CoserBusinessException { + File resultDirectory, RSufiResult rSufiResult, String species, String indicator, String list, + Locale locale) throws CoserBusinessException { File result = null; @@ -1933,11 +1922,11 @@ public class WebService { // cas community (zip avec fichier meta) if (species == null) { File tempDir = FileUtil.createTempDirectory("coser-chartdata-", "-tmp"); - + String surveyName = projectService.getProjectSurveyName(resultDirectory, rSufiResult); File baseDir = new File(tempDir, surveyName); baseDir.mkdirs(); - + File csvFile = publicationService.getRsufiResultComChartData(resultDirectory, rSufiResult, indicator, list); File csvFileCopied = new File(baseDir, indicator + ".csv"); FileUtils.copyFile(csvFile, csvFileCopied); @@ -1959,8 +1948,7 @@ public class WebService { // clean directory FileUtils.deleteDirectory(tempDir); - } - else { + } else { // cas pop, fichier csv brut result = publicationService.getRsufiResultPopChartData(resultDirectory, rSufiResult, species, indicator); } @@ -1968,24 +1956,24 @@ public class WebService { } catch (IOException ex) { throw new CoserBusinessException("Can't generate chart data file", ex); } - + return result; } /** * Recupere le fichier image de la carte demandées en fonction de la zone * et de l'espece. - * + * * Retourne également la repartition globale sur la zone si le nom de * l'espece est {@code null}. - * - * @param zone zone (zoneid) + * + * @param zone zone (zoneid) * @param species species or (null to get <survey>_Repartition-stations.png map file) * @return map file - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getMapFile(String zone, String species) throws CoserBusinessException { - + File result = null; // parcours des resultats disponibles @@ -2018,8 +2006,7 @@ public class WebService { String mapName = null; if (species != null) { mapName = surveyName + "_" + species.toUpperCase() + ".png"; - } - else { + } else { mapName = surveyName + "_Repartition-stations.png"; } @@ -2041,20 +2028,20 @@ public class WebService { /** * Genere un fichier zip des sources d'un projet. - * + * * Contient: * <ul> * <li>les 4 fichiers apres sélection * <li>un fichier de décharge (pdf) * </ul> - * - * @param zone zone (zoneid-surveyname) + * + * @param zone zone (zoneid-surveyname) * @param locale locale * @return zip source file (auto delete when jvm shutdown) - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File getSourceZip(String zone, Locale locale) throws CoserBusinessException { - + File result = null; // parcours des resultats disponibles @@ -2084,10 +2071,10 @@ public class WebService { // load project (with data to get original file names) Project project = projectService.openProject(projectFile.getName(), projectsDirectory); - + // load selection data (to do data export rsufi) Selection selection = project.getSelections().get(selectionFile.getName()); - + // be sure that data are available for this project // or it will fail projectService.loadSelectionData(projectsDirectory, project, selection); @@ -2103,25 +2090,25 @@ public class WebService { } } } - + return result; } /** * Generate zip for selection. - * + * * Be sure that data are available for this project. - * - * @param project project - * @param selection selection with loaded data + * + * @param project project + * @param selection selection with loaded data * @param resultDirectory rsufi result directory - * @param rSufiResult rsufi result - * @param locale generated pdf locale + * @param rSufiResult rsufi result + * @param locale generated pdf locale * @return generated zip file (auto delete when jvm shutdown) - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected File generateSourceZip(Project project, Selection selection, File resultDirectory, - RSufiResult rSufiResult, Locale locale) throws CoserBusinessException { + RSufiResult rSufiResult, Locale locale) throws CoserBusinessException { if (!rSufiResult.isDataAllowed()) { throw new CoserBusinessException("Can't download source for non allowed result"); @@ -2170,13 +2157,13 @@ public class WebService { /** * Genere le PDF dynamique de decharge à partir du template freemarker. - * - * @param disclamerPdf pdf file to generate + * + * @param disclamerPdf pdf file to generate * @param resultDirectory rsufi result directory - * @param rSufiResult rsufi result - * @param locale generated pdf locale + * @param rSufiResult rsufi result + * @param locale generated pdf locale * @return le fichier généré - * @throws CoserBusinessException + * @throws CoserBusinessException */ public File generateDechargePDF(File disclamerPdf, File resultDirectory, RSufiResult rSufiResult, Locale locale) throws CoserBusinessException { @@ -2187,7 +2174,7 @@ public class WebService { try { // get some info to put into pdf Date updateDate = getLastDataUpdateDate(); - + // il se peut que pour l'extraction un fichier de décharge ne soit // pas généré pour une campagne en particulier // on passe un nom vide a freemarker @@ -2235,18 +2222,18 @@ public class WebService { /** * Genere le fichier PDF d'information sur les espèces incluses dans les * calculs des indicateurs de communautés, à jointe à chaque téléchargement. - * - * @param project project - * @param selection selection + * + * @param project project + * @param selection selection * @param resultDirectory result directory - * @param rsufiResult rsufi result - * @param indicator indicator - * @param locale locale + * @param rsufiResult rsufi result + * @param indicator indicator + * @param locale locale * @return generated pdf file - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected File generateMetaFilePDF(Project project, Selection selection, File resultDirectory, - RSufiResult rsufiResult, String indicator, Locale locale) throws CoserBusinessException { + RSufiResult rsufiResult, String indicator, Locale locale) throws CoserBusinessException { File result = null; @@ -2256,7 +2243,7 @@ public class WebService { Map<String, Integer> refTaxSpeciesNumSys = new HashMap<String, Integer>(); Map<String, String> refTaxSpeciesName = new HashMap<String, String>(); Iterator<String[]> itReftax = project.getRefTaxSpecies().iterator(true); - while (itReftax.hasNext() ) { + while (itReftax.hasNext()) { String[] tuple = itReftax.next(); // "C_Perm","NumSys","NivSys","C_VALIDE","L_VALIDE","AA_VALIDE","C_TxP\u00E8re","Taxa" String speciesCode = tuple[3]; @@ -2270,7 +2257,7 @@ public class WebService { // TODO little hack for italic species refTaxSpeciesName.put(speciesCode, "<span style='font-style:italic'>" + speciesSciName + "</span> " + speciesAuthor); } - + // code type / especes Map<String, Integer[]> specyTypes = new HashMap<String, Integer[]>(); Iterator<String[]> itTypeSpecies = project.getTypeEspeces().iterator(true); @@ -2326,20 +2313,17 @@ public class WebService { List<String> selectionSpeciesList = null; if ("1".equals(listNumber)) { selectionSpeciesList = selection.getSelectedSpecies(); - } - else if ("2".equals(listNumber)) { + } else if ("2".equals(listNumber)) { selectionSpeciesList = selection.getSelectedSpeciesOccDens(); - } - else if ("3".equals(listNumber)) { + } else if ("3".equals(listNumber)) { selectionSpeciesList = selection.getSelectedSpeciesSizeAllYear(); - } - else if ("4".equals(listNumber)) { + } else if ("4".equals(listNumber)) { selectionSpeciesList = selection.getSelectedSpeciesMaturity(); } - + if (selectionSpeciesList != null) { SortedSet<String> speciesList = new TreeSet<String>(); - + for (String speciesCode : selectionSpeciesList) { // get species full name String speciesName = refTaxSpeciesName.get(speciesCode); @@ -2349,7 +2333,7 @@ public class WebService { for (Map.Entry<String, Integer[]> speciesTypeEntry : specyTypes.entrySet()) { String speciesTypeCode = speciesTypeEntry.getKey(); Integer[] bound = speciesTypeEntry.getValue(); - + if (speciesNumSys >= bound[0] && speciesNumSys <= bound[1]) { speciesName = "(" + speciesTypeCode + ") " + speciesName; break; @@ -2360,8 +2344,7 @@ public class WebService { speciesList.add(speciesName); } speciesMap.put(listNumber, speciesList); - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Can't get species list for list id " + listNumber); } @@ -2411,9 +2394,9 @@ public class WebService { /** * Recupere dans le repertoire des projets d'indicateur les resultats * disponible par zone (il ne peut y en avoir qu'un par zone). - * - * @return une map avec par zone, son resultat associé (ProjectName/SelectionName) - * @throws CoserBusinessException + * + * @return une map avec par zone, son resultat associé (ProjectName/SelectionName) + * @throws CoserBusinessException */ public Map<String, String> getIndicatorsResultsPerZone() throws CoserBusinessException { return getResultsPerZone(config.getWebIndicatorsProjectsDirectory()); @@ -2422,9 +2405,9 @@ public class WebService { /** * Recupere dans le repertoire des projets d'indicateur les resultats * disponible par zone (il ne peut y en avoir qu'un par zone). - * - * @return une map avec par zone, son resultat associé (ProjectName/SelectionName) - * @throws CoserBusinessException + * + * @return une map avec par zone, son resultat associé (ProjectName/SelectionName) + * @throws CoserBusinessException */ public Map<String, String> getMapsResultsPerZone() throws CoserBusinessException { return getResultsPerZone(config.getWebMapsProjectsDirectory()); @@ -2435,8 +2418,8 @@ public class WebService { * disponible par zone (il ne peut y en avoir qu'un par zone). * * @param scanDirectory le repertoire a scanner - * @return une map avec par zone, son resultat associé (ProjectName/SelectionName/RSUfiName) - * @throws CoserBusinessException + * @return une map avec par zone, son resultat associé (ProjectName/SelectionName/RSUfiName) + * @throws CoserBusinessException */ protected Map<String, String> getResultsPerZone(File scanDirectory) throws CoserBusinessException { @@ -2460,7 +2443,7 @@ public class WebService { RSufiResult rsufiResult = projectService.getRSufiResult(resultFile); String resultResultId = rsufiResult.getZone(); String name = projectFile.getName() + "/" + selectionFile.getName() - + "/" + resultFile.getName(); + + "/" + resultFile.getName(); resultIds.put(resultResultId, name); } } @@ -2478,22 +2461,24 @@ public class WebService { /** * Supprime des résultats par leur identifiant de zone de ratachement (car * un seul resultat par zone). - * + * * Utilisé par l'interface d'admin. + * * @param deleteZoneId - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void deleteIndicatorsResult(List<String> deleteZoneId) throws CoserBusinessException { cleanCurrentProjectDirectory(config.getWebIndicatorsProjectsDirectory(), deleteZoneId); } - + /** * Supprime des résultats par leur identifiant de zone de ratachement (car * un seul resultat par zone). - * + * * Utilisé par l'interface d'admin. + * * @param deleteZoneId - * @throws CoserBusinessException + * @throws CoserBusinessException */ public void deleteMapsResult(List<String> deleteZoneId) throws CoserBusinessException { cleanCurrentProjectDirectory(config.getWebMapsProjectsDirectory(), deleteZoneId); @@ -2502,12 +2487,12 @@ public class WebService { /** * Extrait de toutes les données les informations demandées restreintes * sur certaines zone, certaines espèces et certains indicateurs. - * + * * Ajout en plus dans le zip les cartes, les sources... suivant les * types selectionnés. - * - * @param selectZones zones - * @param selectTypes types + * + * @param selectZones zones + * @param selectTypes types * @param selectSpecies species * @param comIndicators indicators * @param popIndicators indicators @@ -2515,7 +2500,7 @@ public class WebService { * @since 1.4 */ public File extractData(List<String> zones, List<DataType> types, List<String> species, - List<String> comIndicators, List<String> popIndicators, Locale locale) throws CoserBusinessException { + List<String> comIndicators, List<String> popIndicators, Locale locale) throws CoserBusinessException { File resultZip = null; File tempDir = null; @@ -2587,8 +2572,8 @@ public class WebService { /** * Extrait les cartes. - * - * @param zones zones (zoneid) + * + * @param zones zones (zoneid) * @param species species * @return map file (zone/speciesname/mapfile) * @throws CoserBusinessException @@ -2623,7 +2608,7 @@ public class WebService { // extraction des especes pour le résultat demandé if (rsufiResult.isMapsResult() && zones.contains(rsufiResult.getZone())) { - + // load project (to get user display species name) Project project = projectService.openProject(projectFile.getName(), projectsDirectory); @@ -2652,23 +2637,23 @@ public class WebService { return mapForZoneAndSpecies; } - + /** * Genere un fichier zip des sources d'un projet. - * + * * Contient: * <ul> * <li>les 4 fichiers apres sélection * </ul> - * - * @param zone zone (zoneid-surveyname) + * + * @param zone zone (zoneid-surveyname) * @param locale locale * @return zip source file (auto delete when jvm shutdown) * @throws CoserBusinessException * @since 1.4 */ protected File extractSource(Collection<String> zones, File directory) throws CoserBusinessException { - + File result = null; // parcours des resultats disponibles @@ -2721,24 +2706,24 @@ public class WebService { } } } - + return result; } - + /** * Retourne les indicateurs calculés avec leurs traductions scientifique * pour la zone et l'especes souhaitées. - * - * @param zone zone id - * @param species especes (if {@code null} look for com indicators - * @param comIndicator comIndicator + * + * @param zone zone id + * @param species especes (if {@code null} look for com indicators + * @param comIndicator comIndicator * @param popIndicators popIndicators - * @param locale locale + * @param locale locale * @return la liste des indicateurs (zone, speciesname, [graphfile, graphdata]) - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected MultiKeyMap extractCharts(Collection<String> zones, Collection<String> species, - Collection<String> comIndicators, Collection<String> popIndicators, Locale locale) throws CoserBusinessException { + Collection<String> comIndicators, Collection<String> popIndicators, Locale locale) throws CoserBusinessException { MultiKeyMap chartFileAndDatas = new MultiKeyMap(); @@ -2782,8 +2767,8 @@ public class WebService { if (CollectionUtils.isNotEmpty(comIndicators)) { Map<String, Object[]> chartFileAndDataCom = publicationService.getRsufiResultComCharts(project, - resultFile, rsufiResult, codeTypeEspecesFile, comIndicators, - zoneDisplayName, getIndicatorsMap(), locale, 650, 430); + resultFile, rsufiResult, codeTypeEspecesFile, comIndicators, + zoneDisplayName, getIndicatorsMap(), locale, 650, 430); // put in multimap as zone,speciesname, data for (Entry<String, Object[]> entry : chartFileAndDataCom.entrySet()) { chartFileAndDatas.put(zone, entry.getKey(), entry.getValue()); @@ -2792,8 +2777,8 @@ public class WebService { if (CollectionUtils.isNotEmpty(popIndicators)) { Map<String, Object[]> chartFileAndDataPop = publicationService.getRsufiResultPopCharts(project, - resultFile, rsufiResult, species, popIndicators, - zoneDisplayName, getIndicatorsMap(), locale, 650, 430); + resultFile, rsufiResult, species, popIndicators, + zoneDisplayName, getIndicatorsMap(), locale, 650, 430); // put in multimap as zone,speciesname, data for (Entry<String, Object[]> entry : chartFileAndDataPop.entrySet()) { chartFileAndDatas.put(zone, entry.getKey(), entry.getValue()); @@ -2815,15 +2800,15 @@ public class WebService { /** * Generate pdf file filled with maps and charts. - * + * * @param directory directory to generate pdf to - * @param zones zones ids - * @param pdfMaps pdf maps (can be {@code null}) + * @param zones zones ids + * @param pdfMaps pdf maps (can be {@code null}) * @param pdfCharts pdf charts (can be {@code null}) - * @throws CoserBusinessException + * @throws CoserBusinessException */ protected void generateExtractPDF(File directory, List<String> zones, - MultiKeyMap pdfMaps, MultiKeyMap pdfCharts, Locale locale) throws CoserBusinessException { + MultiKeyMap pdfMaps, MultiKeyMap pdfCharts, Locale locale) throws CoserBusinessException { for (String zone : zones) { Collection<File> toDelete = new ArrayList<File>(); @@ -2832,17 +2817,17 @@ public class WebService { try { StringBuilder htmlContent = new StringBuilder(); htmlContent.append("<html><head>"); - htmlContent.append("<title>" + l(locale, "coser.business.extract.extracttitle")+ "</title>"); + htmlContent.append("<title>" + l(locale, "coser.business.extract.extracttitle") + "</title>"); htmlContent.append("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"); htmlContent.append("</head><body>"); - + if (pdfMaps != null) { - for (Entry<MultiKey, File> mapEntry : (Set<Entry<MultiKey, File>>)pdfMaps.entrySet()) { - String zoneId = (String)mapEntry.getKey().getKey(0); + for (Entry<MultiKey, File> mapEntry : (Set<Entry<MultiKey, File>>) pdfMaps.entrySet()) { + String zoneId = (String) mapEntry.getKey().getKey(0); if (zoneId.equals(zone)) { - String speciesName = (String)mapEntry.getKey().getKey(1); + String speciesName = (String) mapEntry.getKey().getKey(1); File file = mapEntry.getValue(); - + String zoneName = getZoneFullName(zoneId); htmlContent.append("<div style='page-break-after: always'>"); htmlContent.append("<p>" + zoneName + " - " + speciesName + "</p>"); @@ -2851,33 +2836,33 @@ public class WebService { } } } - + if (pdfCharts != null) { - for (Entry<MultiKey, Object[]> chartFileAndData : (Set<Entry<MultiKey, Object[]>>)pdfCharts.entrySet()) { - String zoneId = (String)chartFileAndData.getKey().getKey(0); + for (Entry<MultiKey, Object[]> chartFileAndData : (Set<Entry<MultiKey, Object[]>>) pdfCharts.entrySet()) { + String zoneId = (String) chartFileAndData.getKey().getKey(0); if (zoneId.equals(zone)) { - File chartFile = (File)chartFileAndData.getValue()[0]; - String content = (String)chartFileAndData.getValue()[1]; - + File chartFile = (File) chartFileAndData.getValue()[0]; + String content = (String) chartFileAndData.getValue()[1]; + htmlContent.append("<div style='page-break-after: always'>"); htmlContent.append("<img src='file://" + chartFile.getAbsolutePath() + "' />"); htmlContent.append("<br />"); htmlContent.append(l(locale, "coser.business.extract.extractdata") + " :"); htmlContent.append("<pre>").append(content).append("</pre>"); htmlContent.append("</div>"); - + // les graphiques ont été générés, a supprimer donc // a ne surtout pas faire avec les cartes !!! toDelete.add(chartFile); } } } - + htmlContent.append("</body></html>"); - + // get content as w3c document Document document = CoserUtils.parseDocument(htmlContent.toString()); - + // render template output as pdf // remove accents and strange characters from zone display name String zoneDisplay = getZoneFullName(zone); @@ -2885,12 +2870,12 @@ public class WebService { zoneDisplay = zoneDisplay.replaceAll("[^\\w- ]", "_"); File pdfFile = new File(directory, zoneDisplay + ".pdf"); os = new FileOutputStream(pdfFile); - + ITextRenderer renderer = new ITextRenderer(); renderer.setDocument(document, null); renderer.layout(); renderer.createPDF(os); - + os.close(); } catch (IOException ex) { throw new CoserBusinessException("Can't generate log pdf", ex); @@ -2898,7 +2883,7 @@ public class WebService { throw new CoserBusinessException("Can't generate log pdf", ex); } finally { IOUtils.closeQuietly(os); - + // delete file collection for (File file : toDelete) { file.delete(); diff --git a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java index 52f65c8..31d0d6e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java +++ b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java @@ -28,35 +28,31 @@ import java.util.Iterator; /** * Data storage utiliser pour manipuler dans l'application des * tableau de String, mais les stocker en back différement. - * + * * Cette interface respecte globalement l'interface d'une {@link java.util.List}. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ -public interface DataStorage extends Iterable<String[]> , Serializable { +public interface DataStorage extends Iterable<String[]>, Serializable { /** * Add new data into storage. - * + * * @param data data to add */ public void add(String[] data); - + /** * Add new data into storage. - * + * * @param index index to insert data - * @param data data to add + * @param data data to add */ public void add(int index, String[] data); /** * Get data at specified index. - * + * * @param index index * @return data at index */ @@ -64,23 +60,23 @@ public interface DataStorage extends Iterable<String[]> , Serializable { /** * Storage size. - * + * * @return storage size */ public int size(); /** * Replace data at specified index. - * + * * @param index index - * @param data data to set + * @param data data to set * @return previous value */ public String[] set(int index, String[] data); /** * Remove value at index. - * + * * @param index index * @return removed value */ @@ -88,7 +84,7 @@ public interface DataStorage extends Iterable<String[]> , Serializable { /** * Real storage index of lineNumber. - * + * * @param lineNumber line number * @return storage index */ @@ -97,7 +93,7 @@ public interface DataStorage extends Iterable<String[]> , Serializable { /** * Return a new iterator, but skip first iterator element (csv header) * by calling {@code next()} once. - * + * * @param skipFirstLine if {@code true}, skip first line * @return an Iterator. */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorageWalker.java b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorageWalker.java index 99605f0..d7bcdeb 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorageWalker.java +++ b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorageWalker.java @@ -24,10 +24,10 @@ package fr.ifremer.coser.storage; /** * To walk throw a data storage. - * <p/> + * * Created on 3/13/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public interface DataStorageWalker { diff --git a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorages.java b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorages.java index 9ae28f5..f7caa0c 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorages.java +++ b/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorages.java @@ -48,12 +48,12 @@ import static org.nuiton.i18n.I18n.t; /** * Useful methods around {@link DataStorage}. - * <p/> + * * TODO Should move here all others methods storage-centric from {@link CommonService}. - * <p/> + * * Created on 3/7/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class DataStorages { @@ -112,7 +112,7 @@ public class DataStorages { /** * Save a datastorage to a file and return its. - * <p/> + * * The file is temporary file (will be deleted at the end life of the jvm), * his name is generated then using the {@link File#createTempFile(String, String)} using the given {@code prefix} * and {@code suffix}. @@ -154,7 +154,7 @@ public class DataStorages { DataStorages.save(storage, writer); rawDataText = writer.toString(); writer.close(); - }catch (IOException ex) { + } catch (IOException ex) { throw new CoserTechnicalException("Could not close writer", ex); } finally { IOUtils.closeQuietly(writer); @@ -230,7 +230,7 @@ public class DataStorages { /** * Gets a sub storage of all matching rows for the given predicate on the given storage. - * <p/> + * * The result header is the given one in parameter {@code header}. * * @param storage storage to read @@ -251,6 +251,7 @@ public class DataStorages { result.add(header); walk(storage, predicate, new DataStorageWalker() { + @Override public void onRow(String... row) { result.add(row); diff --git a/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java b/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java index 4d07478..51ac48e 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java +++ b/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java @@ -30,19 +30,15 @@ import java.util.Map; /** * Stockage mémoire des String[] sous forme de String simple. - * + * * Beaucoup moins couteux en mémoire que les String[] sans pour antant * que le temps de parcours soit augmenté. - * + * * Les String[] sont encodés en CSV et stocké en mémoire en String. * Le code CSV a été repris de opencsv, mais sans les ioexception, reader et * writer inutiles ici. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class MemoryDataStorage implements DataStorage { @@ -50,12 +46,13 @@ public class MemoryDataStorage implements DataStorage { /** Stockage des données. */ protected List<String> listStorage; - + /** Stockage des numero de ligne (String) pour une recherche indexOf plus rapide. */ protected List<String> lineIndexStorage; + /** Cache pour les indexOf encore plus rapide (invalidé lors d'un delete). */ protected Map<String, Integer> lineIndexStorageCache; - + public MemoryDataStorage() { listStorage = new ArrayList<String>(); lineIndexStorage = new ArrayList<String>(); @@ -64,13 +61,14 @@ public class MemoryDataStorage implements DataStorage { /** * Iterator sur les donnnées. - * + * * {@link #lineIndexIterator} est aussi géré, seulement pour que le * remove reste cohérent. */ public class StringListIterator implements Iterator<String[]> { protected Iterator<String> listIterator; + protected Iterator<String> lineIndexIterator; public StringListIterator(Iterator<String> internalIterator, Iterator<String> lineIndexIterator) { @@ -91,10 +89,10 @@ public class MemoryDataStorage implements DataStorage { */ @Override public String[] next() { - + String nextString = listIterator.next(); String[] nextArray = stringToArray(nextString); - + lineIndexIterator.next(); return nextArray; @@ -121,7 +119,7 @@ public class MemoryDataStorage implements DataStorage { /** * Return a new iterator, but skip first iterator element (csv header) * by calling {@code next()} once. - * + * * @param skipFirstLine if {@code true}, skip first line * @return an Iterator. */ @@ -139,18 +137,18 @@ public class MemoryDataStorage implements DataStorage { */ @Override public void add(String[] data) { - + String stringData = arrayToString(data); listStorage.add(stringData); lineIndexStorage.add(data[0]); } - + /* * @see fr.ifremer.coser.storage.DataStorage#addData(java.lang.String[]) */ @Override public void add(int index, String[] data) { - + String stringData = arrayToString(data); listStorage.add(index, stringData); lineIndexStorage.add(index, data[0]); @@ -208,9 +206,11 @@ public class MemoryDataStorage implements DataStorage { protected String[] stringToArray(String data) { return parseLine(data); } - + protected static final char separator = ','; + protected static final char quotechar = '\"'; + protected static final char escapechar = '\\'; // Copied from CSVWriter and improved @@ -227,11 +227,10 @@ public class MemoryDataStorage implements DataStorage { continue; } sb.append(quotechar); - + if (nextElement.indexOf(quotechar) != -1 || nextElement.indexOf(escapechar) != -1) { sb.append(processLine(nextElement)); - } - else { + } else { sb.append(nextElement); } sb.append(quotechar); @@ -252,7 +251,7 @@ public class MemoryDataStorage implements DataStorage { sb.append(nextChar); } } - + return sb; } @@ -282,28 +281,28 @@ public class MemoryDataStorage implements DataStorage { inQuotes = true; }*/ for (int i = 0; i < nextLine.length(); i++) { - + char c = nextLine.charAt(i); if (c == escapechar) { - if( isNextCharacterEscapable(nextLine, inQuotes, i) ){ - sb.append(nextLine.charAt(i+1)); + if (isNextCharacterEscapable(nextLine, inQuotes, i)) { + sb.append(nextLine.charAt(i + 1)); i++; - } + } } else if (c == quotechar) { - if( isNextCharacterEscapedQuote(nextLine, inQuotes, i) ){ - sb.append(nextLine.charAt(i+1)); + if (isNextCharacterEscapedQuote(nextLine, inQuotes, i)) { + sb.append(nextLine.charAt(i + 1)); i++; - }else{ + } else { inQuotes = !inQuotes; // the tricky case of an embedded quote in the middle: a,bc"d"ef,g //if (!strictQuotes) { - if(i>2 //not on the beginning of the line - && nextLine.charAt(i-1) != separator //not at the beginning of an escape sequence - && nextLine.length()>(i+1) && - nextLine.charAt(i+1) != separator //not at the end of an escape sequence - ){ - sb.append(c); - } + if (i > 2 //not on the beginning of the line + && nextLine.charAt(i - 1) != separator //not at the beginning of an escape sequence + && nextLine.length() > (i + 1) && + nextLine.charAt(i + 1) != separator //not at the end of an escape sequence + ) { + sb.append(c); + } //} } } else if (c == separator && !inQuotes) { @@ -311,7 +310,7 @@ public class MemoryDataStorage implements DataStorage { sb = new StringBuilder(128); // start work on next token } else { //if (!strictQuotes || inQuotes) - sb.append(c); + sb.append(c); } } /*// line is done - check status @@ -326,7 +325,7 @@ public class MemoryDataStorage implements DataStorage { } }*/ //if (sb != null) { - tokensOnThisLine.add(sb.toString()); + tokensOnThisLine.add(sb.toString()); //} return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]); } @@ -334,14 +333,14 @@ public class MemoryDataStorage implements DataStorage { // Copied from CSVParser protected boolean isNextCharacterEscapedQuote(String nextLine, boolean inQuotes, int i) { return inQuotes // we are in quotes, therefore there can be escaped quotes in here. - && nextLine.length() > (i+1) // there is indeed another character to check. - && nextLine.charAt(i+1) == quotechar; + && nextLine.length() > (i + 1) // there is indeed another character to check. + && nextLine.charAt(i + 1) == quotechar; } // Copied from CSVParser and improved protected boolean isNextCharacterEscapable(String nextLine, boolean inQuotes, int i) { return inQuotes // we are in quotes, therefore there can be escaped quotes in here. - && nextLine.length() > (i+1) // there is indeed another character to check. - && ( nextLine.charAt(i+1) == quotechar || nextLine.charAt(i+1) == escapechar); + && nextLine.length() > (i + 1) // there is indeed another character to check. + && (nextLine.charAt(i + 1) == quotechar || nextLine.charAt(i + 1) == escapechar); } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java b/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java index d81fe63..6516c66 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java @@ -26,16 +26,12 @@ import java.io.Serializable; /** * Coordinate used to manipulate haul in map. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class Coordinate implements Serializable { - /** serialVersionUID. */ + private static final long serialVersionUID = -5111417883474394223L; protected int serie; @@ -47,7 +43,7 @@ public class Coordinate implements Serializable { protected double longitude; public Coordinate() { - + } public Coordinate(int serie, String name, double latitude, double longitude) { diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/DataType.java b/coser-business/src/main/java/fr/ifremer/coser/util/DataType.java index a97075a..9b9996b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/DataType.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/DataType.java @@ -22,13 +22,11 @@ package fr.ifremer.coser.util; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Set; import static org.nuiton.i18n.I18n.l; import static org.nuiton.i18n.I18n.n; @@ -49,12 +47,13 @@ public enum DataType { private final String i18nKey; private final boolean needSpecies; + private final boolean indicator; DataType(String i18nKey, boolean needSpecies, boolean indicator) { this.i18nKey = i18nKey; this.needSpecies = needSpecies; - this.indicator=indicator; + this.indicator = indicator; } public String getLabel(Locale locale) { @@ -80,7 +79,7 @@ public enum DataType { } } - return result; + return result; } @@ -95,7 +94,7 @@ public enum DataType { } } - return result; + return result; } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/InputStreamKnownSizeBody.java b/coser-business/src/main/java/fr/ifremer/coser/util/InputStreamKnownSizeBody.java index 1d86551..b5d8a27 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/InputStreamKnownSizeBody.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/InputStreamKnownSizeBody.java @@ -22,31 +22,31 @@ package fr.ifremer.coser.util; -import java.io.InputStream; - import org.apache.http.entity.mime.content.InputStreamBody; +import java.io.InputStream; + /** * Override of apache httpcomponent's InputStreamBody to fix content length of * input stream. - * + * * Otherwize, this result in request blocked by modsecurity. - * + * * See : http://www.radomirml.com/blog/2009/02/13/file-upload-with-httpcomponents-suc... - * + * * @author echatellier * @since 1.4.2 */ public class InputStreamKnownSizeBody extends InputStreamBody { - + /** Input stream length. */ private long lenght; /** * Constructor with length. - * - * @param in input stream - * @param lenght length + * + * @param in input stream + * @param lenght length * @param mimeType mime type * @param filename file name */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressMonitor.java b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressMonitor.java index 9182d98..ff20a3b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressMonitor.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressMonitor.java @@ -24,26 +24,22 @@ package fr.ifremer.coser.util; /** * Progress monitor. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public interface ProgressMonitor { void setStepCount(int stepCount); - + void setStep(int step); - + void nextStep(); void setCurrent(int current); - + void addCurrent(int addition); void setTotal(int total); - + void setText(String text); } diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressReader.java b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressReader.java index 17e1d28..db5faad 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressReader.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressReader.java @@ -28,12 +28,8 @@ import java.nio.CharBuffer; /** * Reader that notify read progression. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProgressReader extends Reader { @@ -59,7 +55,7 @@ public class ProgressReader extends Reader { } return nb; } - + /* * @see java.io.Reader#read(java.nio.CharBuffer) */ diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressStream.java b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressStream.java index 15534f7..bbb82bc 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/ProgressStream.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/ProgressStream.java @@ -27,12 +27,8 @@ import java.io.InputStream; /** * Stream that notify read progression. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProgressStream extends InputStream { diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/io/OneEchobaseFileFilter.java b/coser-business/src/main/java/fr/ifremer/coser/util/io/OneEchobaseFileFilter.java index 5031af8..3da6d96 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/io/OneEchobaseFileFilter.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/io/OneEchobaseFileFilter.java @@ -33,7 +33,7 @@ import java.io.IOException; * Filter pour un resultat echobase donné. * Created on 3/19/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class OneEchobaseFileFilter implements FileFilter { diff --git a/coser-business/src/main/java/fr/ifremer/coser/util/io/OneRSufiResultFileFilter.java b/coser-business/src/main/java/fr/ifremer/coser/util/io/OneRSufiResultFileFilter.java index cebaec0..40db799 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/util/io/OneRSufiResultFileFilter.java +++ b/coser-business/src/main/java/fr/ifremer/coser/util/io/OneRSufiResultFileFilter.java @@ -36,7 +36,7 @@ import java.util.regex.Matcher; /** * Filter pour un resultat rsufi donné. - * <p/> + * * Attention, implémentation que ne doit fonctionner que avec ZipUtil * car meme si on refuse en répertoire, il redemande quand même * les fils (et il faut qu'il les demande) diff --git a/coser-business/src/main/java/fr/ifremer/coser/validators/AbstractFieldValidator.java b/coser-business/src/main/java/fr/ifremer/coser/validators/AbstractFieldValidator.java index a9e6ccd..5f5e80a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/validators/AbstractFieldValidator.java +++ b/coser-business/src/main/java/fr/ifremer/coser/validators/AbstractFieldValidator.java @@ -28,12 +28,8 @@ import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; /** * Abstract validator. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class AbstractFieldValidator extends FieldValidatorSupport { diff --git a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java index 6945a4f..9063bed 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java +++ b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java @@ -22,21 +22,16 @@ package fr.ifremer.coser.validators; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - +import com.opensymphony.xwork2.validator.ValidationException; import org.apache.commons.lang3.StringUtils; -import com.opensymphony.xwork2.validator.ValidationException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Validateur de double de coser en tant que string. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserCheckDoubleValidator extends AbstractFieldValidator { @@ -84,7 +79,7 @@ public class CoserCheckDoubleValidator extends AbstractFieldValidator { if (notAvailable != null && notAvailable.equals(value)) { return; } - + if (minDecimals != null) { Matcher matcher = DOUBLE_PATTERN.matcher(value); if (matcher.find()) { @@ -98,16 +93,14 @@ public class CoserCheckDoubleValidator extends AbstractFieldValidator { if (decimaleSize - exposant < minDecimals) { addFieldError(getFieldName(), object); } - } - else { + } else { addFieldError(getFieldName(), object); } } try { Double.parseDouble(value); - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { addFieldError(getFieldName(), object); } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserDoubleValidator.java b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserDoubleValidator.java index 4012c9a..6343f0b 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserDoubleValidator.java +++ b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserDoubleValidator.java @@ -26,18 +26,17 @@ import com.opensymphony.xwork2.validator.ValidationException; /** * Coser double validator. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserDoubleValidator extends AbstractFieldValidator { protected Double max = null; + protected Double min = null; + protected Double minExclusive = null; + protected Double maxExclusive = null; public void setMax(Double max) { @@ -86,13 +85,12 @@ public class CoserDoubleValidator extends AbstractFieldValidator { Double doubleValue = Double.valueOf(value); if ((max != null && doubleValue.compareTo(max) > 0) || - (min != null && doubleValue.compareTo(min) < 0) || - (maxExclusive != null && doubleValue.compareTo(maxExclusive) >= 0) || - (minExclusive != null && doubleValue.compareTo(minExclusive) <= 0)) { + (min != null && doubleValue.compareTo(min) < 0) || + (maxExclusive != null && doubleValue.compareTo(maxExclusive) >= 0) || + (minExclusive != null && doubleValue.compareTo(minExclusive) <= 0)) { addFieldError(getFieldName(), object); } - } - catch (NumberFormatException ex) { + } catch (NumberFormatException ex) { // skipped, already validated in check double } } diff --git a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserExpressionValidator.java b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserExpressionValidator.java index cd3501b..a78772a 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/validators/CoserExpressionValidator.java +++ b/coser-business/src/main/java/fr/ifremer/coser/validators/CoserExpressionValidator.java @@ -27,12 +27,8 @@ import com.opensymphony.xwork2.validator.validators.ExpressionValidator; /** * Modification de {@link ExpressionValidator} pour avoir les exceptions. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserExpressionValidator extends ExpressionValidator { @@ -52,7 +48,7 @@ public class CoserExpressionValidator extends ExpressionValidator { } catch (ValidationException e) { throw e; } catch (Exception e) { - + // arrive si des valeurs NA sont comparée par exemple // le test lance une exception, mais on le considere // valide pour la suite @@ -66,11 +62,12 @@ public class CoserExpressionValidator extends ExpressionValidator { } if (!answer.booleanValue()) { - if (log.isDebugEnabled()) log.debug("Validation failed on expression " + getExpression() + " with validated object "+ object); + if (log.isDebugEnabled()) + log.debug("Validation failed on expression " + getExpression() + " with validated object " + object); addActionError(object); } } - + /** * Return the field value named <code>name</code> from <code>object</code>, * <code>object</code> should have the appropriate getter/setter. diff --git a/coser-business/src/main/java/fr/ifremer/coser/validators/RegexFieldValidator.java b/coser-business/src/main/java/fr/ifremer/coser/validators/RegexFieldValidator.java index cf82b3c..66e9a08 100644 --- a/coser-business/src/main/java/fr/ifremer/coser/validators/RegexFieldValidator.java +++ b/coser-business/src/main/java/fr/ifremer/coser/validators/RegexFieldValidator.java @@ -21,31 +21,31 @@ */ package fr.ifremer.coser.validators; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import com.opensymphony.xwork2.validator.ValidationException; import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * Same validator, but empty or null string is not valid. - * + * * <!-- START SNIPPET: javadoc --> * Validates a string field using a regular expression. * <!-- END SNIPPET: javadoc --> - * <p/> - * - * + * + * + * * <!-- START SNIPPET: parameters --> * <ul> - * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> - * <li>expression - The RegExp expression REQUIRED</li> - * <li>caseSensitive - Boolean (Optional). Sets whether the expression should be matched against in a case-sensitive way. Default is <code>true</code>.</li> - * <li>trim - Boolean (Optional). Sets whether the expression should be trimed before matching. Default is <code>true</code>.</li> + * <li>fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required</li> + * <li>expression - The RegExp expression REQUIRED</li> + * <li>caseSensitive - Boolean (Optional). Sets whether the expression should be matched against in a case-sensitive way. Default is <code>true</code>.</li> + * <li>trim - Boolean (Optional). Sets whether the expression should be trimed before matching. Default is <code>true</code>.</li> * </ul> * <!-- END SNIPPET: parameters --> - * - * + * + * * <pre> * <!-- START SNIPPET: example --> * <validators> @@ -54,7 +54,7 @@ import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; * <param name="fieldName">myStrangePostcode</param> * <param name="expression"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]<>/param> * </validator> - * + * * <!-- Field Validator Syntax --> * <field name="myStrangePostcode"> * <field-validator type="regex"> @@ -71,7 +71,9 @@ import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; public class RegexFieldValidator extends FieldValidatorSupport { private String expression; + private boolean caseSensitive = true; + private boolean trim = true; public void validate(Object object) throws ValidationException { @@ -79,7 +81,7 @@ public class RegexFieldValidator extends FieldValidatorSupport { Object value = this.getFieldValue(fieldName, object); // if there is no value - don't do comparison // if a value is required, a required validator should be added to the field - + if (value == null) { addFieldError(fieldName, object); return; @@ -109,10 +111,10 @@ public class RegexFieldValidator extends FieldValidatorSupport { } String compare = (String) value; - if ( trim ) { + if (trim) { compare = compare.trim(); } - Matcher matcher = pattern.matcher( compare ); + Matcher matcher = pattern.matcher(compare); if (!matcher.matches()) { addFieldError(fieldName, object); @@ -135,7 +137,7 @@ public class RegexFieldValidator extends FieldValidatorSupport { /** * @return Returns whether the expression should be matched against in - * a case-sensitive way. Default is <code>true</code>. + * a case-sensitive way. Default is <code>true</code>. */ public boolean isCaseSensitive() { return caseSensitive; diff --git a/coser-business/src/test/java/fr/ifremer/coser/CoserUtilsTest.java b/coser-business/src/test/java/fr/ifremer/coser/CoserUtilsTest.java index 33cc4cf..46e2dce 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/CoserUtilsTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/CoserUtilsTest.java @@ -33,10 +33,10 @@ import org.junit.Test; * Coser utils tests. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class CoserUtilsTest { diff --git a/coser-business/src/test/java/fr/ifremer/coser/bean/EchoBaseProjectTest.java b/coser-business/src/test/java/fr/ifremer/coser/bean/EchoBaseProjectTest.java index d6b1ce1..24f9500 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/bean/EchoBaseProjectTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/bean/EchoBaseProjectTest.java @@ -31,7 +31,7 @@ import java.io.FilenameFilter; /** * Created on 3/17/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseProjectTest { diff --git a/coser-business/src/test/java/fr/ifremer/coser/bean/IndicatorMapTest.java b/coser-business/src/test/java/fr/ifremer/coser/bean/IndicatorMapTest.java index 8773040..b72ba37 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/bean/IndicatorMapTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/bean/IndicatorMapTest.java @@ -30,7 +30,7 @@ import org.junit.Test; /** * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class IndicatorMapTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/bean/ZoneMapTest.java b/coser-business/src/test/java/fr/ifremer/coser/bean/ZoneMapTest.java index a47a66c..a8f5f0d 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/bean/ZoneMapTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/bean/ZoneMapTest.java @@ -30,7 +30,7 @@ import org.junit.Test; /** * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class ZoneMapTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProviderTest.java b/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProviderTest.java index 9fc355b..b82fd7b 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProviderTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryProviderTest.java @@ -33,7 +33,7 @@ import java.util.Set; /** * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseResultRepositoryProviderTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryTest.java b/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryTest.java index c1fed72..d67a82a 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/result/repository/echobase/EchoBaseResultRepositoryTest.java @@ -42,7 +42,7 @@ import java.util.Set; /** * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class EchoBaseResultRepositoryTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProviderTest.java b/coser-business/src/test/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProviderTest.java index 9b977a5..c212be9 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProviderTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/result/repository/legacy/LegacyResultRepositoryProviderTest.java @@ -35,7 +35,7 @@ import java.util.Set; /** * Created on 3/5/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class LegacyResultRepositoryProviderTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java index 5eb4ed1..ed33024 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java @@ -38,10 +38,10 @@ import fr.ifremer.coser.data.Length; * CommandService tests * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class CommandServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/CommonServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/CommonServiceTest.java index 26bcf2f..4379e54 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/CommonServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/CommonServiceTest.java @@ -36,10 +36,10 @@ import fr.ifremer.coser.bean.Project; * Project service tests. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class CommonServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java index ffa6111..f2d0a01 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/ControlServiceTest.java @@ -41,10 +41,10 @@ import fr.ifremer.coser.data.Length; * Test about control service (validation...). * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class ControlServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java b/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java index 4cff31a..8c81c5e 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java @@ -51,10 +51,10 @@ import org.nuiton.util.FileUtil; * Common coser test code. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public abstract class CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java index be66205..a48bdf5 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java @@ -54,10 +54,10 @@ import fr.ifremer.coser.util.Coordinate; * Project service tests. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class ProjectServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java index a683c8c..cdfb987 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java @@ -56,10 +56,10 @@ import fr.ifremer.coser.control.ControlError; * Publication service tests * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class PublicationServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java b/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java index e272589..43aca47 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java @@ -47,10 +47,10 @@ import fr.ifremer.coser.util.DataType; * Test du service de l'interface web. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class WebServiceTest extends CoserTestAbstract { diff --git a/coser-business/src/test/java/fr/ifremer/coser/storage/MemoryDataStorageTest.java b/coser-business/src/test/java/fr/ifremer/coser/storage/MemoryDataStorageTest.java index edb4bd5..97b1a69 100644 --- a/coser-business/src/test/java/fr/ifremer/coser/storage/MemoryDataStorageTest.java +++ b/coser-business/src/test/java/fr/ifremer/coser/storage/MemoryDataStorageTest.java @@ -31,10 +31,10 @@ import fr.ifremer.coser.services.CoserTestAbstract; * Test for MemoryDataStorage class. * * @author chatellier - * @version $Revision$ + * - * Last update : $Date$ - * By : $Author$ + + */ public class MemoryDataStorageTest extends CoserTestAbstract { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/Coser.java b/coser-ui/src/main/java/fr/ifremer/coser/Coser.java index 281e53a..a429f0c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/Coser.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/Coser.java @@ -28,19 +28,11 @@ import javax.swing.SwingUtilities; /** * Coser main class. - * <p/> - * Last update : $Date$ - * By : $Author$ * * @author chatellier - * @version $Revision$ */ public class Coser { -// private static final Log log = LogFactory.getLog(Coser.class); - -// protected static CoserConfig coserConfig; - /** * Coser main method. * @@ -48,28 +40,9 @@ public class Coser { */ public static void main(String... args) { -// // init config -// coserConfig = new CoserConfig(); -// try { -// coserConfig.parse(args); -// } catch (ArgumentsParserException ex) { -// if (log.isErrorEnabled()) { -// log.error("Cant' parse configuration", ex); -// } -// } -// -// // OpenMap sysout -// MapBean.suppressCopyright = true; -// -// // catch wall application exception -// launch(context); -// -// // catch uncaught exceptions -// Thread.setDefaultUncaughtExceptionHandler(new CoserExceptionHandler()); -// System.setProperty("sun.awt.exception.handler", CoserExceptionHandler.class.getName()); - // launch UI SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { @@ -102,84 +75,5 @@ public class Coser { } }); } -// /** -// * Display main UI. -// * -// * @param coserConfig coser configuration -// */ -// public static void launch(final CoserConfig coserConfig) { -// -// // to work in java webstart -// try { -// I18n.init(new DefaultI18nInitializer("coser-i18n"), coserConfig.getLocale()); -// } catch (RuntimeException ex) { -// if (log.isErrorEnabled()) { -// log.error("Could not load coser i18n bundle", ex); -// } -// // fallback for dev mode -// I18n.init(new ClassPathI18nInitializer(), coserConfig.getLocale()); -// } -// -// // launch UI -// SwingUtilities.invokeLater(new Runnable() { -// @Override -// public void run() { -// -// CoserConfig coserConfig = applicationContext.getConfig(); -// -// // ne to be done in Swing EDT (otherwize, don't work on javawebstart) -// // declare new classloader -// ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); -// CoserClassLoader coserClassLoader = new CoserClassLoader(currentClassLoader); -// Thread.currentThread().setContextClassLoader(coserClassLoader); -// // set coser xwork validation file directory in classloader -// coserClassLoader.setValidatorsDirectory(coserConfig.getValidatorsDirectory()); -// -// // init LAF (from configuration) -// try { -// String lafClassName = coserConfig.getLookAndFeel(); -// for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { -// if (laf.getClassName().equalsIgnoreCase(lafClassName)) { -// UIManager.setLookAndFeel(laf.getClassName()); -// } -// } -// } catch (Exception ex) { -// if (log.isErrorEnabled()) { -// log.error("Can't init look and feel", ex); -// } -// } -// -// // update font size (after laf) -// coserConfig.updateSwingFont(); -// -// File coserConfigDirectory = new File(coserConfig.getUserConfigDirectory(), "coser"); -// try { -// FileUtils.forceMkdir(coserConfigDirectory); -// } catch (IOException e) { -// throw new CoserTechnicalException("Could not create user data directory", e); -// } -// File mainFrameFile = new File(coserConfigDirectory, "session.xml"); -// SwingSession session = new SwingSession(mainFrameFile, true); -// -// // define unique context global values -// DefaultApplicationContext context = new DefaultApplicationContext(); -// context.setContextValue(coserConfig); -// context.setContextValue(session); -// context.setContextValue(new ProjectService(coserConfig)); -// context.setContextValue(new CommandService(coserConfig)); -// context.setContextValue(new ControlService(coserConfig)); -// context.setContextValue(new PublicationService(coserConfig)); -//// context.setContextValue(new WebService(coserConfig)); -// context.setContextValue(new ClientResultService(coserConfig)); -// context.setContextValue(new DefaultCoserApplicationContext(coserConfig)); -// -// // init frame with session reloading -// CoserFrame frame = new CoserFrame(context); -// frame.setLocationRelativeTo(null); -// session.add(frame); -// -// frame.setVisible(true); -// } -// }); -// } + } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java b/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java index ef7677b..13ef7c9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java @@ -36,10 +36,6 @@ import static org.nuiton.i18n.I18n.n; * Coser application configuration. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class CoserConfig extends CoserBusinessConfig { @@ -52,6 +48,7 @@ public class CoserConfig extends CoserBusinessConfig { n("numbereditor.dot"); n("numbereditor.sign"); } + public CoserConfig() { // init configuration with default options loadDefaultOptions(CoserOption.values()); @@ -98,7 +95,7 @@ public class CoserConfig extends CoserBusinessConfig { } } - public static enum CoserOption implements ConfigOptionDef { + public enum CoserOption implements ConfigOptionDef { CONFIG_FILE(CONFIG_FILE_NAME, n("coser.config.config.file.description"), "coser.properties", String.class, true, true), LOOKANDFEEL("coser.lookandfeel", n("coser.config.lookandfeel.description"), null, String.class, false, false), @@ -119,12 +116,12 @@ public class CoserConfig extends CoserBusinessConfig { private final boolean isFinal; - private CoserOption(String key, - String description, - String defaultValue, - Class<?> type, - boolean isTransient, - boolean isFinal) { + CoserOption(String key, + String description, + String defaultValue, + Class<?> type, + boolean isTransient, + boolean isFinal) { this.key = key; this.description = description; this.defaultValue = defaultValue; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/CoserConfigProvider.java b/coser-ui/src/main/java/fr/ifremer/coser/CoserConfigProvider.java index 84fd09b..c1f9173 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/CoserConfigProvider.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/CoserConfigProvider.java @@ -35,7 +35,7 @@ import static org.nuiton.i18n.I18n.l; /** * To generate configuration report. * - * @author tchemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserConfigProvider implements ApplicationConfigProvider { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/CoserException.java b/coser-ui/src/main/java/fr/ifremer/coser/CoserException.java index e404aae..6d74583 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/CoserException.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/CoserException.java @@ -24,21 +24,17 @@ package fr.ifremer.coser; /** * Coser runtime exception. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserException extends RuntimeException { - /** serialVersionUID. */ + private static final long serialVersionUID = -1199702067044070739L; /** * Constructs a new exception with the specified detail message. - * + * * @param message the detail message */ public CoserException(String message) { @@ -46,10 +42,10 @@ public class CoserException extends RuntimeException { } /** - * Constructs a new exception with the specified detail message and cause. - * + * Constructs a new exception with the specified detail message and cause. + * * @param message the detail message - * @param cause the cause + * @param cause the cause */ public CoserException(String message, Throwable cause) { super(message, cause); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java index 9b5779b..05988c9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java @@ -22,21 +22,20 @@ package fr.ifremer.coser; -import java.lang.Thread.UncaughtExceptionHandler; - +import fr.ifremer.coser.ui.util.ErrorHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import fr.ifremer.coser.ui.util.ErrorHelper; +import java.lang.Thread.UncaughtExceptionHandler; /** * Coser global exception handler. - * + * * Catch all application uncaught and display it in a custom JoptionPane * or JXErrorPane. - * + * * See http://stackoverflow.com/a/4448569/1165234 for details. - * + * * @author echatellier * @since 1.3 */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/CoserUIApplicationContext.java b/coser-ui/src/main/java/fr/ifremer/coser/CoserUIApplicationContext.java index 751e981..42ebabd 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/CoserUIApplicationContext.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/CoserUIApplicationContext.java @@ -44,10 +44,10 @@ import java.io.IOException; /** * Coser UI Application context. - * <p/> + * * Created on 3/23/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserUIApplicationContext extends DefaultCoserApplicationContext { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerRedoMenu.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerRedoMenu.java index dde41ca..e4af9d6 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerRedoMenu.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerRedoMenu.java @@ -22,6 +22,16 @@ package fr.ifremer.coser.ui; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.command.Command; +import fr.ifremer.coser.ui.control.ControlView; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -29,34 +39,18 @@ import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; -import javax.swing.JMenu; -import javax.swing.JMenuItem; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.command.Command; -import fr.ifremer.coser.ui.control.ControlView; - /** * Redo menu action. - * + * * Currently working only for control view because in selection merge commands * are not undoable. - * + * * Listen for action undone by {@link ContainerUndoMenu} to redo them. When * new history commands are done on container, local modification list is * cleared (can't be undone). - * + * * @author chatellier - * @version $Revision$ * @since 1.2 - * - * Last update : $Date$ - * By : $Author$ */ public class ContainerRedoMenu extends JMenu implements ActionListener, PropertyChangeListener { @@ -98,7 +92,7 @@ public class ContainerRedoMenu extends JMenu implements ActionListener, Property * Update submenu items. */ protected void updateSubMenuItems() { - + if (log.isDebugEnabled()) { log.debug("Refresh redo menu items"); } @@ -112,7 +106,7 @@ public class ContainerRedoMenu extends JMenu implements ActionListener, Property menuEnabled = !redoableCommands.isEmpty(); // command in reverse order (only 10 last) - for (int i = redoableCommands.size() - 1 ; i >= 0 && i > redoableCommands.size() - 10 ; i--) { + for (int i = redoableCommands.size() - 1; i >= 0 && i > redoableCommands.size() - 10; i--) { Command command = redoableCommands.get(i); JMenuItem commandMenu = new JMenuItem(command.getDescription(project, control)); commandMenu.setActionCommand(String.valueOf(i)); @@ -147,13 +141,13 @@ public class ContainerRedoMenu extends JMenu implements ActionListener, Property List<Command> commands = new ArrayList<Command>(); List<Command> newRedoCommands = new ArrayList<Command>(redoableCommands); - for (int i = redoableCommands.size() - 1 ; i >= commandIndex ; i--) { + for (int i = redoableCommands.size() - 1; i >= commandIndex; i--) { Command command = redoableCommands.get(i); commands.add(command); newRedoCommands.remove(command); } controlView.getHandler().redoCommands(controlView, commands); - + // update redoable command list // a gerer completement sinon, avec les event du control, on perd tout. setCommands(newRedoCommands); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerUndoMenu.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerUndoMenu.java index a4fc3a2..e2b1a84 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerUndoMenu.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/ContainerUndoMenu.java @@ -22,6 +22,16 @@ package fr.ifremer.coser.ui; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.command.Command; +import fr.ifremer.coser.ui.control.ControlView; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -29,34 +39,17 @@ import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; -import javax.swing.JMenu; -import javax.swing.JMenuItem; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.command.Command; -import fr.ifremer.coser.ui.control.ControlView; - /** * Undo menu action. - * + * * Currently working only for control view because in selection merge commands * are not undoable. - * + * * @author chatellier - * @version $Revision$ * @since 1.2 - * - * Last update : $Date$ - * By : $Author$ */ public class ContainerUndoMenu extends JMenu implements ActionListener, PropertyChangeListener { - /** serialVersionUID */ private static final long serialVersionUID = 2104672856535432709L; private static final Log log = LogFactory.getLog(ContainerUndoMenu.class); @@ -103,7 +96,7 @@ public class ContainerUndoMenu extends JMenu implements ActionListener, Property menuEnabled = !commands.isEmpty(); // command in reverse order (only 10 last) - for (int i = commands.size() - 1 ; i >= 0 && i > commands.size() - 10 ; i--) { + for (int i = commands.size() - 1; i >= 0 && i > commands.size() - 10; i--) { Command command = commands.get(i); JMenuItem commandMenu = new JMenuItem(command.getDescription(project, control)); commandMenu.setActionCommand(String.valueOf(i)); @@ -141,7 +134,7 @@ public class ContainerUndoMenu extends JMenu implements ActionListener, Property // attention copie : la list va changer avec les fire List<Command> redoCommands = new ArrayList<Command>(redoMenu.getCommands()); List<Command> commands = controlView.getControl().getHistoryCommands(); - for (int i = commands.size() - 1 ; i >= commandIndex ; i--) { + for (int i = commands.size() - 1; i >= commandIndex; i--) { redoCommands.add(commands.get(i)); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx index 4a77122..30a417d 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx @@ -20,67 +20,75 @@ #L% --> <JFrame title="coser.ui.mainview.titleempty" layout="{new BorderLayout()}" - name="mainFrame" onWindowClosing="getHandler().quit()" - iconImage='{SwingUtil.createImageIcon("logo.png").getImage()}'> + name="mainFrame" onWindowClosing="getHandler().quit()" + iconImage='{SwingUtil.createImageIcon("logo.png").getImage()}'> - <import> + <import> java.util.Locale - </import> + </import> - <CoserFrameHandler id="handler" constructorParams="this" /> - <fr.ifremer.coser.bean.Project id="project" javaBean="null" /> - <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> + <CoserFrameHandler id="handler" constructorParams="this"/> + <fr.ifremer.coser.bean.Project id="project" javaBean="null"/> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null"/> - <JMenuBar> + <JMenuBar> - <JMenu text="coser.ui.mainframe.menu.file"> - <JMenuItem text="coser.ui.mainframe.menu.newProject" onActionPerformed="getHandler().showProjectCreationView()"/> - <JMenuItem text="coser.ui.mainframe.menu.openProject" onActionPerformed="getHandler().showProjectOpenView()"/> - <JMenuItem text="coser.ui.mainframe.menu.editProject" onActionPerformed="getHandler().showProjectEditView()" enabled="{getProject() != null}" /> - <JMenuItem text="coser.ui.mainframe.menu.closeProject" onActionPerformed="getHandler().closeProject()" enabled="{getProject() != null}" /> - <JSeparator/> - <JMenuItem text="coser.ui.mainframe.menu.quit" onActionPerformed="getHandler().quit()"/> - </JMenu> + <JMenu text="coser.ui.mainframe.menu.file"> + <JMenuItem text="coser.ui.mainframe.menu.newProject" onActionPerformed="getHandler().showProjectCreationView()"/> + <JMenuItem text="coser.ui.mainframe.menu.openProject" onActionPerformed="getHandler().showProjectOpenView()"/> + <JMenuItem text="coser.ui.mainframe.menu.editProject" onActionPerformed="getHandler().showProjectEditView()" + enabled="{getProject() != null}"/> + <JMenuItem text="coser.ui.mainframe.menu.closeProject" onActionPerformed="getHandler().closeProject()" + enabled="{getProject() != null}"/> + <JSeparator/> + <JMenuItem text="coser.ui.mainframe.menu.quit" onActionPerformed="getHandler().quit()"/> + </JMenu> - <JMenu text="coser.ui.mainframe.menu.data" enabled="{getProject() != null}"> - <JMenuItem text="coser.ui.mainframe.menu.data.summary" onActionPerformed="getHandler().showSummaryView()"/> - <JMenuItem text="coser.ui.mainframe.menu.data.control" onActionPerformed="getHandler().showControlView()"/> - <SelectionsListMenu id="menuWindowSelectionMenu" project="{getProject()}" - text="coser.ui.mainframe.menu.data.selections" constructorParams="this" /> - <JSeparator/> - <ContainerUndoMenu id="menuWindowSelectionUndo" text="coser.ui.mainframe.menu.data.undo" redoMenu="{menuWindowSelectionRedo}" /> - <ContainerRedoMenu id="menuWindowSelectionRedo" text="coser.ui.mainframe.menu.data.redo" /> - </JMenu> - - <JMenu text="coser.ui.mainframe.menu.admin"> - <JMenuItem text="coser.ui.mainframe.menu.admin.publishResult" onActionPerformed="getHandler().showPublishResultView()"/> - </JMenu> + <JMenu text="coser.ui.mainframe.menu.data" enabled="{getProject() != null}"> + <JMenuItem text="coser.ui.mainframe.menu.data.summary" onActionPerformed="getHandler().showSummaryView()"/> + <JMenuItem text="coser.ui.mainframe.menu.data.control" onActionPerformed="getHandler().showControlView()"/> + <SelectionsListMenu id="menuWindowSelectionMenu" project="{getProject()}" + text="coser.ui.mainframe.menu.data.selections" constructorParams="this"/> + <JSeparator/> + <ContainerUndoMenu id="menuWindowSelectionUndo" text="coser.ui.mainframe.menu.data.undo" + redoMenu="{menuWindowSelectionRedo}"/> + <ContainerRedoMenu id="menuWindowSelectionRedo" text="coser.ui.mainframe.menu.data.redo"/> + </JMenu> - <JMenu text="coser.ui.mainframe.menu.options"> - <JMenuItem text="coser.ui.mainframe.menu.configuration" onActionPerformed="getHandler().showCoserConfiguration()"/> - <JMenuItem text="coser.ui.mainframe.menu.validators" onActionPerformed="getHandler().showValidatorsConfiguration()" /> - <JSeparator/> - <JMenuItem actionIcon="i18n-fr" text="coser.ui.mainframe.menu.locale.fr" onActionPerformed="getHandler().switchLanguage(this, Locale.FRANCE)"/> - <JMenuItem actionIcon="i18n-gb" text="coser.ui.mainframe.menu.locale.uk" onActionPerformed="getHandler().switchLanguage(this, Locale.UK)"/> - </JMenu> + <JMenu text="coser.ui.mainframe.menu.admin"> + <JMenuItem text="coser.ui.mainframe.menu.admin.publishResult" + onActionPerformed="getHandler().showPublishResultView()"/> + </JMenu> - <JMenu text="coser.ui.mainframe.menu.view"> - <fr.ifremer.coser.ui.widgets.LookAndFeelViewMenuItem text="coser.ui.mainframe.menu.view.lookandfeel" - onPropertyChange="getHandler().saveLookAndFeelConfiguration(event)"/> - </JMenu> + <JMenu text="coser.ui.mainframe.menu.options"> + <JMenuItem text="coser.ui.mainframe.menu.configuration" + onActionPerformed="getHandler().showCoserConfiguration()"/> + <JMenuItem text="coser.ui.mainframe.menu.validators" + onActionPerformed="getHandler().showValidatorsConfiguration()"/> + <JSeparator/> + <JMenuItem actionIcon="i18n-fr" text="coser.ui.mainframe.menu.locale.fr" + onActionPerformed="getHandler().switchLanguage(this, Locale.FRANCE)"/> + <JMenuItem actionIcon="i18n-gb" text="coser.ui.mainframe.menu.locale.uk" + onActionPerformed="getHandler().switchLanguage(this, Locale.UK)"/> + </JMenu> - <JMenu text="coser.ui.mainframe.menu.help"> - <JMenuItem text="coser.ui.mainframe.menu.website" onActionPerformed="getHandler().showCoserWebsite()"/> - <JMenuItem text="coser.ui.mainframe.menu.websitesih" onActionPerformed="getHandler().showCoserWebsiteSIH()"/> - <JMenuItem text="coser.ui.mainframe.menu.about" onActionPerformed="getHandler().showAboutView()"/> - </JMenu> - </JMenuBar> + <JMenu text="coser.ui.mainframe.menu.view"> + <fr.ifremer.coser.ui.widgets.LookAndFeelViewMenuItem text="coser.ui.mainframe.menu.view.lookandfeel" + onPropertyChange="getHandler().saveLookAndFeelConfiguration(event)"/> + </JMenu> - <JPanel id="mainViewContent" layout="{new BorderLayout()}" constraints="BorderLayout.CENTER"> - <HomeView handler="{getHandler()}" /> - </JPanel> + <JMenu text="coser.ui.mainframe.menu.help"> + <JMenuItem text="coser.ui.mainframe.menu.website" onActionPerformed="getHandler().showCoserWebsite()"/> + <JMenuItem text="coser.ui.mainframe.menu.websitesih" onActionPerformed="getHandler().showCoserWebsiteSIH()"/> + <JMenuItem text="coser.ui.mainframe.menu.about" onActionPerformed="getHandler().showAboutView()"/> + </JMenu> + </JMenuBar> - <fr.ifremer.coser.ui.freize.Freize id="freize" constraints='BorderLayout.SOUTH' /> - <fr.ifremer.coser.ui.freize.FreizeModel initializer="freize.getModel()" project="{getProject()}" - selection="{getSelection()}" /> + <JPanel id="mainViewContent" layout="{new BorderLayout()}" constraints="BorderLayout.CENTER"> + <HomeView handler="{getHandler()}"/> + </JPanel> + + <fr.ifremer.coser.ui.freize.Freize id="freize" constraints='BorderLayout.SOUTH'/> + <fr.ifremer.coser.ui.freize.FreizeModel initializer="freize.getModel()" project="{getProject()}" + selection="{getSelection()}"/> </JFrame> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java index 69ab20b..c77a5f4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java @@ -22,33 +22,6 @@ package fr.ifremer.coser.ui; -import static org.nuiton.i18n.I18n.t; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Desktop; -import java.beans.PropertyChangeEvent; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.Locale; - -import javax.swing.JOptionPane; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.filechooser.FileFilter; - -import jaxx.runtime.JAXXContext; - -import jaxx.runtime.swing.session.SwingSession; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Resource; -import org.nuiton.jaxx.widgets.extra.AboutFrame; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserException; @@ -73,15 +46,35 @@ import fr.ifremer.coser.ui.selection.SelectionView; import fr.ifremer.coser.ui.selection.replay.SelectionReplayHandler; import fr.ifremer.coser.ui.selection.replay.SelectionReplayView; import fr.ifremer.coser.ui.widgets.LookAndFeelViewMenuItem; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.swing.session.SwingSession; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.widgets.extra.AboutFrame; +import org.nuiton.util.Resource; + +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileFilter; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Desktop; +import java.beans.PropertyChangeEvent; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.Locale; + +import static org.nuiton.i18n.I18n.t; /** * Coser handler for main frame. * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserFrameHandler extends CommonHandler { @@ -96,7 +89,7 @@ public class CoserFrameHandler extends CommonHandler { /** * Switch application locale. * - * @param frame frame + * @param frame frame * @param newLocale new locale */ public void switchLanguage(CoserFrame frame, Locale newLocale) { @@ -104,7 +97,7 @@ public class CoserFrameHandler extends CommonHandler { config.setLocale(newLocale); config.saveForUser(); JOptionPane.showMessageDialog(frame, t("coser.ui.locale.mustRestart"), - t("coser.ui.locale.title"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.locale.title"), JOptionPane.INFORMATION_MESSAGE); } /** @@ -158,7 +151,7 @@ public class CoserFrameHandler extends CommonHandler { // centralisation of undo/redo menu manipulation if (component instanceof ControlView) { - ControlView controlView = (ControlView)component; + ControlView controlView = (ControlView) component; view.getMenuWindowSelectionUndo().setControlView(controlView); view.getMenuWindowSelectionRedo().setControlView(controlView); } else { @@ -190,7 +183,7 @@ public class CoserFrameHandler extends CommonHandler { * Show coser configuration. */ public void showCoserConfiguration() { - ConfigurationView configView = new ConfigurationView((JAXXContext)view); + ConfigurationView configView = new ConfigurationView((JAXXContext) view); configView.setLocationRelativeTo(view); configView.setVisible(true); } @@ -245,9 +238,10 @@ public class CoserFrameHandler extends CommonHandler { aboutPanel.showInDialog(view, true);*/ AboutFrame aboutFrame = new AboutFrame() { + @Override protected Component getLicenseTab() { - JTextArea textArea = (JTextArea)super.getLicenseTab(); + JTextArea textArea = (JTextArea) super.getLicenseTab(); textArea.setCaretPosition(0); return new JScrollPane(textArea); } @@ -260,16 +254,14 @@ public class CoserFrameHandler extends CommonHandler { try { if (licenseStream != null) { aboutFrame.setLicenseText(IOUtils.toString(licenseStream)); - } - else { + } else { aboutFrame.setLicenseText("No license file found"); } } catch (IOException ex) { if (log.isWarnEnabled()) { log.warn("Can't read licence file", ex); } - } - finally { + } finally { IOUtils.closeQuietly(licenseStream); } aboutFrame.setBackgroundColor(Color.WHITE); @@ -284,7 +276,7 @@ public class CoserFrameHandler extends CommonHandler { */ public void showValidatorsConfiguration() { CoserConfig config = view.getContextValue(CoserConfig.class); - ValidatorDialog validatorDialog = new ValidatorDialog((JAXXContext)view); + ValidatorDialog validatorDialog = new ValidatorDialog((JAXXContext) view); validatorDialog.setHandler(new OptionHandler()); // layer si non copié @@ -373,7 +365,7 @@ public class CoserFrameHandler extends CommonHandler { * Charge les données de control et affiche la vue de control. * * @param reloadData reload data (a {@code false} dans le cas d'une creation, - * les données sont deja chargées) + * les données sont deja chargées) */ public void showControlView(boolean reloadData) { // load control @@ -383,7 +375,7 @@ public class CoserFrameHandler extends CommonHandler { // #667 : Empecher l'accès à l'étape de contrôle si des sélections existent if (!project.getSelections().isEmpty()) { JOptionPane.showMessageDialog(view, t("coser.ui.mainview.accesswontrolwithselection"), - t("coser.ui.control.controlTitle"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.control.controlTitle"), JOptionPane.ERROR_MESSAGE); return; } @@ -407,8 +399,7 @@ public class CoserFrameHandler extends CommonHandler { setMainComponent(controlView); } catch (CoserBusinessException ex) { throw new CoserException("Can't load control data", ex); - } - finally { + } finally { setDefaultCursor(view); } } @@ -450,8 +441,7 @@ public class CoserFrameHandler extends CommonHandler { setMainComponent(selectionView); } catch (CoserBusinessException ex) { throw new CoserException("Can't create new selection", ex); - } - finally { + } finally { setDefaultCursor(view); } } @@ -478,8 +468,7 @@ public class CoserFrameHandler extends CommonHandler { } catch (CoserBusinessException ex) { throw new CoserException("Can't reload selection data", ex); - } - finally { + } finally { setDefaultCursor(view); } } @@ -490,7 +479,7 @@ public class CoserFrameHandler extends CommonHandler { * Used in selection replay. Selection already exists and is already loaded * into memory. * - * @param selection selection to open + * @param selection selection to open * @param selectedTab onglet a selectionner apres l'ouverture */ public void showSelectionView(Selection selection, int selectedTab) { @@ -518,8 +507,7 @@ public class CoserFrameHandler extends CommonHandler { selectionView.setSelectedIndex(selectedTab); setMainComponent(selectionView); - } - finally { + } finally { setDefaultCursor(view); } } @@ -571,7 +559,7 @@ public class CoserFrameHandler extends CommonHandler { public void saveLookAndFeelConfiguration(PropertyChangeEvent event) { if (event.getPropertyName().equals(LookAndFeelViewMenuItem.PROPERTY_LOOK_AND_FEEL)) { CoserConfig config = view.getContextValue(CoserConfig.class); - config.setLookAndFeel((String)event.getNewValue()); + config.setLookAndFeel((String) event.getNewValue()); config.saveForUser(); if (log.isDebugEnabled()) { log.debug("Look and feel saved to " + config.getLookAndFeel()); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/HomeView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/HomeView.jaxx index bdf3a15..da77f58 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/HomeView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/HomeView.jaxx @@ -21,23 +21,23 @@ --> <JPanel layout="{new BorderLayout()}"> - <import> + <import> javax.swing.SwingConstants - </import> + </import> - <CoserFrameHandler id="handler" javaBean="null" /> + <CoserFrameHandler id="handler" javaBean="null"/> - <Table constraints="BorderLayout.CENTER"> - <row> - <cell weightx="1" weighty="1" anchor="south" fill="horizontal"> - <JLabel icon="logo300.png" horizontalAlignment="{SwingConstants.CENTER}" /> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" anchor="north" fill="horizontal"> - <JLabel text='coser.ui.home.text' horizontalAlignment="{SwingConstants.CENTER}" /> - </cell> - </row> - </Table> + <Table constraints="BorderLayout.CENTER"> + <row> + <cell weightx="1" weighty="1" anchor="south" fill="horizontal"> + <JLabel icon="logo300.png" horizontalAlignment="{SwingConstants.CENTER}"/> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" anchor="north" fill="horizontal"> + <JLabel text='coser.ui.home.text' horizontalAlignment="{SwingConstants.CENTER}"/> + </cell> + </row> + </Table> </JPanel> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenu.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenu.java index 15ef57e..3aaae6d 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenu.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/SelectionsListMenu.java @@ -22,8 +22,15 @@ package fr.ifremer.coser.ui; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JSeparator; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -31,29 +38,15 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Map; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JSeparator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.Selection; +import static org.nuiton.i18n.I18n.t; /** * Selection list menu item. Display dynamic entries for project selection. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SelectionsListMenu extends JMenu implements ActionListener, PropertyChangeListener { - /** serialVersionUID. */ private static final long serialVersionUID = -3528302058982208907L; private static final Log log = LogFactory.getLog(SelectionsListMenu.class); @@ -61,7 +54,7 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert protected CoserFrame view; protected Project project; - + public SelectionsListMenu(CoserFrame view) { this.view = view; updateMenuContent(); @@ -98,8 +91,7 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert menuItem.setFont(menuItem.getFont().deriveFont(Font.ITALIC)); menuItem.setEnabled(false); add(menuItem); - } - else { + } else { Map<String, Selection> selections = project.getSelections(); if (selections == null || selections.isEmpty()) { @@ -107,8 +99,7 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert menuItem.setFont(menuItem.getFont().deriveFont(Font.ITALIC)); menuItem.setEnabled(false); add(menuItem); - } - else { + } else { for (String selectionName : selections.keySet()) { // new selection JMenuItem menuItem = new JMenuItem(selectionName); @@ -128,7 +119,7 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert newMenuItem.setActionCommand("$new selection$"); newMenuItem.addActionListener(this); add(newMenuItem); - + // replay selection JMenuItem replayMenuItem = new JMenuItem(t("coser.ui.mainframe.menu.data.replaySelection")); // les chaines ne doivent pas poser pb, on ne peut pas @@ -150,11 +141,9 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert // new selection case if ("$new selection$".equals(actionCommand)) { view.getHandler().showSelectionView(); - } - else if ("$replay selection$".equals(actionCommand)) { + } else if ("$replay selection$".equals(actionCommand)) { view.getHandler().replaySelection(); - } - else { + } else { view.getHandler().showSelectionView(actionCommand); } } @@ -164,7 +153,7 @@ public class SelectionsListMenu extends JMenu implements ActionListener, Propert */ @Override public void propertyChange(PropertyChangeEvent evt) { - + // quand la liste de selection change // ou la validation du controle updateMenuContent(); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java index 4720128..5bcfb98 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/CommonHandler.java @@ -22,30 +22,24 @@ package fr.ifremer.coser.ui.common; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.ui.control.ControlHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; import java.awt.Component; import java.awt.Cursor; import java.awt.Desktop; import java.io.File; import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.ui.control.ControlHandler; +import static org.nuiton.i18n.I18n.t; /** * Common application handler. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CommonHandler { @@ -58,7 +52,7 @@ public class CommonHandler { /** * Retourne une unique instance du file chooser pour conserver * le répertoire de sélection d'un appel sur l'autre. - * + * * @param currentDirectory current directory * @return file chooser */ @@ -72,7 +66,7 @@ public class CommonHandler { /** * Install le curseur sablier. - * + * * @param comp component to set cursor */ public void setWaitCursor(Component comp) { @@ -81,7 +75,7 @@ public class CommonHandler { /** * Repositionne le curseur a sa valeur par defaut. - * + * * @param comp component to set cursor */ public void setDefaultCursor(Component comp) { @@ -90,9 +84,9 @@ public class CommonHandler { /** * Ouvre un fichier dans le navigateur systeme. - * + * * @param parentComponent parent component - * @param report report to open + * @param report report to open */ protected void browseFile(Component parentComponent, File report) { try { @@ -102,7 +96,7 @@ public class CommonHandler { log.warn("Can't open generated report at " + report.getAbsolutePath(), ex); } JOptionPane.showMessageDialog(parentComponent, t("coser.ui.error.htmlReportCantBeOpened", report.getAbsolutePath()), - t("coser.ui.error.htmlReportError"), JOptionPane.WARNING_MESSAGE); + t("coser.ui.error.htmlReportError"), JOptionPane.WARNING_MESSAGE); } } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java index c70b278..4cca822 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/DataHandler.java @@ -22,52 +22,46 @@ package fr.ifremer.coser.ui.common; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; -import java.util.Collections; -import java.util.List; - -import javax.swing.JFrame; -import javax.swing.SwingUtilities; - +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.services.ProjectService; import jaxx.runtime.JAXXContext; - import jaxx.runtime.swing.session.SwingSession; import org.nuiton.math.matrix.MatrixND; import org.nuiton.math.matrix.viewer.MatrixViewerPanel; import org.nuiton.math.matrix.viewer.renderer.MatrixChartRenderer; import org.nuiton.math.matrix.viewer.renderer.MatrixPanelRenderer; -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.services.ProjectService; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import java.awt.Component; +import java.util.Collections; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Data application handler. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class DataHandler extends CommonHandler { /** * Display lengthStructure matrix in matrixviewerpanel. - * - * @param parent parent component - * @param session session to restore frame state + * + * @param parent parent component + * @param session session to restore frame state * @param projectService projectService - * @param project project - * @param container data container - * @param species selected species (can be null) + * @param project project + * @param container data container + * @param species selected species (can be null) */ public void displayLengthStructureGraph(final Component parent, final SwingSession session, - final ProjectService projectService, final Project project, final AbstractDataContainer container, - final String species) { + final ProjectService projectService, final Project project, final AbstractDataContainer container, + final String species) { SwingUtilities.invokeLater(new Runnable() { + public void run() { try { setWaitCursor(parent); @@ -76,7 +70,7 @@ public class DataHandler extends CommonHandler { MatrixND matrix = projectService.getLengthStructure(project, container); // close previous opened - JFrame previousFrame = ((JAXXContext)parent).getContextValue(JFrame.class, "lengthstructureframe"); + JFrame previousFrame = ((JAXXContext) parent).getContextValue(JFrame.class, "lengthstructureframe"); if (previousFrame != null) { previousFrame.dispose(); } @@ -96,11 +90,11 @@ public class DataHandler extends CommonHandler { // contiennent les noms déjà traduits defaultSpecies = project.getDisplaySpeciesText(defaultSpecies); } else { - defaultSpecies = (String)matrix.getSemantic(1).get(0); + defaultSpecies = (String) matrix.getSemantic(1).get(0); } panel.initRenderering(new List[]{ - matrix.getSemantic(0), // select all length - Collections.singletonList(defaultSpecies) // select first species + matrix.getSemantic(0), // select all length + Collections.singletonList(defaultSpecies) // select first species }, new int[]{-1, -1, 0, 0}); // select dim 3 et 4 sum action matrixViewerFrame.add(panel); matrixViewerFrame.pack(); @@ -110,9 +104,8 @@ public class DataHandler extends CommonHandler { matrixViewerFrame.setVisible(true); // register current frame - ((JAXXContext)parent).setContextValue(matrixViewerFrame, "lengthstructureframe"); - } - finally { + ((JAXXContext) parent).setContextValue(matrixViewerFrame, "lengthstructureframe"); + } finally { setDefaultCursor(parent); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixFilter.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixFilter.java index d37b666..03ee299 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixFilter.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/LengthStructureMatrixFilter.java @@ -22,28 +22,23 @@ package fr.ifremer.coser.ui.common; -import java.util.ArrayList; -import java.util.List; - +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import org.nuiton.math.matrix.MatrixFactory; import org.nuiton.math.matrix.MatrixND; import org.nuiton.math.matrix.viewer.MatrixFilter; -import fr.ifremer.coser.bean.AbstractDataContainer; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.Selection; +import java.util.ArrayList; +import java.util.List; /** * Filtre qui ajoute les trou dans les données (valeur intermédiares absentes) * et qui supprime les bornes sans valeures ensuite. - * + * * Modifie egalement le titre de la matrice. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class LengthStructureMatrixFilter implements MatrixFilter { @@ -65,7 +60,7 @@ public class LengthStructureMatrixFilter implements MatrixFilter { // modifie le titre de la matrice String title = "Coser: " + project.getName(); if (container instanceof Selection) { - title += ": " + ((Selection)container).getName(); + title += ": " + ((Selection) container).getName(); } matrix.setName(title); @@ -84,9 +79,9 @@ public class LengthStructureMatrixFilter implements MatrixFilter { // mais le vide entre est requis (trou de données) for (Object categorySem : matrix.getSemantic(0)) { for (Object serieSem : matrix.getSemantic(1)) { - Double value = matrix.getValue(new Object[] { categorySem, serieSem }); + Double value = matrix.getValue(new Object[]{categorySem, serieSem}); if (value > 0.0) { - double category = (Double)categorySem; + double category = (Double) categorySem; if (first > category) { first = category; } @@ -102,15 +97,15 @@ public class LengthStructureMatrixFilter implements MatrixFilter { // bornes ne sont pas ajustées // chose incohérente... if (!atLeastOneAdujments) { - first = (Double)matrix.getSemantic(0).get(0); - last = (Double)matrix.getSemantic(0).get(matrix.getSemantic(0).size() - 1); + first = (Double) matrix.getSemantic(0).get(0); + last = (Double) matrix.getSemantic(0).get(matrix.getSemantic(0).size() - 1); } // on verifie toutes les valeurs pour savoir si c'est un // pas entier ou un demi pas boolean haltStep = false; for (Object number : semantic0) { - double dNumber = (Double)number; + double dNumber = (Double) number; if (dNumber - Math.floor(dNumber) > 0) { haltStep = true; break; @@ -118,7 +113,7 @@ public class LengthStructureMatrixFilter implements MatrixFilter { } List<Double> newLengthSemantic = new ArrayList<Double>(); - for (double index = first ; index <= last ; index += (haltStep) ? 0.5 : 1) { + for (double index = first; index <= last; index += (haltStep) ? 0.5 : 1) { newLengthSemantic.add(index); } @@ -128,7 +123,7 @@ public class LengthStructureMatrixFilter implements MatrixFilter { semantics[0] = newLengthSemantic; System.arraycopy(matrix.getSemantics(), 1, semantics, 1, matrix.getSemantics().length - 1); filteredMatrix = MatrixFactory.getInstance().create(matrix.getName(), semantics); - + // copy des elements en fonction des semantiques filteredMatrix.pasteSemantics(matrix); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesListRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesListRenderer.java index 663258b..6616f7c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesListRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesListRenderer.java @@ -22,22 +22,21 @@ package fr.ifremer.coser.ui.common; -import java.awt.Component; -import java.util.Map; - import javax.swing.DefaultListCellRenderer; import javax.swing.JList; +import java.awt.Component; +import java.util.Map; /** * L'editeur remplace la valeur présente dans le fichier csv pour l'especes * par un autre nom (latin valide, code...) - * + * * @author echatellier * @since 1.3 */ public class SpeciesListRenderer extends DefaultListCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = 3747535342745177615L; protected Map<String, String> reftaxSpecies; @@ -48,13 +47,13 @@ public class SpeciesListRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - String speciesText = (String)value; + int index, boolean isSelected, boolean cellHasFocus) { + String speciesText = (String) value; if (reftaxSpecies.containsKey(speciesText)) { speciesText = reftaxSpecies.get(speciesText); } return super.getListCellRendererComponent(list, speciesText, index, isSelected, - cellHasFocus); + cellHasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesTableCellRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesTableCellRenderer.java index 9f8dd14..46503fb 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesTableCellRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/common/SpeciesTableCellRenderer.java @@ -22,22 +22,21 @@ package fr.ifremer.coser.ui.common; -import java.awt.Component; -import java.util.Map; - import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Component; +import java.util.Map; /** * L'editeur remplace la valeur présente dans le fichier csv pour l'especes * par un autre nom (latin valide, code...) - * + * * @author echatellier * @since 1.3 */ public class SpeciesTableCellRenderer extends DefaultTableCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -1913267872081009935L; protected Map<String, String> reftaxSpecies; @@ -48,13 +47,13 @@ public class SpeciesTableCellRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { + boolean isSelected, boolean hasFocus, int row, int column) { - String speciesId = (String)value; + String speciesId = (String) value; if (reftaxSpecies.containsKey(speciesId)) { speciesId = reftaxSpecies.get(speciesId); } return super.getTableCellRendererComponent(table, speciesId, isSelected, hasFocus, - row, column); + row, column); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java index 090584c..ef7b7f4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListModel.java @@ -22,25 +22,20 @@ package fr.ifremer.coser.ui.control; -import java.util.ArrayList; -import java.util.List; +import fr.ifremer.coser.CoserConstants.Category; import javax.swing.DefaultComboBoxModel; - -import fr.ifremer.coser.CoserConstants.Category; +import java.util.ArrayList; +import java.util.List; /** * Control data categories list model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlCategoryListModel extends DefaultComboBoxModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 6700971928409164642L; protected List<Category> categories; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListRenderer.java index 4d70430..4330fb2 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlCategoryListRenderer.java @@ -22,36 +22,31 @@ package fr.ifremer.coser.ui.control; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; +import fr.ifremer.coser.CoserConstants.Category; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; +import java.awt.Component; -import fr.ifremer.coser.CoserConstants.Category; +import static org.nuiton.i18n.I18n.t; /** * Validation categories list model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlCategoryListRenderer extends DefaultListCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -435184894102500045L; @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { - Category category = (Category)value; + Category category = (Category) value; String stringValue = t(category.getTranslationKey()); - + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java index 5337049..0053f77 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java @@ -22,25 +22,21 @@ package fr.ifremer.coser.ui.control; -import static org.nuiton.i18n.I18n.t; - import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.storage.DataStorage; +import static org.nuiton.i18n.I18n.t; + /** * Table model that display csv content loaded into memory and stored in * project storage. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlDataTableModel extends ControlTableModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -1192463259386773117L; protected DataStorage data; @@ -61,16 +57,20 @@ public class ControlDataTableModel extends ControlTableModel { protected void updateData(ControlView controlView) { Project project = controlView.getContextValue(Project.class); - + switch (category) { - case CATCH: - data = project.getControl().getCatch(); break; - case HAUL: - data = project.getControl().getHaul(); break; - case LENGTH: - data = project.getControl().getLength(); break; - case STRATA: - data = project.getControl().getStrata(); break; + case CATCH: + data = project.getControl().getCatch(); + break; + case HAUL: + data = project.getControl().getHaul(); + break; + case LENGTH: + data = project.getControl().getLength(); + break; + case STRATA: + data = project.getControl().getStrata(); + break; } header = data.get(0); fireTableStructureChanged(); @@ -114,7 +114,7 @@ public class ControlDataTableModel extends ControlTableModel { /** * Retourne la donnée (toutes le String[]) à la ligne demandée. - * + * * @param rowIndex * @return String[] */ @@ -125,7 +125,7 @@ public class ControlDataTableModel extends ControlTableModel { /** * Retourne l'index dans la liste des données du numero de ligne demandée. - * + * * @param lineNumber le numero de données * @return l'index */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java index e201887..755680c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java @@ -22,6 +22,14 @@ package fr.ifremer.coser.ui.control; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.control.ControlError; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import java.util.EventListener; import java.util.HashSet; import java.util.Iterator; @@ -29,34 +37,20 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.control.ControlError; - /** * Table model that change line order to display duplicated line side by side. - * + * * L'implementation reside sur la construction d'un tableau associatif qui * associe les numeros demandé par la vue à d'autre numero différents qui * correspondent au données du modèle réel. * La précédente implémentation utilisait des ArrayList, mais n'était pas * performante vis à vis de la construction de la liste. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlDuplicatedLineTableModel extends ControlTableModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 8138379018849263395L; private static final Log log = LogFactory.getLog(ControlDuplicatedLineTableModel.class); @@ -67,6 +61,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { protected List<ControlError> controlErrors; protected int[] linesIndex = null; + protected int[] reverseLinesIndex = null; @Override @@ -86,7 +81,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { /** * Compute line indices. - * + * * This algorithm has been optimized three times. * Be carefull of performances when modify it, can take looooong times * without optimisation. @@ -105,7 +100,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { int i = 0; int j = 0; Set<Integer> alreadyDone = new HashSet<Integer>(); - + // look for first error line to manage in main loop Iterator<ControlError> itControlErrors = localControlErrors.iterator(); int nextErrorFirstLine = -1; @@ -117,7 +112,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { } // main loop - while (i<dataCount) { + while (i < dataCount) { while (alreadyDone.contains(j)) { j++; } @@ -132,7 +127,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { // remove it, useless for next iteration itControlErrors.remove(); - + // look for next error line to manage in main loop if (itControlErrors.hasNext()) { controlError = itControlErrors.next(); @@ -145,7 +140,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { // build reverse array (for method getRealIndexOfLine) reverseLinesIndex = new int[dataCount]; - for (int reversei = 0 ; reversei < dataCount ; ++reversei) { + for (int reversei = 0; reversei < dataCount; ++reversei) { reverseLinesIndex[linesIndex[reversei]] = reversei; } @@ -158,7 +153,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { /** * Parse input control errors list, an build a new list with only errors * that will be used by this model. - * + * * @return new error list for model only */ protected List<ControlError> getCurrentModelErrors() { @@ -199,7 +194,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { /** * Look for modified order row index. - * + * * @param rowIndex initial row index * @return modified row index */ @@ -229,7 +224,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { /** * Retourne l'index réel de la ligne dans la vue. - * + * * Ne doit être utilisé que pour manipuler le modele de selection * et non appeler derriere getValueAt ou getDataAt (pas de sens). */ @@ -246,7 +241,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { /** * Update linesIndex array to remove an index of a line. * This method WONT work for addition, just deletion. - * + * * @param lineIndex index of line to delete */ protected void deleteLine(int lineIndex) { @@ -272,7 +267,7 @@ public class ControlDuplicatedLineTableModel extends ControlTableModel { } // update reverse array indices - for (int reversei = 0 ; reversei < dataCount ; ++reversei) { + for (int reversei = 0; reversei < dataCount; ++reversei) { reverseLinesIndex[linesIndex[reversei]] = reversei; } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java index daf6d25..e46ef6e 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java @@ -22,41 +22,37 @@ package fr.ifremer.coser.ui.control; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; +import fr.ifremer.coser.control.ControlError; +import fr.ifremer.coser.control.ControlErrorGroup; +import jaxx.runtime.validator.swing.SwingValidatorUtil; +import org.jdesktop.swingx.treetable.TreeTableNode; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; +import java.awt.Component; -import jaxx.runtime.validator.swing.SwingValidatorUtil; - -import org.jdesktop.swingx.treetable.TreeTableNode; - -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserConstants.ValidationLevel; -import fr.ifremer.coser.control.ControlError; -import fr.ifremer.coser.control.ControlErrorGroup; +import static org.nuiton.i18n.I18n.t; /** * Renderer pour le table des erreurs globales. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlErrorTreeRenderer extends DefaultTreeCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -6423364126451874968L; protected ImageIcon fatalIcon = null; + protected ImageIcon errorIcon = null; + protected ImageIcon warningIcon = null; + protected ImageIcon infoIcon = null; public ControlErrorTreeRenderer() { @@ -69,60 +65,57 @@ public class ControlErrorTreeRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, - boolean sel, boolean expanded, boolean leaf, int row, - boolean hasFocus) { + boolean sel, boolean expanded, boolean leaf, int row, + boolean hasFocus) { - GlobalControlErrorModel model = (GlobalControlErrorModel)tree.getModel(); - JLabel component = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + GlobalControlErrorModel model = (GlobalControlErrorModel) tree.getModel(); + JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - Object userObject = ((TreeTableNode)value).getUserObject(); + Object userObject = ((TreeTableNode) value).getUserObject(); ImageIcon icon = null; String text = null; String tooltipText = null; if (userObject instanceof String) { - text = t((String)userObject) + " (" + model.getChildCount(value) + ")"; - } - else if (userObject instanceof Category) { - text = t(((Category)userObject).getTranslationKey()) + " (" + model.getChildCount(value) + ")"; - } - else if (userObject instanceof ControlErrorGroup) { - ControlErrorGroup validationErrorGroup = (ControlErrorGroup)userObject; + text = t((String) userObject) + " (" + model.getChildCount(value) + ")"; + } else if (userObject instanceof Category) { + text = t(((Category) userObject).getTranslationKey()) + " (" + model.getChildCount(value) + ")"; + } else if (userObject instanceof ControlErrorGroup) { + ControlErrorGroup validationErrorGroup = (ControlErrorGroup) userObject; ValidationLevel level = validationErrorGroup.getValidationLevel(); switch (level) { - case FATAL: - icon = fatalIcon; - break; - case ERROR: - icon = errorIcon; - break; - case WARNING: - icon = warningIcon; - break; - case INFO: - icon = infoIcon; - break; + case FATAL: + icon = fatalIcon; + break; + case ERROR: + icon = errorIcon; + break; + case WARNING: + icon = warningIcon; + break; + case INFO: + icon = infoIcon; + break; } String message = validationErrorGroup.getMessage(); text = t(message) + " (" + model.getChildCount(value) + ")"; - } - else if (userObject instanceof ControlError) { - ControlError validationError = (ControlError)userObject; + } else if (userObject instanceof ControlError) { + ControlError validationError = (ControlError) userObject; ValidationLevel level = validationError.getLevel(); switch (level) { - case FATAL: - icon = fatalIcon; - break; - case ERROR: - icon = errorIcon; - break; - case WARNING: - icon = warningIcon; - break; - case INFO: - icon = infoIcon; - break; + case FATAL: + icon = fatalIcon; + break; + case ERROR: + icon = errorIcon; + break; + case WARNING: + icon = warningIcon; + break; + case INFO: + icon = infoIcon; + break; } String message = validationError.getDetailMessage(); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx index f241ba3..b44bc32 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx @@ -20,41 +20,41 @@ #L% --> <JDialog title="coser.ui.control.replace.title" modal="true"> - <ControlHandler id="handler" javaBean="null" /> - <Integer id="columnIndex" javaBean="-1" /> - <Boolean id="replaceInSelection" javaBean="false" /> - <Table> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.control.replace.inField" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JLabel id="replaceFieldNameLabel" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.control.replace.find" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="replaceFindField" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.control.replace.replace" /> - </cell> - <cell weightx="2" weighty="1" fill="both" columns="3"> - <JTextField id="replaceReplaceField" /> - </cell> - </row> - <row> - <cell columns="4" anchor="east" insets="0"> - <JPanel> - <JButton text="coser.ui.common.cancel" onActionPerformed="dispose()"/> - <JButton text="coser.ui.common.valid" onActionPerformed="getHandler().performFindAndReplace(this)" /> - </JPanel> - </cell> - </row> - </Table> + <ControlHandler id="handler" javaBean="null"/> + <Integer id="columnIndex" javaBean="-1"/> + <Boolean id="replaceInSelection" javaBean="false"/> + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.control.replace.inField"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JLabel id="replaceFieldNameLabel"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.control.replace.find"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="replaceFindField"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.control.replace.replace"/> + </cell> + <cell weightx="2" weighty="1" fill="both" columns="3"> + <JTextField id="replaceReplaceField"/> + </cell> + </row> + <row> + <cell columns="4" anchor="east" insets="0"> + <JPanel> + <JButton text="coser.ui.common.cancel" onActionPerformed="dispose()"/> + <JButton text="coser.ui.common.valid" onActionPerformed="getHandler().performFindAndReplace(this)"/> + </JPanel> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx index 69c889d..928ece4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx @@ -21,23 +21,23 @@ --> <JFrame title="coser.ui.graph.compareNumberCatchLength" name="catchLengthCompareFrame"> - <ControlHandler id="handler" javaBean="null" /> + <ControlHandler id="handler" javaBean="null"/> - <Table> - <row> - <cell> - <JLabel text="coser.ui.control.graph.species"/> - </cell> - <cell fill="horizontal"> - <SpecyComboModel id="speciesComboModel" /> - <JComboBox id="speciesCombo" model="{speciesComboModel}" - onActionPerformed="getHandler().updateCompareNumberCatchGraph(this)" /> - </cell> - </row> - <row fill="both" weightx="1" weighty="1" columns="2"> - <cell> - <JPanel id="controlGraphPanel" layout="{new BorderLayout()}"/> - </cell> - </row> - </Table> + <Table> + <row> + <cell> + <JLabel text="coser.ui.control.graph.species"/> + </cell> + <cell fill="horizontal"> + <SpecyComboModel id="speciesComboModel"/> + <JComboBox id="speciesCombo" model="{speciesComboModel}" + onActionPerformed="getHandler().updateCompareNumberCatchGraph(this)"/> + </cell> + </row> + <row fill="both" weightx="1" weighty="1" columns="2"> + <cell> + <JPanel id="controlGraphPanel" layout="{new BorderLayout()}"/> + </cell> + </row> + </Table> </JFrame> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java index 69e883c..3410db6 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java @@ -22,59 +22,6 @@ package fr.ifremer.coser.ui.control; -import static org.nuiton.i18n.I18n.t; - -import java.awt.BorderLayout; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.beans.Introspector; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.JViewport; -import javax.swing.ListSelectionModel; -import javax.swing.SwingWorker; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.tree.TreePath; - -import jaxx.runtime.JAXXUtil; -import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.session.SwingSession; -import jaxx.runtime.validator.swing.SwingValidator; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTreeTable; -import org.jdesktop.swingx.combobox.ListComboBoxModel; -import org.jdesktop.swingx.treetable.TreeTableNode; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserConstants.Category; @@ -100,15 +47,61 @@ import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.common.SpeciesListRenderer; import fr.ifremer.coser.ui.common.SpeciesTableCellRenderer; import fr.ifremer.coser.ui.util.CoserProgressBar; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.session.SwingSession; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.combobox.ListComboBoxModel; +import org.jdesktop.swingx.treetable.TreeTableNode; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JSeparator; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.ListSelectionModel; +import javax.swing.SwingWorker; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.beans.Introspector; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static org.nuiton.i18n.I18n.t; /** * Control handler for control view. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ControlHandler extends DataHandler { @@ -116,7 +109,7 @@ public class ControlHandler extends DataHandler { /** * Init control view. - * + * * @param controlView view to init */ public void init(ControlView controlView) { @@ -134,41 +127,41 @@ public class ControlHandler extends DataHandler { /** * Return l'intance de la table qui est selectionnée. - * + * * Les 4 tables sont dupliquées juste pour conserver l'etat des colonnes. - * + * * @param controlView view * @return la table affichée (suivante la categorie) */ protected JTable getControlDataTable(ControlView controlView) { - Category category = (Category)controlView.getCategoryComboBox().getSelectedItem(); + Category category = (Category) controlView.getCategoryComboBox().getSelectedItem(); JTable controlDataTable = null; switch (category) { - case CATCH: - controlDataTable = controlView.getControlDataTableCatch(); - break; - case HAUL: - controlDataTable = controlView.getControlDataTableHaul(); - break; - case LENGTH: - controlDataTable = controlView.getControlDataTableLength(); - break; - case STRATA: - controlDataTable = controlView.getControlDataTableStrata(); - break; + case CATCH: + controlDataTable = controlView.getControlDataTableCatch(); + break; + case HAUL: + controlDataTable = controlView.getControlDataTableHaul(); + break; + case LENGTH: + controlDataTable = controlView.getControlDataTableLength(); + break; + case STRATA: + controlDataTable = controlView.getControlDataTableStrata(); + break; } return controlDataTable; } /** * Selection d'une nouvelle categories dans la liste des categories. - * + * * @param controlView controlView - * @param event event + * @param event event */ public void categoryChanged(ControlView controlView, ActionEvent event) { - Category category = (Category)controlView.getCategoryComboBox().getSelectedItem(); + Category category = (Category) controlView.getCategoryComboBox().getSelectedItem(); controlView.getControlTablesLayout().show(controlView.getControlTablesPanel(), category.toString()); clearAllSelection(controlView); } @@ -177,7 +170,7 @@ public class ControlHandler extends DataHandler { * Vide la selection des 4 tables pour que le bean en cours d'edition * soit vidé et que le changement de categories n'arrive pas * dans un etat de selection incoherent. - * + * * @param controlView controlView */ protected void clearAllSelection(ControlView controlView) { @@ -189,9 +182,9 @@ public class ControlHandler extends DataHandler { /** * Affiche le menu contextuel de la table qui contient les données. - * + * * @param controlView view - * @param event mouse event + * @param event mouse event */ public void showDataTableContextMenu(final ControlView controlView, MouseEvent event) { @@ -205,13 +198,14 @@ public class ControlHandler extends DataHandler { // plusieurs lignes selectionnées et pas la premiere colonne (Line index) if (dataSelectedRows.length > 0 && columnIndex > 0) { - ControlTableModel controlDataModel = (ControlTableModel)displayedTable.getModel(); + ControlTableModel controlDataModel = (ControlTableModel) displayedTable.getModel(); final String columnName = displayedTable.getColumnName(columnIndex); - final String firstValue = (String)controlDataModel.getValueAt(dataSelectedRows[0], columnIndex); + final String firstValue = (String) controlDataModel.getValueAt(dataSelectedRows[0], columnIndex); // replace in selection JMenuItem replaceMenu = new JMenuItem(t("coser.ui.control.dataMenuReplace", columnName)); replaceMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { ControlFindReplaceDialog viewDialog = new ControlFindReplaceDialog(controlView); @@ -232,6 +226,7 @@ public class ControlHandler extends DataHandler { final String columnName = displayedTable.getColumnName(columnIndex); JMenuItem replaceAllMenu = new JMenuItem(t("coser.ui.control.dataMenuReplaceAll", columnName)); replaceAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { ControlFindReplaceDialog viewDialog = new ControlFindReplaceDialog(controlView); @@ -247,9 +242,10 @@ public class ControlHandler extends DataHandler { // delete selected if (dataSelectedRows.length > 0) { - + JMenuItem deleteSelectedMenu = new JMenuItem(t("coser.ui.control.dataMenuDeleteSelected")); deleteSelectedMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { deletedSelectedDataLines(controlView); @@ -257,48 +253,47 @@ public class ControlHandler extends DataHandler { }); popupMenu.add(deleteSelectedMenu); } - + popupMenu.show(displayedTable, event.getX(), event.getY()); } } /** * Delete selected line in data table (called from context menu). - * + * * @param controlView view */ protected void deletedSelectedDataLines(ControlView controlView) { - + JTable controlDataTable = getControlDataTable(controlView); int[] selectedLines = controlDataTable.getSelectedRows(); if (ArrayUtils.isNotEmpty(selectedLines)) { int response = JOptionPane.showConfirmDialog(controlView, t("coser.ui.control.confirmDeletionsMessage", selectedLines.length), - t("coser.ui.control.confirmDeletionTitle"), - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - + t("coser.ui.control.confirmDeletionTitle"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (response == JOptionPane.YES_OPTION) { - + // disableValidAction disableValidAction(controlView); - + Project project = controlView.getContextValue(Project.class); ProjectService projectService = controlView.getContextValue(ProjectService.class); - Category category = (Category)controlView.getCategoryComboBox().getSelectedItem(); + Category category = (Category) controlView.getCategoryComboBox().getSelectedItem(); - ControlTableModel model = (ControlTableModel)controlDataTable.getModel(); + ControlTableModel model = (ControlTableModel) controlDataTable.getModel(); String commandUUID = UUID.randomUUID().toString(); // il faut le faire à l'envers, sinon, les index de // selection change en cours de route - for (int indexSelected = selectedLines.length - 1 ; indexSelected >= 0 ; --indexSelected) { + for (int indexSelected = selectedLines.length - 1; indexSelected >= 0; --indexSelected) { int selectedLine = selectedLines[indexSelected]; String[] data = model.getDataAt(selectedLine); try { projectService.deleteData(project, project.getControl(), category, data[AbstractDataEntity.INDEX_LINE], commandUUID); model.fireTableRowsDeleted(selectedLine, selectedLine); - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't delete data", ex); } } @@ -308,33 +303,33 @@ public class ControlHandler extends DataHandler { /** * Perform find and replace. - * + * * @param replaceView view */ public void performFindAndReplace(ControlFindReplaceDialog replaceView) { ControlView controlView = replaceView.getContextValue(ControlView.class, JAXXUtil.PARENT); - Category category = (Category)controlView.getCategoryComboBox().getSelectedItem(); + Category category = (Category) controlView.getCategoryComboBox().getSelectedItem(); JTable displayedTable = getControlDataTable(controlView); - ControlTableModel controlDataModel = (ControlTableModel)displayedTable.getModel(); + ControlTableModel controlDataModel = (ControlTableModel) displayedTable.getModel(); ProjectService projectService = replaceView.getContextValue(ProjectService.class); Project project = replaceView.getContextValue(Project.class); // find en field name String[] enHeaders = null; switch (category) { - case CATCH: - enHeaders = Catch.EN_HEADERS; - break; - case HAUL: - enHeaders = Haul.EN_HEADERS; - break; - case LENGTH: - enHeaders = Length.EN_HEADERS; - break; - case STRATA: - enHeaders = Strata.EN_HEADERS; - break; + case CATCH: + enHeaders = Catch.EN_HEADERS; + break; + case HAUL: + enHeaders = Haul.EN_HEADERS; + break; + case LENGTH: + enHeaders = Length.EN_HEADERS; + break; + case STRATA: + enHeaders = Strata.EN_HEADERS; + break; } // -1 because table model contains line number @@ -348,9 +343,9 @@ public class ControlHandler extends DataHandler { String commandUUID = UUID.randomUUID().toString(); try { - + int replaceCount = 0; - + if (replaceView.isReplaceInSelection()) { // on suppose que la fenetre est modale, et // que la selection ne peut pas avoir changée @@ -358,35 +353,34 @@ public class ControlHandler extends DataHandler { for (int dataSelectedRow : dataSelectedRows) { String[] data = controlDataModel.getDataAt(dataSelectedRow); boolean replaced = projectService.replaceFieldValue(project, category, field, find, replace, data, false, commandUUID); - + if (replaced) { controlDataModel.fireTableRowsUpdated(dataSelectedRow, dataSelectedRow); replaceCount++; } } - } - else { + } else { int rowCount = controlDataModel.getRowCount(); - for (int rowIndex = 0 ; rowIndex < rowCount ; ++rowIndex) { + for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex) { String[] data = controlDataModel.getDataAt(rowIndex); boolean replaced = projectService.replaceFieldValue(project, category, field, find, replace, data, false, commandUUID); - + if (replaced) { controlDataModel.fireTableRowsUpdated(rowIndex, rowIndex); replaceCount++; } } } - + // message de confirmation JOptionPane.showMessageDialog(replaceView, t("coser.ui.control.replace.replacedCount", replaceCount), - t("coser.ui.control.replace.title"), JOptionPane.INFORMATION_MESSAGE); - + t("coser.ui.control.replace.title"), JOptionPane.INFORMATION_MESSAGE); + } catch (CoserBusinessException ex) { throw new CoserException("Can't replace field value", ex); } replaceView.dispose(); - + // bufix // si le remplacement de masse a modifié la ligne courante, il // faut la rafraichir @@ -395,14 +389,14 @@ public class ControlHandler extends DataHandler { /** * Check project. - * + * * @param view view */ public void checkData(final ControlView view) { - + // clear selection and error message when check data start clearAllSelection(view); - + final ControlService validationService = view.getContextValue(ControlService.class); final Project project = view.getContextValue(Project.class); final CoserProgressBar progressBar = view.getCheckProgressBar(); @@ -413,21 +407,21 @@ public class ControlHandler extends DataHandler { @Override protected List<ControlError> doInBackground() { - + List<ControlError> validationErrors = validationService.validateData(project, project.getControl(), progressBar); return validationErrors; } - + @Override protected void done() { - + if (log.isInfoEnabled()) { long after = System.currentTimeMillis(); - log.info("Validation file checked in " + (after-before) + "ms"); + log.info("Validation file checked in " + (after - before) + "ms"); } - + try { - + // genere la liste des graphes a se moment PublicationService publicationService = view.getContextValue(PublicationService.class); Map<String, JFreeChart> charts = publicationService.getCompareCatchLengthGraph(project, project.getControl(), null); @@ -442,13 +436,13 @@ public class ControlHandler extends DataHandler { view.getGlobalControlErrorModel().setControlErrors(project, errors); // set errors list in each table model - ControlDuplicatedLineTableModel catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableCatch().getModel(); + ControlDuplicatedLineTableModel catchModel = (ControlDuplicatedLineTableModel) view.getControlDataTableCatch().getModel(); catchModel.setControlErrors(errors); - catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableStrata().getModel(); + catchModel = (ControlDuplicatedLineTableModel) view.getControlDataTableStrata().getModel(); catchModel.setControlErrors(errors); - catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableHaul().getModel(); + catchModel = (ControlDuplicatedLineTableModel) view.getControlDataTableHaul().getModel(); catchModel.setControlErrors(errors); - catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableLength().getModel(); + catchModel = (ControlDuplicatedLineTableModel) view.getControlDataTableLength().getModel(); catchModel.setControlErrors(errors); // active le bouton de sauvegarde si la liste d'erreur @@ -468,7 +462,7 @@ public class ControlHandler extends DataHandler { } } - + }; task.execute(); } @@ -476,47 +470,46 @@ public class ControlHandler extends DataHandler { /** * Called when selection change to display selected bean * in edition panel. - * + * * @param view view */ public void controlDataTableSelectionChanged(ControlView view) { JTable table = getControlDataTable(view); - ControlTableModel model = (ControlTableModel)table.getModel(); + ControlTableModel model = (ControlTableModel) table.getModel(); int[] selectedRows = table.getSelectedRows(); if (selectedRows.length == 1) { int selectedRow = selectedRows[0]; Project project = view.getContextValue(Project.class); - Category category = (Category)view.getCategoryComboBox().getSelectedItem(); + Category category = (Category) view.getCategoryComboBox().getSelectedItem(); String[] header = null; String[] line = null; - switch(category) { - case CATCH: - // warning, skip header - header = project.getControl().getCatch().get(0); - //project.getControl().getCatch().get(selectedRow + 1); - break; - case HAUL: - header = project.getControl().getHaul().get(0); - //line = project.getControl().getHaul().get(selectedRow + 1); - break; - case LENGTH: - header = project.getControl().getLength().get(0); - //line = project.getControl().getLength().get(selectedRow + 1); - break; - case STRATA: - header = project.getControl().getStrata().get(0); - //line = project.getControl().getStrata().get(selectedRow + 1); - break; + switch (category) { + case CATCH: + // warning, skip header + header = project.getControl().getCatch().get(0); + //project.getControl().getCatch().get(selectedRow + 1); + break; + case HAUL: + header = project.getControl().getHaul().get(0); + //line = project.getControl().getHaul().get(selectedRow + 1); + break; + case LENGTH: + header = project.getControl().getLength().get(0); + //line = project.getControl().getLength().get(selectedRow + 1); + break; + case STRATA: + header = project.getControl().getStrata().get(0); + //line = project.getControl().getStrata().get(selectedRow + 1); + break; } // get data from model (because of line order modification) - line = model.getDataAt(selectedRow); + line = model.getDataAt(selectedRow); // convertion updateEditionPanel(view, category, header, line); - } - else { + } else { // clear edition panel updateEditionPanel(view, null, null, null); } @@ -525,37 +518,37 @@ public class ControlHandler extends DataHandler { /** * Selectionne, dans la table des données, la ligne correspondant * a l'erreur selectionnée dans la table des erreurs. - * - * @param view view + * + * @param view view * @param event selection event */ public void showSelectedError(ControlView view, TreeSelectionEvent event) { TreePath selectedError = view.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath(); if (selectedError != null && selectedError.getPathCount() >= 3) { - TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1); + TreeTableNode cateNode = (TreeTableNode) selectedError.getPathComponent(1); Object cateObject = cateNode.getUserObject(); - TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent(); + TreeTableNode lastNode = (TreeTableNode) selectedError.getLastPathComponent(); Object userObject = lastNode.getUserObject(); if (cateObject instanceof Category && userObject instanceof ControlError) { - Category category = (Category)cateObject; + Category category = (Category) cateObject; // swap category view.getCategoryComboBoxModel().setSelectedItem(category); - ControlError error = (ControlError)userObject; + ControlError error = (ControlError) userObject; List<String> errorLineNumbers = error.getLineNumbers(); // peut être vide, si l'erreur ne porte pas sur un bean en particulier if (errorLineNumbers != null) { JTable displayedTable = getControlDataTable(view); - ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel(); + ControlTableModel tableModel = (ControlTableModel) displayedTable.getModel(); ListSelectionModel selectionModel = displayedTable.getSelectionModel(); selectionModel.clearSelection(); boolean first = true; for (String errorLineNumber : errorLineNumbers) { int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber); - + // ca peut arriver si la ligne a été supprimée if (errorLineIndex >= 0) { selectionModel.addSelectionInterval(errorLineIndex, errorLineIndex); @@ -569,14 +562,14 @@ public class ControlHandler extends DataHandler { } } } - + /** * Affiche le menu contextuel de l'arbre qui contient les erreurs de * validation globales ou les graphes de comparaison captures/taille * dans le cas d'un double clic sur une {@link SpeciesControlError}. - * + * * @param controlView view - * @param event mouse event + * @param event mouse event * @see SpeciesControlError */ public void globalErrorTableMouseClicked(final ControlView controlView, MouseEvent event) { @@ -593,17 +586,18 @@ public class ControlHandler extends DataHandler { // plusieurs lignes selectionnées et pas la premiere colonne (Line index) if (selectedError != null && selectedError.getPathCount() >= 3) { - TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1); + TreeTableNode cateNode = (TreeTableNode) selectedError.getPathComponent(1); Object cateObject = cateNode.getUserObject(); if (cateObject instanceof Category) { // ca peut être 'tout' en String - final Category category = (Category)cateObject; - final TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent(); + final Category category = (Category) cateObject; + final TreeTableNode lastNode = (TreeTableNode) selectedError.getLastPathComponent(); // selectall n'a d'interet que pour les groupes d'erreurs if (lastNode.getChildCount() > 0) { JMenuItem replaceMenu = new JMenuItem(t("coser.ui.control.globalErrorMenuSelectAll")); replaceMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { selectAllErrorGroupLines(controlView, category, lastNode); @@ -619,6 +613,7 @@ public class ControlHandler extends DataHandler { if (errorTable.getRowCount() > 0) { JMenuItem generateHtmlMenu = new JMenuItem(t("coser.ui.control.globalErrorMenuGenerateHTML")); generateHtmlMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { generateHTMLReport(controlView); @@ -629,18 +624,18 @@ public class ControlHandler extends DataHandler { popupMenu.show(controlView.getGlobalControlErrorTable(), event.getX(), event.getY()); } - + // double clic (bouton normal) else if (eventButton == MouseEvent.BUTTON1 && event.getClickCount() == 2) { TreePath selectedError = controlView.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath(); - + // si la selection est une instance de DiffCatchLengthControlError // affiche le graphe avec l'espece correspondante if (selectedError != null) { - TreeTableNode lastComponent = (TreeTableNode)selectedError.getLastPathComponent(); + TreeTableNode lastComponent = (TreeTableNode) selectedError.getLastPathComponent(); Object userObject = lastComponent.getUserObject(); if (userObject instanceof SpeciesControlError) { - SpeciesControlError error = (SpeciesControlError)userObject; + SpeciesControlError error = (SpeciesControlError) userObject; String species = error.getSpecies(); if (userObject instanceof SpeciesLengthControlError) { displayLengthStructureGraph(controlView, species); @@ -654,15 +649,15 @@ public class ControlHandler extends DataHandler { /** * Selectionne toutes les lignes associés au erreur d'un groupe d'erreur. - * + * * @param controlView controlView - * @param category la categorie pour switcher les tables - * @param lastNode validationGroup + * @param category la categorie pour switcher les tables + * @param lastNode validationGroup */ protected void selectAllErrorGroupLines(ControlView controlView, Category category, TreeTableNode lastNode) { // swap category controlView.getCategoryComboBoxModel().setSelectedItem(category); - + // select all lines JTable displayedTable = getControlDataTable(controlView); ListSelectionModel selectionModel = displayedTable.getSelectionModel(); @@ -673,30 +668,30 @@ public class ControlHandler extends DataHandler { /** * Methode recursive qui selection toutes les lignes correspondant à un * groupe d'erreurs. - * - * @param controlView + * + * @param controlView * @param lastNode * @param scrollToVisible allow to scroll to visible */ protected void selectAllErrorGroupLines(ControlView controlView, TreeTableNode lastNode, boolean scrollToVisible) { GlobalControlErrorModel model = controlView.getGlobalControlErrorModel(); JTable displayedTable = getControlDataTable(controlView); - ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel(); + ControlTableModel tableModel = (ControlTableModel) displayedTable.getModel(); ListSelectionModel selectionModel = displayedTable.getSelectionModel(); boolean first = scrollToVisible; int childCount = model.getChildCount(lastNode); - for (int indexChild = 0 ; indexChild < childCount ; ++indexChild) { - TreeTableNode childNode = (TreeTableNode)model.getChild(lastNode, indexChild); + for (int indexChild = 0; indexChild < childCount; ++indexChild) { + TreeTableNode childNode = (TreeTableNode) model.getChild(lastNode, indexChild); Object userObject = childNode.getUserObject(); - + if (userObject instanceof ControlErrorGroup) { // recursive selectAllErrorGroupLines(controlView, childNode, first); first = false; } else if (userObject instanceof ControlError) { - ControlError validationError = (ControlError)userObject; + ControlError validationError = (ControlError) userObject; List<String> errorLineNumbers = validationError.getLineNumbers(); - + for (String errorLineNumber : errorLineNumbers) { int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber); @@ -712,21 +707,20 @@ public class ControlHandler extends DataHandler { } } } - - + /** * Scroll le viewport de la table à la ligne demandée. - * - * @param table table - * @param rowIndex ligne + * + * @param table table + * @param rowIndex ligne * @param vColIndex colonne */ protected void scrollToVisible(JTable table, int rowIndex, int vColIndex) { if (!(table.getParent() instanceof JViewport)) { return; } - JViewport viewport = (JViewport)table.getParent(); + JViewport viewport = (JViewport) table.getParent(); // This rectangle is relative to the table where the // northwest corner of cell (0,0) is always (0,0). Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); @@ -735,14 +729,14 @@ public class ControlHandler extends DataHandler { // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0) - rect.setLocation(rect.x-pt.x, rect.y-pt.y); + rect.setLocation(rect.x - pt.x, rect.y - pt.y); // Scroll the area into view - viewport.scrollRectToVisible(rect); + viewport.scrollRectToVisible(rect); } /** * Generate global error table model data as html report. - * + * * @param controlView */ protected void generateHTMLReport(ControlView controlView) { @@ -763,13 +757,13 @@ public class ControlHandler extends DataHandler { /** * Contruit le panel d'edition du bean. - * + * * Vide le panel si line est {@code null}. - * - * @param view view + * + * @param view view * @param category category - * @param header header - * @param line line to edit + * @param header header + * @param line line to edit */ protected void updateEditionPanel(ControlView view, Category category, String[] header, String[] line) { @@ -786,30 +780,30 @@ public class ControlHandler extends DataHandler { AbstractDataEntity bean = null; SwingValidator<?> validator = null; switch (category) { - case CATCH: - beanCatch = new Catch(); - beanCatch.setData(line); - bean = beanCatch; - validator = view.getValidatorCatch(); - break; - case HAUL: - beanHaul = new Haul(); - beanHaul.setData(line); - bean = beanHaul; - validator = view.getValidatorHaul(); - break; - case LENGTH: - beanLength = new Length(); - beanLength.setData(line); - bean = beanLength; - validator = view.getValidatorLength(); - break; - case STRATA: - beanStrata = new Strata(); - beanStrata.setData(line); - bean = beanStrata; - validator = view.getValidatorStrata(); - break; + case CATCH: + beanCatch = new Catch(); + beanCatch.setData(line); + bean = beanCatch; + validator = view.getValidatorCatch(); + break; + case HAUL: + beanHaul = new Haul(); + beanHaul.setData(line); + bean = beanHaul; + validator = view.getValidatorHaul(); + break; + case LENGTH: + beanLength = new Length(); + beanLength.setData(line); + bean = beanLength; + validator = view.getValidatorLength(); + break; + case STRATA: + beanStrata = new Strata(); + beanStrata.setData(line); + bean = beanStrata; + validator = view.getValidatorStrata(); + break; } // set to all validators to clear non concerned @@ -821,7 +815,7 @@ public class ControlHandler extends DataHandler { final AbstractDataEntity finalBean = bean; // add to panel // start at 1 (0 = line index) - for (int fieldIndex = 1 ; fieldIndex < header.length ; fieldIndex++) { + for (int fieldIndex = 1; fieldIndex < header.length; fieldIndex++) { String headerValue = header[fieldIndex]; String fieldValue = line[fieldIndex]; @@ -833,12 +827,12 @@ public class ControlHandler extends DataHandler { JLabel label = new JLabel(headerValue + "\u2009:"); panel.add(label, new GridBagConstraints(0, fieldIndex, 1, 1, 0, 0, - GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( - 1, 1, 1, 1), 0, 0)); + GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( + 1, 1, 1, 1), 0, 0)); // combo box used to choose for species in list if ((category == Category.CATCH && fieldIndex == Catch.INDEX_SPECIES) || - (category == Category.LENGTH && fieldIndex == Length.INDEX_SPECIES)) { + (category == Category.LENGTH && fieldIndex == Length.INDEX_SPECIES)) { Project project = view.getContextValue(Project.class); Map<String, String> reftaxSpecies = project.getRefTaxSpeciesMap(); List<String> domain = new ArrayList<String>(reftaxSpecies.keySet()); @@ -847,15 +841,16 @@ public class ControlHandler extends DataHandler { if (!reftaxSpecies.containsKey(fieldValue)) { domain.add(0, fieldValue); } - ListComboBoxModel speciesComboModel = new ListComboBoxModel(domain); + ListComboBoxModel speciesComboModel = new ListComboBoxModel(domain); JComboBox speciesCombo = new JComboBox(speciesComboModel); speciesCombo.setRenderer(new SpeciesListRenderer(reftaxSpecies)); speciesCombo.setSelectedItem(fieldValue); speciesCombo.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { - String value = (String)e.getItem(); + String value = (String) e.getItem(); try { PropertyUtils.setProperty(finalBean, stringBeanFieldName, value); } catch (Exception ex) { @@ -867,8 +862,8 @@ public class ControlHandler extends DataHandler { } }); panel.add(SwingUtil.boxComponentWithJxLayer(speciesCombo), new GridBagConstraints(1, fieldIndex, 1, 1, 1, 0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( - 1, 1, 1, 1), 0, 0)); + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( + 1, 1, 1, 1), 0, 0)); // permet de dire a jaxx que les erreurs sur les // champs d'origine, et les champs string pointent sur le // même composant @@ -877,18 +872,22 @@ public class ControlHandler extends DataHandler { } else { final JTextField fieldTextField = new JTextField(fieldValue); fieldTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override public void insertUpdate(DocumentEvent event) { valueChanged(event); } + @Override public void removeUpdate(DocumentEvent event) { valueChanged(event); } + @Override public void changedUpdate(DocumentEvent event) { valueChanged(event); } + protected void valueChanged(DocumentEvent event) { try { PropertyUtils.setProperty(finalBean, stringBeanFieldName, fieldTextField.getText()); @@ -900,9 +899,9 @@ public class ControlHandler extends DataHandler { } }); panel.add(SwingUtil.boxComponentWithJxLayer(fieldTextField), new GridBagConstraints(1, fieldIndex, 1, 1, 1, 0, - GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( - 1, 1, 1, 1), 0, 0)); - + GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets( + 1, 1, 1, 1), 0, 0)); + // permet de dire a jaxx que les erreurs sur les // champs d'origine, et les champs string pointent sur le // même composant @@ -913,19 +912,18 @@ public class ControlHandler extends DataHandler { validator.installUIs(); validator.reloadBean(); - + view.getControlDataValidButton().setEnabled(true); view.getControlDataCancelButton().setEnabled(true); view.getControlDataDeleteButton().setEnabled(true); - } - else { + } else { // set to all validators to clear non concerned view.getValidatorCatch().setBean(null); view.getValidatorHaul().setBean(null); view.getValidatorLength().setBean(null); view.getValidatorStrata().setBean(null); - + view.getControlDataValidButton().setEnabled(false); view.getControlDataCancelButton().setEnabled(false); view.getControlDataDeleteButton().setEnabled(false); @@ -936,22 +934,22 @@ public class ControlHandler extends DataHandler { /** * Save project after control and display message. - * - * Can't save if : + * + * Can't save if : * - validation contains error * - validation contains non checked warning - * + * * @param view view */ public void saveControl(ControlView view) { saveProjectControl(view); JOptionPane.showMessageDialog(view, t("coser.ui.control.controlSaved"), - t("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE); } - + /** * Save project after control. - * + * * @param view view */ protected void saveProjectControl(ControlView view) { @@ -965,8 +963,7 @@ public class ControlHandler extends DataHandler { long after = System.currentTimeMillis(); log.debug("Control files saved in " + (after - before) + "ms"); } - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't save project control", ex); } } @@ -974,7 +971,7 @@ public class ControlHandler extends DataHandler { /** * Display data graph, initialized with graph for first specy * selected in specyComboModel. - * + * * @param view view */ public void displayCompareNumberCatchGraph(ControlView view) { @@ -984,8 +981,8 @@ public class ControlHandler extends DataHandler { /** * Display data graph, initialized with graph for selected specy * selected. - * - * @param view view + * + * @param view view * @param selectedSpecies if not null (auto select species in combo box) */ public void displayCompareNumberCatchGraph(ControlView view, String selectedSpecies) { @@ -1016,24 +1013,24 @@ public class ControlHandler extends DataHandler { session.add(frame); // session restore frame.toFront(); frame.setVisible(true); - + // register current frame view.setContextValue(frame, "comparenumberframe"); } /** * Display lengthStructure matrix in matrixviewerpanel. - * + * * @param view view */ public void displayLengthStructureGraph(ControlView view) { displayLengthStructureGraph(view, null); } - + /** * Display lengthStructure matrix in matrixviewerpanel. - * - * @param view view + * + * @param view view * @param species selected species (can be null) */ public void displayLengthStructureGraph(ControlView view, String species) { @@ -1045,11 +1042,11 @@ public class ControlHandler extends DataHandler { /** * Met a jour le graphique lorsque la selection de l'espece change. - * + * * @param view view */ public void updateCompareNumberCatchGraph(ControlGraphFrame view) { - String specyName = (String)view.getSpeciesCombo().getSelectedItem(); + String specyName = (String) view.getSpeciesCombo().getSelectedItem(); Map<String, JFreeChart> charts = view.getContextValue(Map.class, "CompareCatchLengthGraph"); JFreeChart chart = charts.get(specyName); view.getControlGraphPanel().removeAll(); @@ -1060,7 +1057,7 @@ public class ControlHandler extends DataHandler { /** * Valide les modifications faites sur le bean actuellement edité. - * + * * @param view view */ public void validDataModification(ControlView view) { @@ -1071,37 +1068,36 @@ public class ControlHandler extends DataHandler { Project project = view.getContextValue(Project.class); ProjectService projectService = view.getContextValue(ProjectService.class); JTable controlDataTable = getControlDataTable(view); - ControlTableModel model = (ControlTableModel)controlDataTable.getModel(); + ControlTableModel model = (ControlTableModel) controlDataTable.getModel(); int selectedLine = controlDataTable.getSelectedRow(); - Category category = (Category)view.getCategoryComboBox().getSelectedItem(); + Category category = (Category) view.getCategoryComboBox().getSelectedItem(); // get data String[] newData = null; switch (category) { - case CATCH: - Catch beanCatch = view.getValidatorCatch().getBean(); - newData = beanCatch.getData(); - break; - case HAUL: - Haul beanHaul = view.getValidatorHaul().getBean(); - newData = beanHaul.getData(); - break; - case LENGTH: - Length beanLength = view.getValidatorLength().getBean(); - newData = beanLength.getData(); - break; - case STRATA: - Strata beanStrata = view.getValidatorStrata().getBean(); - newData = beanStrata.getData(); - break; + case CATCH: + Catch beanCatch = view.getValidatorCatch().getBean(); + newData = beanCatch.getData(); + break; + case HAUL: + Haul beanHaul = view.getValidatorHaul().getBean(); + newData = beanHaul.getData(); + break; + case LENGTH: + Length beanLength = view.getValidatorLength().getBean(); + newData = beanLength.getData(); + break; + case STRATA: + Strata beanStrata = view.getValidatorStrata().getBean(); + newData = beanStrata.getData(); + break; } // remplace les nouvelle données (utilise le numero de ligne pour trouver les anciennes) try { projectService.replaceData(project, project.getControl(), category, newData); model.fireTableRowsUpdated(selectedLine, selectedLine); - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't replace data", ex); } } @@ -1109,7 +1105,7 @@ public class ControlHandler extends DataHandler { /** * Annule les modifications en cours reset les données data, et * reload le validator. - * + * * @param view view */ public void cancelDataModification(ControlView view) { @@ -1118,12 +1114,12 @@ public class ControlHandler extends DataHandler { /** * Supprime la ligne en cours d'edition (apres confirmation). - * + * * @param view view */ public void deleteData(ControlView view) { int response = JOptionPane.showConfirmDialog(view, t("coser.ui.control.confirmDeletionMessage"), - t("coser.ui.control.confirmDeletionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + t("coser.ui.control.confirmDeletionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { // disableValidAction @@ -1134,16 +1130,15 @@ public class ControlHandler extends DataHandler { // get selected row, and selected csv line index JTable controlDataTable = getControlDataTable(view); - ControlTableModel model = (ControlTableModel)controlDataTable.getModel(); + ControlTableModel model = (ControlTableModel) controlDataTable.getModel(); int selectedLine = controlDataTable.getSelectedRow(); - Category category = (Category)view.getCategoryComboBox().getSelectedItem(); + Category category = (Category) view.getCategoryComboBox().getSelectedItem(); String[] data = model.getDataAt(selectedLine); try { projectService.deleteData(project, project.getControl(), category, data[AbstractDataEntity.INDEX_LINE]); model.fireTableRowsDeleted(selectedLine, selectedLine); - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't delete data", ex); } } @@ -1162,7 +1157,7 @@ public class ControlHandler extends DataHandler { /** * Set validated control flag to true and save control. - * + * * @param view view */ public void validControl(ControlView view) { @@ -1173,7 +1168,7 @@ public class ControlHandler extends DataHandler { List<ControlError> controlErrors = view.getGlobalControlErrorModel().getControlErrors(); service.validControl(project, controlErrors); JOptionPane.showMessageDialog(view, t("coser.ui.control.controlValidated"), - t("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.control.controlTitle"), JOptionPane.INFORMATION_MESSAGE); } catch (CoserBusinessException ex) { throw new CoserException("Can't generate html report", ex); } @@ -1182,7 +1177,7 @@ public class ControlHandler extends DataHandler { /** * Genere le log des modifications faites lors du control en HTML * et l'ouvre dans le navigateur systeme. - * + * * @param controlView */ public void displayLogReport(ControlView controlView) { @@ -1200,22 +1195,21 @@ public class ControlHandler extends DataHandler { /** * Undo commands. - * - * @param controlView view + * + * @param controlView view * @param commandsCount commands count to undo - * * @since 1.2 */ public void undoCommands(ControlView controlView, int commandsCount) { CommandService commandeService = controlView.getContextValue(CommandService.class); Project project = controlView.getContextValue(Project.class); - + try { commandeService.undoAction(project, project.getControl(), commandsCount); - + // after undo, refresh table, edition zone JTable controlDataTable = getControlDataTable(controlView); - ControlTableModel model = (ControlTableModel)controlDataTable.getModel(); + ControlTableModel model = (ControlTableModel) controlDataTable.getModel(); model.fireTableDataChanged(); } catch (CoserBusinessException ex) { throw new CoserException("Can't undo selected commands", ex); @@ -1224,22 +1218,22 @@ public class ControlHandler extends DataHandler { /** * Redo commands. - * + * * @param controlView view - * @param commands commands to redo + * @param commands commands to redo * @since 1.2 */ public void redoCommands(ControlView controlView, List<Command> commands) { CommandService commandeService = controlView.getContextValue(CommandService.class); Project project = controlView.getContextValue(Project.class); - + try { for (Command command : commands) { commandeService.doAction(command, project, project.getControl()); } // after redo, refresh table, edition zone JTable controlDataTable = getControlDataTable(controlView); - ControlTableModel model = (ControlTableModel)controlDataTable.getModel(); + ControlTableModel model = (ControlTableModel) controlDataTable.getModel(); model.fireTableDataChanged(); } catch (CoserBusinessException ex) { throw new CoserException("Can't redo selected commands", ex); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java index 6c4bff7..12834f7 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java @@ -22,43 +22,39 @@ package fr.ifremer.coser.ui.control; -import javax.swing.table.AbstractTableModel; - import fr.ifremer.coser.CoserConstants.Category; +import javax.swing.table.AbstractTableModel; + /** * Common interface for all data table model used in control view. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public abstract class ControlTableModel extends AbstractTableModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -2010447483214407634L; /** * Return category managed by model. - * + * * @return model category */ public abstract Category getCategory(); /** * Retourne la donnée (toutes le String[]) à la ligne demandée. - * + * * @param rowIndex * @return String[] */ public abstract String[] getDataAt(int rowIndex); - + /** * Retourne l'index dans la liste des données du numero de ligne * demandé. - * + * * @param lineNumber le numero de données * @return l'index */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx index 05b5730..53d08b1 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx @@ -20,14 +20,14 @@ #L% --> <Table name="controlView"> - <import> + <import> java.awt.Color java.awt.GridBagLayout javax.swing.BorderFactory fr.ifremer.coser.CoserConstants.Category - </import> + </import> - <script><![CDATA[ + <script><![CDATA[ void $afterCompleteSetup() { // bean validation jaxx.runtime.validator.swing.SwingValidatorUtil.installUI(validationMessagesTable, @@ -38,157 +38,165 @@ } ]]></script> - <ControlHandler id="handler" javaBean="null" /> - <fr.ifremer.coser.bean.Control id="control" javaBean="null" /> - <Boolean id="canValidControl" javaBean="false" /> + <ControlHandler id="handler" javaBean="null"/> + <fr.ifremer.coser.bean.Control id="control" javaBean="null"/> + <Boolean id="canValidControl" javaBean="false"/> - <row> - <cell fill="horizontal" insets="0" anchor="west" columns="2"> - <JToolBar floatable="false"> - <JLabel text="coser.ui.control.categorylabel" /> - <fr.ifremer.coser.ui.control.ControlCategoryListModel id="categoryComboBoxModel" /> - <JComboBox id="categoryComboBox" model="{categoryComboBoxModel}" - renderer="{new fr.ifremer.coser.ui.control.ControlCategoryListRenderer()}" - onActionPerformed="getHandler().categoryChanged(this, event)"/> - <JToolBar.Separator /> - <JButton icon="spellcheck.png" text="coser.ui.control.checkData" - onActionPerformed="getHandler().checkData(this)" /> - <JButton id="compareNumberCatchLengthButton" icon="chart_curve.png" enabled="false" - text="coser.ui.graph.compareNumberCatchLength" toolTipText="coser.ui.graph.compareNumberCatchLengthTip" - onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)"/> - <JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure" - onActionPerformed="getHandler().displayLengthStructureGraph(this)"/> - <JToolBar.Separator /> - <JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)" - text="coser.ui.control.controlreport" /> - <Component initializer="javax.swing.Box.createHorizontalGlue()" /> - <JButton icon="disk.png" text="coser.ui.control.save" - onActionPerformed="getHandler().saveControl(this)" /> - <JButton icon="accept.png" onActionPerformed="getHandler().validControl(this)" - text="coser.ui.control.validcontrol" toolTipText="coser.ui.control.validcontroltip" - enabled="{isCanValidControl()}"/> - </JToolBar> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" columns="2"> - <JSplitPane name="splitpaneDataDetails" orientation="{JSplitPane.VERTICAL_SPLIT}" resizeWeight="0.3"> - <CardLayout id="controlTablesLayout" /> - <JPanel id="controlTablesPanel" layout="{controlTablesLayout}"> - <JScrollPane constraints="Category.CATCH.toString()"> - <JTable id='controlDataTableCatch' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.CATCH))}" - onMouseClicked="getHandler().showDataTableContextMenu(this, event)" /> - <ListSelectionModel id="controlDataTableSelectionModelCatch" javaBean="controlDataTableCatch.getSelectionModel()" - onValueChanged="getHandler().controlDataTableSelectionChanged(this)" /> - </JScrollPane> - <JScrollPane constraints="Category.STRATA.toString()"> - <JTable id='controlDataTableStrata' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.STRATA))}" - onMouseClicked="getHandler().showDataTableContextMenu(this, event)" /> - <ListSelectionModel id="controlDataTableSelectionModelStrata" javaBean="controlDataTableStrata.getSelectionModel()" - onValueChanged="getHandler().controlDataTableSelectionChanged(this)" /> - </JScrollPane> - <JScrollPane constraints="Category.HAUL.toString()"> - <JTable id='controlDataTableHaul' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.HAUL))}" - onMouseClicked="getHandler().showDataTableContextMenu(this, event)" /> - <ListSelectionModel id="controlDataTableSelectionModelHaul" javaBean="controlDataTableHaul.getSelectionModel()" - onValueChanged="getHandler().controlDataTableSelectionChanged(this)" /> - </JScrollPane> - <JScrollPane constraints="Category.LENGTH.toString()"> - <JTable id='controlDataTableLength' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.LENGTH))}" - onMouseClicked="getHandler().showDataTableContextMenu(this, event)" /> - <ListSelectionModel id="controlDataTableSelectionModelLength" javaBean="controlDataTableLength.getSelectionModel()" - onValueChanged="getHandler().controlDataTableSelectionChanged(this)" /> - </JScrollPane> - </JPanel> + <row> + <cell fill="horizontal" insets="0" anchor="west" columns="2"> + <JToolBar floatable="false"> + <JLabel text="coser.ui.control.categorylabel"/> + <fr.ifremer.coser.ui.control.ControlCategoryListModel id="categoryComboBoxModel"/> + <JComboBox id="categoryComboBox" model="{categoryComboBoxModel}" + renderer="{new fr.ifremer.coser.ui.control.ControlCategoryListRenderer()}" + onActionPerformed="getHandler().categoryChanged(this, event)"/> + <JToolBar.Separator/> + <JButton icon="spellcheck.png" text="coser.ui.control.checkData" + onActionPerformed="getHandler().checkData(this)"/> + <JButton id="compareNumberCatchLengthButton" icon="chart_curve.png" enabled="false" + text="coser.ui.graph.compareNumberCatchLength" toolTipText="coser.ui.graph.compareNumberCatchLengthTip" + onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)"/> + <JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure" + onActionPerformed="getHandler().displayLengthStructureGraph(this)"/> + <JToolBar.Separator/> + <JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)" + text="coser.ui.control.controlreport"/> + <Component initializer="javax.swing.Box.createHorizontalGlue()"/> + <JButton icon="disk.png" text="coser.ui.control.save" + onActionPerformed="getHandler().saveControl(this)"/> + <JButton icon="accept.png" onActionPerformed="getHandler().validControl(this)" + text="coser.ui.control.validcontrol" toolTipText="coser.ui.control.validcontroltip" + enabled="{isCanValidControl()}"/> + </JToolBar> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" columns="2"> + <JSplitPane name="splitpaneDataDetails" orientation="{JSplitPane.VERTICAL_SPLIT}" resizeWeight="0.3"> + <CardLayout id="controlTablesLayout"/> + <JPanel id="controlTablesPanel" layout="{controlTablesLayout}"> + <JScrollPane constraints="Category.CATCH.toString()"> + <JTable id='controlDataTableCatch' + model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.CATCH))}" + onMouseClicked="getHandler().showDataTableContextMenu(this, event)"/> + <ListSelectionModel id="controlDataTableSelectionModelCatch" + javaBean="controlDataTableCatch.getSelectionModel()" + onValueChanged="getHandler().controlDataTableSelectionChanged(this)"/> + </JScrollPane> + <JScrollPane constraints="Category.STRATA.toString()"> + <JTable id='controlDataTableStrata' + model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.STRATA))}" + onMouseClicked="getHandler().showDataTableContextMenu(this, event)"/> + <ListSelectionModel id="controlDataTableSelectionModelStrata" + javaBean="controlDataTableStrata.getSelectionModel()" + onValueChanged="getHandler().controlDataTableSelectionChanged(this)"/> + </JScrollPane> + <JScrollPane constraints="Category.HAUL.toString()"> + <JTable id='controlDataTableHaul' + model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.HAUL))}" + onMouseClicked="getHandler().showDataTableContextMenu(this, event)"/> + <ListSelectionModel id="controlDataTableSelectionModelHaul" + javaBean="controlDataTableHaul.getSelectionModel()" + onValueChanged="getHandler().controlDataTableSelectionChanged(this)"/> + </JScrollPane> + <JScrollPane constraints="Category.LENGTH.toString()"> + <JTable id='controlDataTableLength' + model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.LENGTH))}" + onMouseClicked="getHandler().showDataTableContextMenu(this, event)"/> + <ListSelectionModel id="controlDataTableSelectionModelLength" + javaBean="controlDataTableLength.getSelectionModel()" + onValueChanged="getHandler().controlDataTableSelectionChanged(this)"/> + </JScrollPane> + </JPanel> - <JSplitPane name="splitpaneDetail" orientation="{JSplitPane.VERTICAL_SPLIT}" resizeWeight="0.5"> - <JSplitPane name="splitpaneDataDetailError" resizeWeight="0.5"> - <JScrollPane id="editionScrollPane"> - <Table> - <row> - <cell weightx="1" fill="horizontal"> - <JButton id="controlDataValidButton" text="coser.ui.common.valid" - onActionPerformed="getHandler().validDataModification(this)" - enabled="false" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JButton id="controlDataCancelButton" text="coser.ui.common.cancel" - onActionPerformed="getHandler().cancelDataModification(this)" - enabled="false" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JButton id="controlDataDeleteButton" text="coser.ui.control.deleteLine" - onActionPerformed="getHandler().deleteData(this)" - enabled="false" /> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both" columns="3"> - <JPanel id="editionPanel" layout="{new GridBagLayout()}"/> - </cell> - </row> - </Table> - </JScrollPane> - - <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' /> - <fr.ifremer.coser.data.Catch id="beanCatch" javaBean="null" /> - <fr.ifremer.coser.data.Haul id="beanHaul" javaBean="null" /> - <fr.ifremer.coser.data.Strata id="beanStrata" javaBean="null" /> - <fr.ifremer.coser.data.Length id="beanLength" javaBean="null" /> - <BeanValidator id='validatorCatch' bean='beanCatch' - uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" - errorTableModel="errorsTableModel" /> - <BeanValidator id='validatorHaul' bean='beanHaul' - uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" - errorTableModel="errorsTableModel" /> - <BeanValidator id='validatorStrata' bean='beanStrata' - uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" - errorTableModel="errorsTableModel" /> - <BeanValidator id='validatorLength' bean='beanLength' - uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" - errorTableModel="errorsTableModel" /> - <JScrollPane> - <JTable id='validationMessagesTable' autoCreateRowSorter='true' - rowSelectionAllowed='true' - model='{errorsTableModel}' /> - </JScrollPane> - </JSplitPane> - - <JSplitPane name="splitpaneGlobalErrorComment" resizeWeight="0.5"> - <JScrollPane> - <GlobalControlErrorModel id="globalControlErrorModel" /> - <JXTreeTable id='globalControlErrorTable' treeTableModel="{globalControlErrorModel}" - rootVisible="false" showsRootHandles="true" - treeCellRenderer="{new ControlErrorTreeRenderer()}" - onMouseClicked="getHandler().globalErrorTableMouseClicked(this, event)" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> - <javax.swing.tree.TreeSelectionModel id="globalControlErrorSelectionModel" - javaBean="globalControlErrorTable.getTreeSelectionModel()" - onValueChanged="getHandler().showSelectedError(this, event)" /> - </JScrollPane> - - <JPanel layout="{new BorderLayout()}"> - <JLabel text="coser.ui.control.comment" constraints="BorderLayout.NORTH"/> - <JScrollPane constraints="BorderLayout.CENTER"> - <JTextArea id="controlComment" rows="3" text="{getControl().getComment()}" /> - <javax.swing.text.Document javaBean="controlComment.getDocument()" - onInsertUpdate='getControl().setComment(controlComment.getText())' - onRemoveUpdate='getControl().setComment(controlComment.getText())' /> - </JScrollPane> - </JPanel> - </JSplitPane> - </JSplitPane> - </JSplitPane> - </cell> - </row> - <row> - <cell anchor="center" weightx="1" fill="horizontal"> - <fr.ifremer.coser.ui.util.CoserProgressBar id="checkProgressBar" stringPainted="true" /> - </cell> - <cell anchor="center" fill="both"> - <JLabel id="localControlUsedLabel" icon="warning.png" background='{new Color(255, 255, 173)}' - border='{BorderFactory.createLineBorder(new Color(226, 226, 81))}' opaque="true" - text="coser.ui.control.warninguselocalcontrols" visible="false" /> - </cell> - </row> + <JSplitPane name="splitpaneDetail" orientation="{JSplitPane.VERTICAL_SPLIT}" resizeWeight="0.5"> + <JSplitPane name="splitpaneDataDetailError" resizeWeight="0.5"> + <JScrollPane id="editionScrollPane"> + <Table> + <row> + <cell weightx="1" fill="horizontal"> + <JButton id="controlDataValidButton" text="coser.ui.common.valid" + onActionPerformed="getHandler().validDataModification(this)" + enabled="false"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JButton id="controlDataCancelButton" text="coser.ui.common.cancel" + onActionPerformed="getHandler().cancelDataModification(this)" + enabled="false"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JButton id="controlDataDeleteButton" text="coser.ui.control.deleteLine" + onActionPerformed="getHandler().deleteData(this)" + enabled="false"/> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both" columns="3"> + <JPanel id="editionPanel" layout="{new GridBagLayout()}"/> + </cell> + </row> + </Table> + </JScrollPane> + + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel'/> + <fr.ifremer.coser.data.Catch id="beanCatch" javaBean="null"/> + <fr.ifremer.coser.data.Haul id="beanHaul" javaBean="null"/> + <fr.ifremer.coser.data.Strata id="beanStrata" javaBean="null"/> + <fr.ifremer.coser.data.Length id="beanLength" javaBean="null"/> + <BeanValidator id='validatorCatch' bean='beanCatch' + uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" + errorTableModel="errorsTableModel"/> + <BeanValidator id='validatorHaul' bean='beanHaul' + uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" + errorTableModel="errorsTableModel"/> + <BeanValidator id='validatorStrata' bean='beanStrata' + uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" + errorTableModel="errorsTableModel"/> + <BeanValidator id='validatorLength' bean='beanLength' + uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" + errorTableModel="errorsTableModel"/> + <JScrollPane> + <JTable id='validationMessagesTable' autoCreateRowSorter='true' + rowSelectionAllowed='true' + model='{errorsTableModel}'/> + </JScrollPane> + </JSplitPane> + + <JSplitPane name="splitpaneGlobalErrorComment" resizeWeight="0.5"> + <JScrollPane> + <GlobalControlErrorModel id="globalControlErrorModel"/> + <JXTreeTable id='globalControlErrorTable' treeTableModel="{globalControlErrorModel}" + rootVisible="false" showsRootHandles="true" + treeCellRenderer="{new ControlErrorTreeRenderer()}" + onMouseClicked="getHandler().globalErrorTableMouseClicked(this, event)" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + <javax.swing.tree.TreeSelectionModel id="globalControlErrorSelectionModel" + javaBean="globalControlErrorTable.getTreeSelectionModel()" + onValueChanged="getHandler().showSelectedError(this, event)"/> + </JScrollPane> + + <JPanel layout="{new BorderLayout()}"> + <JLabel text="coser.ui.control.comment" constraints="BorderLayout.NORTH"/> + <JScrollPane constraints="BorderLayout.CENTER"> + <JTextArea id="controlComment" rows="3" text="{getControl().getComment()}"/> + <javax.swing.text.Document javaBean="controlComment.getDocument()" + onInsertUpdate='getControl().setComment(controlComment.getText())' + onRemoveUpdate='getControl().setComment(controlComment.getText())'/> + </JScrollPane> + </JPanel> + </JSplitPane> + </JSplitPane> + </JSplitPane> + </cell> + </row> + <row> + <cell anchor="center" weightx="1" fill="horizontal"> + <fr.ifremer.coser.ui.util.CoserProgressBar id="checkProgressBar" stringPainted="true"/> + </cell> + <cell anchor="center" fill="both"> + <JLabel id="localControlUsedLabel" icon="warning.png" background='{new Color(255, 255, 173)}' + border='{BorderFactory.createLineBorder(new Color(226, 226, 81))}' opaque="true" + text="coser.ui.control.warninguselocalcontrols" visible="false"/> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java index f17d3e0..76d2c49 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java @@ -22,8 +22,13 @@ package fr.ifremer.coser.ui.control; -import static org.nuiton.i18n.I18n.t; -import static org.nuiton.i18n.I18n.n; +import fr.ifremer.coser.CoserConstants.ValidationLevel; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.control.ControlError; +import fr.ifremer.coser.control.ControlErrorGroup; +import fr.ifremer.coser.control.DiffCatchLengthControlError; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; import java.util.HashMap; import java.util.HashSet; @@ -31,27 +36,18 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; -import org.jdesktop.swingx.treetable.DefaultTreeTableModel; - -import fr.ifremer.coser.CoserConstants.ValidationLevel; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.control.ControlError; -import fr.ifremer.coser.control.ControlErrorGroup; -import fr.ifremer.coser.control.DiffCatchLengthControlError; +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; /** * Global validation table model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class GlobalControlErrorModel extends DefaultTreeTableModel { protected List<ControlError> controlErrors; + protected Set<Object> checkedControlErrors; public GlobalControlErrorModel() { @@ -71,8 +67,8 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { /** * Utilise une simple liste d'erreur issue du contôle pour en faire * une représentation sous forme d'arbre pour l'utilisateur. - * - * @param project project (to get species real names) + * + * @param project project (to get species real names) * @param validationErrors validation errors list to render */ protected void buildGlobalControlErrorTreeModel(Project project, List<ControlError> validationErrors) { @@ -82,7 +78,7 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { for (ControlError validationError : validationErrors) { Object category = validationError.getCategory() == null ? - n("coser.ui.control.error.allCategories") : validationError.getCategory(); + n("coser.ui.control.error.allCategories") : validationError.getCategory(); // definition du noeud categorie DefaultMutableTreeTableNode categoryNode = nodeCache.get(category); @@ -107,11 +103,11 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { // cas special pour les erreurs DiffCatchLengthControlError // regroupement supplémentaire par espèce if (validationError instanceof DiffCatchLengthControlError) { - DiffCatchLengthControlError diffCatchError = (DiffCatchLengthControlError)validationError; + DiffCatchLengthControlError diffCatchError = (DiffCatchLengthControlError) validationError; String species = diffCatchError.getSpecies(); String speciesCategory = t("coser.ui.control.error.diffcatchlenghtspecies", - project.getDisplaySpeciesText(species)); - + project.getDisplaySpeciesText(species)); + ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), speciesCategory); DefaultMutableTreeTableNode newParent = nodeCache.get(speciesCategory); if (newParent == null) { @@ -126,7 +122,7 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(validationError); parentNode.add(node); } - + setRoot(root); } @@ -138,16 +134,16 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { return 2; } - + @Override public String getColumnName(int columnIndex) { String result = null; switch (columnIndex) { - case 0: - result = t("coser.ui.control.global.message"); - break; + case 0: + result = t("coser.ui.control.global.message"); + break; } return result; } @@ -157,12 +153,12 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { Class<?> result = null; switch (columnIndex) { - case 0: - result = ValidationLevel.class; - break; - case 1: - result = Boolean.class; - break; + case 0: + result = ValidationLevel.class; + break; + case 1: + result = Boolean.class; + break; } return result; } @@ -176,12 +172,12 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { Object result = null; switch (column) { - case 0: - result = node; - break; - default: - result = checkedControlErrors.contains(node); - break; + case 0: + result = node; + break; + default: + result = checkedControlErrors.contains(node); + break; } return result; @@ -198,18 +194,17 @@ public class GlobalControlErrorModel extends DefaultTreeTableModel { @Override public void setValueAt(Object value, Object node, int column) { - - Boolean booleanValue = (Boolean)value; + + Boolean booleanValue = (Boolean) value; if (booleanValue.booleanValue()) { checkedControlErrors.add(node); - } - else { + } else { checkedControlErrors.remove(node); } // recursive check of sub errors int childCount = getChildCount(node); - for (int i = 0 ; i < childCount; ++i) { + for (int i = 0; i < childCount; ++i) { Object child = getChild(node, i); setValueAt(value, child, column); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/SpecyComboModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/SpecyComboModel.java index 18a3cd5..3d1dffb 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/control/SpecyComboModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/control/SpecyComboModel.java @@ -22,24 +22,19 @@ package fr.ifremer.coser.ui.control; -import java.util.List; - import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; +import java.util.List; /** * Model de selection d'especu utilise sur la dialog de graph pour * changer l'espece sur laquelle le graphique porte. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SpecyComboModel extends AbstractListModel implements ComboBoxModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<String> species; @@ -71,7 +66,7 @@ public class SpecyComboModel extends AbstractListModel implements ComboBoxModel public Object getElementAt(int index) { return species.get(index); } - + public int getIndexOf(Object o) { return species.indexOf(o); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/Freize.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/Freize.jaxx index 8450526..0864312 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/Freize.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/Freize.jaxx @@ -20,96 +20,96 @@ #L% --> <JPanel layout="{new GridLayout(0, 5)}" - border="{BorderFactory.createLineBorder(Color.BLACK)}"> + border="{BorderFactory.createLineBorder(Color.BLACK)}"> - <import> + <import> java.awt.Color javax.swing.BorderFactory fr.ifremer.coser.ui.CoserFrame - </import> + </import> - <FreizeModel id="model" javaBean="new FreizeModel()" /> - <FreizeHandler id="handler" constructorParams="this" model="{getModel()}" /> + <FreizeModel id="model" javaBean="new FreizeModel()"/> + <FreizeHandler id="handler" constructorParams="this" model="{getModel()}"/> - <Table id="step0Panel" border="{BorderFactory.createEtchedBorder()}"> - <row> - <cell columns="2"> - <JLabel text="coser.ui.freize.projectstep" font-weight="bold" /> - </cell> - </row> - <row> - <cell weightx="1" anchor="center"> - <JButton text='coser.ui.freize.projectcreate' - onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showProjectCreationView()"/> - </cell> - <cell weightx="1" anchor="center"> - <JButton text='coser.ui.freize.projectopen' - onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showProjectOpenView()"/> - </cell> - </row> - </Table> + <Table id="step0Panel" border="{BorderFactory.createEtchedBorder()}"> + <row> + <cell columns="2"> + <JLabel text="coser.ui.freize.projectstep" font-weight="bold"/> + </cell> + </row> + <row> + <cell weightx="1" anchor="center"> + <JButton text='coser.ui.freize.projectcreate' + onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showProjectCreationView()"/> + </cell> + <cell weightx="1" anchor="center"> + <JButton text='coser.ui.freize.projectopen' + onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showProjectOpenView()"/> + </cell> + </row> + </Table> - <Table id="step1Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> - <row> - <cell columns="2"> - <JLabel text="coser.ui.freize.controlstep" enabled="{model.isStep1Enabled()}" font-weight="bold" /> - </cell> - </row> - <row> - <cell weightx="1" anchor="center"> - <JButton text='coser.ui.freize.controlaction' enabled="{model.isStep1Enabled()}" - onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showControlView()"/> - </cell> - <cell weightx="2" anchor="center"> - <JLabel id="controlStatus" enabled="{model.isStep1Enabled()}" /> - </cell> - </row> - </Table> + <Table id="step1Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> + <row> + <cell columns="2"> + <JLabel text="coser.ui.freize.controlstep" enabled="{model.isStep1Enabled()}" font-weight="bold"/> + </cell> + </row> + <row> + <cell weightx="1" anchor="center"> + <JButton text='coser.ui.freize.controlaction' enabled="{model.isStep1Enabled()}" + onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showControlView()"/> + </cell> + <cell weightx="2" anchor="center"> + <JLabel id="controlStatus" enabled="{model.isStep1Enabled()}"/> + </cell> + </row> + </Table> - <Table id="step2Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> - <row> - <cell columns="2"> - <JLabel text="coser.ui.freize.selectionstep" enabled="{model.isStep2Enabled()}" font-weight="bold" /> - </cell> - </row> - <row> - <cell weightx="2" anchor="center"> - <JButton text='coser.ui.freize.selectionaction' - enabled="{model.isStep2Enabled()}" - onMousePressed="getHandler().showSelectionDropDownMenu(this, event)"/> - </cell> - <cell weightx="2" anchor="center"> - <JLabel id="selectionStatus" enabled="{model.isStep2Enabled()}" /> - </cell> - </row> - </Table> + <Table id="step2Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> + <row> + <cell columns="2"> + <JLabel text="coser.ui.freize.selectionstep" enabled="{model.isStep2Enabled()}" font-weight="bold"/> + </cell> + </row> + <row> + <cell weightx="2" anchor="center"> + <JButton text='coser.ui.freize.selectionaction' + enabled="{model.isStep2Enabled()}" + onMousePressed="getHandler().showSelectionDropDownMenu(this, event)"/> + </cell> + <cell weightx="2" anchor="center"> + <JLabel id="selectionStatus" enabled="{model.isStep2Enabled()}"/> + </cell> + </row> + </Table> - <Table id="step3Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> - <row> - <cell weightx="1"> - <JLabel text="coser.ui.freize.rsufistep" enabled="{model.isStep3Enabled()}" font-weight="bold" /> - </cell> - </row> - <row> - <cell> - <JButton text='coser.ui.freize.rsufiaction' enabled="{model.isStep3Enabled()}" - onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showSelectionView(model.getSelection(), 2)"/> - </cell> - </row> - </Table> + <Table id="step3Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> + <row> + <cell weightx="1"> + <JLabel text="coser.ui.freize.rsufistep" enabled="{model.isStep3Enabled()}" font-weight="bold"/> + </cell> + </row> + <row> + <cell> + <JButton text='coser.ui.freize.rsufiaction' enabled="{model.isStep3Enabled()}" + onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showSelectionView(model.getSelection(), 2)"/> + </cell> + </row> + </Table> - <Table id="step4Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> - <row> - <cell> - <JLabel text="coser.ui.freize.resultstep" enabled="{model.isStep3Enabled()}" font-weight="bold" /> - </cell> - </row> - <row> - <cell weightx="1"> - <JButton text='coser.ui.freize.resultaction' enabled="{model.isStep3Enabled()}" - onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showSelectionView(model.getSelection(), 2)"/> - </cell> - </row> - </Table> + <Table id="step4Panel" border="{BorderFactory.createEtchedBorder()}" decorator="boxed"> + <row> + <cell> + <JLabel text="coser.ui.freize.resultstep" enabled="{model.isStep3Enabled()}" font-weight="bold"/> + </cell> + </row> + <row> + <cell weightx="1"> + <JButton text='coser.ui.freize.resultaction' enabled="{model.isStep3Enabled()}" + onActionPerformed="getParentContainer(CoserFrame.class).getHandler().showSelectionView(model.getSelection(), 2)"/> + </cell> + </row> + </Table> </JPanel> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeHandler.java index f535fe9..a227396 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeHandler.java @@ -21,31 +21,29 @@ */ package fr.ifremer.coser.ui.freize; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.bean.Control; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.ui.CoserFrame; +import fr.ifremer.coser.ui.SelectionsListMenu; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JPopupMenu; import java.awt.Color; import java.awt.Component; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import javax.swing.Icon; -import javax.swing.ImageIcon; -import javax.swing.JPopupMenu; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.bean.Control; -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.ui.CoserFrame; -import fr.ifremer.coser.ui.SelectionsListMenu; +import static org.nuiton.i18n.I18n.t; /** * Panel affichant l'état d'avancement du dans la definition sous forme de frise. - * + * * @author echatellier */ public class FreizeHandler implements PropertyChangeListener { @@ -53,10 +51,15 @@ public class FreizeHandler implements PropertyChangeListener { private static final Log log = LogFactory.getLog(FreizeHandler.class); protected static final Icon OK_ICON = new ImageIcon(FreizeHandler.class.getResource("/icons/button_ok.png")); + protected static final Icon LOCKED_ICON = new ImageIcon(FreizeHandler.class.getResource("/icons/stock_lock.png")); + protected static final Icon BAD_ICON = new ImageIcon(FreizeHandler.class.getResource("/icons/agt_action_fail.png")); + protected static final Color COMPLETE_COLOR = Color.GREEN; + protected static final Color PENDING_COLOR = Color.YELLOW; + protected static final Color DISABLED_COLOR = null; protected FreizeModel model; @@ -80,27 +83,27 @@ public class FreizeHandler implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); - + if (log.isDebugEnabled()) { log.debug("Update freize : " + propertyName); } if (FreizeModel.PROPERTY_PROJECT.equals(propertyName)) { - Project oldProject = (Project)evt.getOldValue(); + Project oldProject = (Project) evt.getOldValue(); if (oldProject != null) { oldProject.getControl().removePropertyChangeListener(this); } - Project newProject = (Project)evt.getNewValue(); + Project newProject = (Project) evt.getNewValue(); if (newProject != null) { newProject.getControl().addPropertyChangeListener(this); } updateUi(); } else if (FreizeModel.PROPERTY_SELECTION.equals(propertyName)) { - Selection oldSelection = (Selection)evt.getOldValue(); + Selection oldSelection = (Selection) evt.getOldValue(); if (oldSelection != null) { oldSelection.removePropertyChangeListener(this); } - Selection newSelection = (Selection)evt.getNewValue(); + Selection newSelection = (Selection) evt.getNewValue(); if (newSelection != null) { newSelection.addPropertyChangeListener(this); } @@ -108,7 +111,7 @@ public class FreizeHandler implements PropertyChangeListener { } else if (Selection.PROPERTY_RSUFI_RESULTS.equals(propertyName)) { updateUi(); } else if (Control.PROPERTY_VALIDATED.equals(propertyName) || - Selection.PROPERTY_VALIDATED.equals(propertyName)) { + Selection.PROPERTY_VALIDATED.equals(propertyName)) { // c'est les même propriétés, mais ca ne pose pas de pbs updateUi(); } @@ -123,7 +126,7 @@ public class FreizeHandler implements PropertyChangeListener { model.setStep1Enabled(false); model.setStep2Enabled(false); model.setStep3Enabled(false); - + view.getStep0Panel().setBackground(DISABLED_COLOR); view.getStep1Panel().setBackground(DISABLED_COLOR); view.getStep2Panel().setBackground(DISABLED_COLOR); @@ -134,12 +137,12 @@ public class FreizeHandler implements PropertyChangeListener { // step 0 if (project != null) { view.getStep0Panel().setBackground(COMPLETE_COLOR); - + // step 1 model.setStep1Enabled(true); if (project.getControl().isValidated()) { view.getStep1Panel().setBackground(COMPLETE_COLOR); - + // step 2 model.setStep2Enabled(true); if (!project.getSelections().isEmpty()) { @@ -160,14 +163,14 @@ public class FreizeHandler implements PropertyChangeListener { // step 3 model.setStep3Enabled(true); view.getStep3Panel().setBackground(COMPLETE_COLOR); - + // step 4 if (selection.getRsufiResults().isEmpty()) { view.getStep4Panel().setBackground(PENDING_COLOR); } else { view.getStep4Panel().setBackground(COMPLETE_COLOR); } - + } else { view.getStep2Panel().setBackground(PENDING_COLOR); view.getSelectionStatus().setIcon(BAD_ICON); @@ -185,7 +188,7 @@ public class FreizeHandler implements PropertyChangeListener { /** * Affiche en popup l'equivalent du menu "Données" > "Selection". - * + * * @param view view */ public void showSelectionDropDownMenu(Freize view, MouseEvent event) { @@ -200,6 +203,6 @@ public class FreizeHandler implements PropertyChangeListener { menu.insert(oldMenu.getMenuComponent(i), 0); } - menu.show((Component)event.getSource(), event.getX(), event.getY()); + menu.show((Component) event.getSource(), event.getX(), event.getY()); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeModel.java index c57cc83..989b6c7 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/freize/FreizeModel.java @@ -22,29 +22,39 @@ package fr.ifremer.coser.ui.freize; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.bean.RSufiResult; import fr.ifremer.coser.bean.Selection; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + public class FreizeModel { public static final String PROPERTY_PROJECT = "project"; + public static final String PROPERTY_SELECTION = "selection"; + public static final String PROPERTY_STEP0_ENABLED = "step0Enabled"; + public static final String PROPERTY_STEP1_ENABLED = "step1Enabled"; + public static final String PROPERTY_STEP2_ENABLED = "step2Enabled"; + public static final String PROPERTY_STEP3_ENABLED = "step3Enabled"; protected Project project; + protected Selection selection; + protected RSufiResult rSufiResult; protected boolean step0Enabled; + protected boolean step1Enabled; + protected boolean step2Enabled; + protected boolean step3Enabled; protected transient PropertyChangeSupport pcs; @@ -72,7 +82,7 @@ public class FreizeModel { this.selection = selection; pcs.firePropertyChange(PROPERTY_SELECTION, oldValue, selection); } - + public boolean isStep0Enabled() { return step0Enabled; } @@ -122,12 +132,12 @@ public class FreizeModel { } public void addPropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + PropertyChangeListener listener) { pcs.addPropertyChangeListener(propertyName, listener); } public void removePropertyChangeListener(String propertyName, - PropertyChangeListener listener) { + PropertyChangeListener listener) { pcs.removePropertyChangeListener(propertyName, listener); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java index a295931..e879bde 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java @@ -22,14 +22,6 @@ package fr.ifremer.coser.ui.maps; -import java.awt.Color; -import java.io.File; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.bbn.openmap.InformationDelegator; import com.bbn.openmap.Layer; import com.bbn.openmap.LayerHandler; @@ -43,22 +35,24 @@ import com.bbn.openmap.layer.location.LocationHandler; import com.bbn.openmap.layer.location.LocationLayer; import com.bbn.openmap.layer.shape.ShapeLayer; import com.bbn.openmap.omGraphics.DrawingAttributes; - import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.util.Coordinate; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.awt.Color; +import java.io.File; +import java.util.List; +import java.util.Properties; /** * Coser map based open openmap. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserMap extends OverlayMapPanel { - /** serialVersionUID. */ + private static final long serialVersionUID = 3134624721243512358L; private static final Log log = LogFactory.getLog(CoserMap.class); @@ -88,9 +82,9 @@ public class CoserMap extends OverlayMapPanel { OMMouseMode mouseMode = new OMMouseMode(); mouseMode.setInfoDelegator(informationDelegator); addMapComponent(mouseMode); - + MapBean mapBean = getMapBean(); - + // centrée sur la france mapBean.setCenter(50f, 0f); mapBean.setScale(16000000f); @@ -121,8 +115,7 @@ public class CoserMap extends OverlayMapPanel { // le fond de carte a une couleur vert/contour noir if (map.getName().equals("cntry00.shp")) { addLayer(map.getAbsolutePath(), map.getAbsolutePath(), "ff000000", "ffbdde83"); - } - else { + } else { // les autres rouge (contour noir) addLayer(map.getAbsolutePath(), map.getAbsolutePath(), "ff000000", "ffFDA908"); } @@ -162,7 +155,7 @@ public class CoserMap extends OverlayMapPanel { /** * Display stata's haul position in an openmap layer - * + * * @param hauls coordinate to display on map */ public void addStataHaulLayer(List<Coordinate> hauls) { @@ -183,21 +176,20 @@ public class CoserMap extends OverlayMapPanel { /** * Add a new layer to the map depending on mapFile extension. - * - * @param layerId layer id - * @param mapFile absolute map fail path + * + * @param layerId layer id + * @param mapFile absolute map fail path * @param lineColor line color * @param fillColor fill color */ protected void addLayer(String layerId, String mapFile, String lineColor, - String fillColor) { + String fillColor) { Layer layer = null; // get layer depending on type if (mapFile.endsWith(".shp")) { layer = getShapeLayer(layerId, mapFile, lineColor, fillColor); - } - else { + } else { if (log.isErrorEnabled()) { log.error("Can't find layer for " + mapFile + " (unknown type)"); } @@ -214,17 +206,16 @@ public class CoserMap extends OverlayMapPanel { /** * Manage shp layer display. - * - * @param layerId layer id - * @param mapFile absolute map fail path + * + * @param layerId layer id + * @param mapFile absolute map fail path * @param lineColor line color * @param fillColor fill color - * * @return shape layer * @see ShapeLayer */ protected Layer getShapeLayer(String layerId, String mapFile, String lineColor, - String fillColor) { + String fillColor) { if (log.isDebugEnabled()) { log.debug("Get ShapeLayer with filename : " + mapFile); @@ -237,7 +228,7 @@ public class CoserMap extends OverlayMapPanel { p.setProperty(layerId + "." + DrawingAttributes.fillPaintProperty, fillColor); shapeLayer.setProperties(layerId, p); shapeLayer.setName(layerId); - + return shapeLayer; } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java index 6857087..d6b7de2 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java @@ -22,41 +22,36 @@ package fr.ifremer.coser.ui.maps; -import java.awt.Color; -import java.awt.Component; -import java.util.List; - import com.bbn.openmap.layer.location.AbstractLocationHandler; import com.bbn.openmap.layer.location.BasicLocation; import com.bbn.openmap.layer.location.Location; import com.bbn.openmap.layer.location.LocationLayer; import com.bbn.openmap.omGraphics.OMGraphicList; - import fr.ifremer.coser.util.Coordinate; +import java.awt.Color; +import java.awt.Component; +import java.util.List; + /** * Handler used by {@link LocationLayer} to provide haul's locations. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class HaulLocationHandler extends AbstractLocationHandler { - protected static Color[] markerColors = new Color[] { - Color.RED, - Color.BLUE, - Color.CYAN, - Color.GRAY, - Color.BLACK, - Color.GREEN, - Color.GREEN.darker(), - Color.MAGENTA, - Color.PINK, - Color.YELLOW, - new Color(165, 3, 63) // purple + protected static Color[] markerColors = new Color[]{ + Color.RED, + Color.BLUE, + Color.CYAN, + Color.GRAY, + Color.BLACK, + Color.GREEN, + Color.GREEN.darker(), + Color.MAGENTA, + Color.PINK, + Color.YELLOW, + new Color(165, 3, 63) // purple }; protected List<Coordinate> coordinates; @@ -102,6 +97,6 @@ public class HaulLocationHandler extends AbstractLocationHandler { */ @Override public void reloadData() { - + } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java index 5b7048b..9d2e6b4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java @@ -22,28 +22,22 @@ package fr.ifremer.coser.ui.option; -import java.awt.Frame; -import java.awt.Window; -import java.io.File; +import fr.ifremer.coser.CoserConfig; +import fr.ifremer.coser.ui.common.CommonHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.swing.JFileChooser; import javax.swing.JTextField; import javax.swing.SwingUtilities; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import fr.ifremer.coser.CoserConfig; -import fr.ifremer.coser.ui.common.CommonHandler; +import java.awt.Frame; +import java.awt.Window; +import java.io.File; /** * Handler for {@link ConfigurationView}. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ConfigurationHandler extends CommonHandler { @@ -52,9 +46,9 @@ public class ConfigurationHandler extends CommonHandler { /** * Display user directory selection dialog and fill given text component * with given file. - * + * * @param configurationView config view - * @param textComponent text component to fill + * @param textComponent text component to fill */ public void selectInputDirectory(ConfigurationView configurationView, JTextField textComponent) { CoserConfig config = configurationView.getContextValue(CoserConfig.class); @@ -71,9 +65,9 @@ public class ConfigurationHandler extends CommonHandler { /** * Display user file selection dialog and fill given text component * with given file. - * + * * @param configurationView config view - * @param textComponent text component to fill + * @param textComponent text component to fill */ public void selectInputFile(ConfigurationView configurationView, JTextField textComponent) { CoserConfig config = configurationView.getContextValue(CoserConfig.class); @@ -89,8 +83,8 @@ public class ConfigurationHandler extends CommonHandler { /** * Save configuration. - * - * @param configurationView + * + * @param configurationView */ public void saveConfiguration(ConfigurationView configurationView) { CoserConfig config = configurationView.getContextValue(CoserConfig.class); @@ -140,12 +134,12 @@ public class ConfigurationHandler extends CommonHandler { log.warn("Can't parse number", ex); } } - + // misc config.setSmtpHost(configurationView.getSmtpHostField().getText()); config.setSupportEmail(configurationView.getSupportEmailField().getText()); try { - config.setSwingFontSize(Integer.parseInt((String)configurationView.getSwingFontSizeField().getSelectedItem())); + config.setSwingFontSize(Integer.parseInt((String) configurationView.getSwingFontSizeField().getSelectedItem())); } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse number", ex); @@ -160,7 +154,7 @@ public class ConfigurationHandler extends CommonHandler { // update font size (font size) Window windows[] = Frame.getWindows(); - for(Window window : windows) { + for (Window window : windows) { SwingUtilities.updateComponentTreeUI(window); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx index 5ad1712..b1e82fe 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx @@ -20,184 +20,186 @@ #L% --> <JDialog title="coser.ui.configuration.title"> - <import> + <import> static fr.ifremer.coser.CoserBusinessConfig.CoserBusinessOption static fr.ifremer.coser.CoserConfig.CoserOption fr.ifremer.coser.CoserConfig - </import> + </import> - <ConfigurationHandler id="handler" /> - <CoserConfig id="config" initializer="getContextValue(CoserConfig.class)" /> + <ConfigurationHandler id="handler"/> + <CoserConfig id="config" initializer="getContextValue(CoserConfig.class)"/> - <Table> - <row> - <cell fill="both" columns="2"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.path"))}'> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.PROJECTS_DIRECTORY.getDescription()}" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="projectDirectoryField" text="{config.getProjectsDirectory().getAbsolutePath()}"/> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputDirectory(this, projectDirectoryField)"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.VALIDATOR_DIRECTORY.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="validatorDirectoryField" text="{config.getValidatorsDirectory().getAbsolutePath()}"/> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputDirectory(this, validatorDirectoryField)"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.REFERENCE_SPECIES.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="referenceSpeciesField" text="{config.getReferenceSpeciesPath()}"/> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, referenceSpeciesField)"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.REFERENCE_TYPE_ESPECES.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="referenceTypeEspecesField" text="{config.getReferenceTypeEspecesPath()}"/> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, referenceTypeEspecesField)"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.WEB_ZONES.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="webZonesField" text="{config.getWebZonesFile().getAbsolutePath()}"/> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, webZonesField)"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.WEB_FRONT_END.getDescription()}" /> - </cell> - <cell columns="2" fill="horizontal"> - <JTextField id="webFrontEndField" text="{config.getWebFrontEnd()}"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill="both" columns="2"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.controlselection"))}'> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.CONTROL_NOBSMIN.getDescription()}" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="controlNobsMinField" text="{String.valueOf(config.getControlNobsmin())}"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="controlDiffCatchLengthField" text="{String.valueOf(config.getControlDiffCatchLength())}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.CONTROL_TYPE_FISH.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="controlTypeFishField" text="{config.getControlTypeFish()}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.CONTROL_STANDARD_DEVIATION_TO_AVERAGE.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="controlStandardDeviationField" text="{String.valueOf(config.getStandardDeviationToAverage())}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="selectionFilterOccurrenceField" text="{String.valueOf(config.getSelectionOccurrenceFilter())}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.SELECTION_FILTER_DENSITY.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="selectionFilterDensityField" text="{String.valueOf(config.getSelectionDensityFilter())}" /> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill="both" columns="2"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.misc"))}'> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserBusinessOption.SMTP_HOST.getDescription()}" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="smtpHostField" text="{config.getSmtpHost()}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserOption.SUPPORT_EMAIL.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JTextField id="supportEmailField" text="{config.getSupportEmail()}" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="{CoserOption.SWING_FONT_SIZE.getDescription()}" /> - </cell> - <cell fill="horizontal"> - <JComboBox id="swingFontSizeField" constructorParams='new Object[]{"12", "14", "16", "18", "20"}' - selectedItem="{String.valueOf(config.getSwingFontSize())}" /> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell anchor="east" weightx="1"> - <JButton text="coser.ui.common.valid" - onActionPerformed="getHandler().saveConfiguration(this)"/> - </cell> - <cell anchor="west" weightx="1"> - <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()"/> - </cell> - </row> - </Table> + <Table> + <row> + <cell fill="both" columns="2"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.path"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.PROJECTS_DIRECTORY.getDescription()}"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="projectDirectoryField" text="{config.getProjectsDirectory().getAbsolutePath()}"/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputDirectory(this, projectDirectoryField)"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.VALIDATOR_DIRECTORY.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="validatorDirectoryField" text="{config.getValidatorsDirectory().getAbsolutePath()}"/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputDirectory(this, validatorDirectoryField)"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.REFERENCE_SPECIES.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="referenceSpeciesField" text="{config.getReferenceSpeciesPath()}"/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, referenceSpeciesField)"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.REFERENCE_TYPE_ESPECES.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="referenceTypeEspecesField" text="{config.getReferenceTypeEspecesPath()}"/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, referenceTypeEspecesField)"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.WEB_ZONES.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="webZonesField" text="{config.getWebZonesFile().getAbsolutePath()}"/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, webZonesField)"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.WEB_FRONT_END.getDescription()}"/> + </cell> + <cell columns="2" fill="horizontal"> + <JTextField id="webFrontEndField" text="{config.getWebFrontEnd()}"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill="both" columns="2"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.controlselection"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.CONTROL_NOBSMIN.getDescription()}"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="controlNobsMinField" text="{String.valueOf(config.getControlNobsmin())}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="controlDiffCatchLengthField" text="{String.valueOf(config.getControlDiffCatchLength())}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.CONTROL_TYPE_FISH.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="controlTypeFishField" text="{config.getControlTypeFish()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.CONTROL_STANDARD_DEVIATION_TO_AVERAGE.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="controlStandardDeviationField" + text="{String.valueOf(config.getStandardDeviationToAverage())}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="selectionFilterOccurrenceField" + text="{String.valueOf(config.getSelectionOccurrenceFilter())}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.SELECTION_FILTER_DENSITY.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="selectionFilterDensityField" text="{String.valueOf(config.getSelectionDensityFilter())}"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill="both" columns="2"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.configuration.category.misc"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserBusinessOption.SMTP_HOST.getDescription()}"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="smtpHostField" text="{config.getSmtpHost()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserOption.SUPPORT_EMAIL.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JTextField id="supportEmailField" text="{config.getSupportEmail()}"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="{CoserOption.SWING_FONT_SIZE.getDescription()}"/> + </cell> + <cell fill="horizontal"> + <JComboBox id="swingFontSizeField" constructorParams='new Object[]{"12", "14", "16", "18", "20"}' + selectedItem="{String.valueOf(config.getSwingFontSize())}"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell anchor="east" weightx="1"> + <JButton text="coser.ui.common.valid" + onActionPerformed="getHandler().saveConfiguration(this)"/> + </cell> + <cell anchor="west" weightx="1"> + <JButton text="coser.ui.common.cancel" + onActionPerformed="dispose()"/> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java index 19573f2..9926a6c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java @@ -22,8 +22,11 @@ package fr.ifremer.coser.ui.option; -import static org.nuiton.i18n.I18n.t; +import org.jdesktop.jxlayer.JXLayer; +import org.jdesktop.jxlayer.plaf.ext.LockableUI; +import javax.swing.JButton; +import javax.swing.JComponent; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Graphics2D; @@ -31,27 +34,20 @@ import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.JButton; -import javax.swing.JComponent; - -import org.jdesktop.jxlayer.JXLayer; -import org.jdesktop.jxlayer.plaf.ext.LockableUI; +import static org.nuiton.i18n.I18n.t; /** * Layer transparent. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class NoCopiedLayerUI extends LockableUI implements ActionListener { - /** serialVersionUID. */ + private static final long serialVersionUID = -616755266651462912L; protected ValidatorDialog view; + protected JButton copyToDiskButton; public NoCopiedLayerUI(ValidatorDialog view) { @@ -68,14 +64,14 @@ public class NoCopiedLayerUI extends LockableUI implements ActionListener { public void actionPerformed(ActionEvent e) { view.getHandler().copyDefaultValidators(view); } - + @Override protected void paintLayer(Graphics2D g2, JXLayer<? extends JComponent> l) { super.paintLayer(g2, l); g2.setColor(new Color(150, 150, 150, 128)); g2.fillRect(0, 0, l.getWidth(), l.getHeight()); } - + @Override public void installUI(JComponent c) { super.installUI(c); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java index e941020..306263c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java @@ -22,38 +22,31 @@ package fr.ifremer.coser.ui.option; -import static org.nuiton.i18n.I18n.t; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.List; - -import javax.swing.JOptionPane; -import javax.swing.tree.TreePath; - +import fr.ifremer.coser.CoserConfig; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.ui.common.CommonHandler; import jaxx.runtime.JAXXContext; - import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.Resource; -import fr.ifremer.coser.CoserConfig; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserConstants.ValidationLevel; -import fr.ifremer.coser.data.Catch; -import fr.ifremer.coser.ui.common.CommonHandler; +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Handler for options. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class OptionHandler extends CommonHandler { @@ -62,18 +55,18 @@ public class OptionHandler extends CommonHandler { /** * Restaure les validateurs par defaut en supprimant ceux * ceux du répertoire et en utilsant le class path. - * + * * @param view view */ public void restoreDefaults(ValidatorDialog view) { - + int answer = JOptionPane.showConfirmDialog(view, t("coser.ui.validators.confirmRestore"), - t("coser.ui.validators.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + t("coser.ui.validators.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (answer == JOptionPane.YES_OPTION) { CoserConfig config = view.getContextValue(CoserConfig.class); File validatorsDir = config.getValidatorsDirectory(); - + try { FileUtils.deleteDirectory(validatorsDir); view.dispose(); @@ -87,15 +80,15 @@ public class OptionHandler extends CommonHandler { /** * Appelé par le layer pour copier les validateurs par defaut sur - * le disque de l'utilisateur. Les copies depuis le classpath (dossier + * le disque de l'utilisateur. Les copies depuis le classpath (dossier * "validators" vers le dossier défini par l'utilisateur. - * + * * @param view view */ public void copyDefaultValidators(ValidatorDialog view) { - + int answer = JOptionPane.showConfirmDialog(view, t("coser.ui.validators.confirmCopyToDisk"), - t("coser.ui.validators.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + t("coser.ui.validators.title"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (answer != JOptionPane.YES_OPTION) { view.dispose(); @@ -109,7 +102,7 @@ public class OptionHandler extends CommonHandler { // ne match que dans coser try { List<URL> resources = Resource.getResources("validators/fr/ifremer/coser/data/.*\\.xml", - Thread.currentThread().getContextClassLoader()); + Thread.currentThread().getContextClassLoader()); if (log.isDebugEnabled()) { log.debug("XML resources found : " + resources.size() + " files"); } @@ -118,15 +111,15 @@ public class OptionHandler extends CommonHandler { String lastPath = path.substring(path.indexOf("/validators/") + "/validators/".length()); String folderPath = lastPath.substring(0, lastPath.lastIndexOf('/')); String name = lastPath.substring(lastPath.lastIndexOf('/') + 1); - + File validatorDirectory = new File(validatorsDir, folderPath); validatorDirectory.mkdirs(); File validatorFile = new File(validatorDirectory, name); - + if (log.isDebugEnabled()) { log.debug("Coping resources " + resource + " to " + validatorFile.getAbsolutePath()); } - + FileUtils.copyURLToFile(resource, validatorFile); } } catch (IOException ex) { @@ -134,12 +127,12 @@ public class OptionHandler extends CommonHandler { log.error("Can't copy validators to file system", ex); } } - + // remove bloking layer //view.getNoCopiedToDiskLayer().setUI(null); // FIXME gros hack, j'arrive pas a enlever le layer view.dispose(); - ValidatorDialog newView = new ValidatorDialog((JAXXContext)view); + ValidatorDialog newView = new ValidatorDialog((JAXXContext) view); newView.setHandler(this); newView.setLocationRelativeTo(view); newView.setVisible(true); @@ -148,13 +141,13 @@ public class OptionHandler extends CommonHandler { /** * Retourne le File qui correspond (ou devrait) a un fichier de validateur * sur le disque. - * + * * @param view view * @return un file (existant... ou pas) */ protected File getValidatorFile(ValidatorDialog view) { File validatorFile = null; - + TreePath selectedPath = view.getValidatorsTree().getSelectionPath(); if (selectedPath != null) { Object[] path = selectedPath.getPath(); @@ -164,8 +157,8 @@ public class OptionHandler extends CommonHandler { // si la selection est un sous context d'une categorie if (path.length == 3) { - Category category = (Category)path[1]; - ValidationLevel level = (ValidationLevel)path[2]; + Category category = (Category) path[1]; + ValidationLevel level = (ValidationLevel) path[2]; String sPackage = Catch.class.getPackage().getName(); @@ -179,17 +172,17 @@ public class OptionHandler extends CommonHandler { validatorFile = new File(validatorsDir, validatorResource); } } - + return validatorFile; } /** * Control selected in tree. - * + * * Dans ce cas, les fichiers sur disque existent, et on ne doit * editer que ceux là, sinon enregistrer un fichier dans le classpath * ca risque pas de fonctionner. - * + * * @param view view */ public void selectValidator(ValidatorDialog view) { @@ -200,7 +193,7 @@ public class OptionHandler extends CommonHandler { TreePath selectedPath = view.getValidatorsTree().getSelectionPath(); if (selectedPath != null) { - + File validatorFile = getValidatorFile(view); if (validatorFile != null) { @@ -215,8 +208,7 @@ public class OptionHandler extends CommonHandler { // selection, enable delete view.getDeleteButton().setEnabled(true); view.getSaveButton().setEnabled(true); - } - else { + } else { view.getValidationEditor().close(); view.getCreateNewButton().setEnabled(true); } @@ -228,7 +220,7 @@ public class OptionHandler extends CommonHandler { /** * Save current file. - * + * * @param view view */ public void saveValidator(ValidatorDialog view) { @@ -237,13 +229,13 @@ public class OptionHandler extends CommonHandler { /** * Create new file. - * + * * @param view view */ public void createNew(ValidatorDialog view) { - + File validatorFile = getValidatorFile(view); - + try { FileUtils.writeStringToFile(validatorFile, ""); } catch (IOException ex) { @@ -254,17 +246,17 @@ public class OptionHandler extends CommonHandler { selectValidator(view); } - + /** * Delete a single validator. - * + * * @param view view */ public void deleteValidator(ValidatorDialog view) { - + File validatorFile = getValidatorFile(view); validatorFile.delete(); selectValidator(view); } - + } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx index 4b704b9..2d8ee50 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx @@ -24,46 +24,49 @@ org.jdesktop.jxlayer.JXLayer org.nuiton.jaxx.widgets.extra.editor.Editor </import> - <OptionHandler id="handler" javaBean="null" /> - <JXLayer id="noCopiedToDiskLayer"> - <Table> - <row> - <cell columns="2" fill="horizontal"> - <JLabel font-style="italic" text="coser.ui.validators.description" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.validators.validators" /> - </cell> - <cell fill="horizontal"> - <JLabel text="coser.ui.validators.content" /> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1"> - <JScrollPane> - <ValidatorsTreeModel id="validatorsTreeModel" /> - <JTree id="validatorsTree" model="{validatorsTreeModel}" cellRenderer="{new ValidatorsTreeRenderer()}" - showsRootHandles="true" rootVisible="false" - onValueChanged="getHandler().selectValidator(this)" /> - </JScrollPane> - </cell> - <cell weightx="2" weighty="1" fill="both"> - <Editor id="validationEditor" /> - </cell> - </row> - <row> - <cell columns="2" anchor="east" insets="0"> - <JPanel> - <JButton text="coser.ui.validators.restoredefaults" onActionPerformed="getHandler().restoreDefaults(this)" /> - <JButton id="createNewButton" text="coser.ui.validators.createNew" onActionPerformed="getHandler().createNew(this)" enabled="false" /> - <JButton id="saveButton" text="coser.ui.validators.saveValidator" onActionPerformed="getHandler().saveValidator(this)" enabled="false" /> - <JButton id="deleteButton" text="coser.ui.validators.deleteValidator" onActionPerformed="getHandler().deleteValidator(this)" enabled="false" /> - <JButton text="coser.ui.validators.close" onActionPerformed="dispose()" /> - </JPanel> - </cell> - </row> - </Table> - </JXLayer> + <OptionHandler id="handler" javaBean="null"/> + <JXLayer id="noCopiedToDiskLayer"> + <Table> + <row> + <cell columns="2" fill="horizontal"> + <JLabel font-style="italic" text="coser.ui.validators.description"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.validators.validators"/> + </cell> + <cell fill="horizontal"> + <JLabel text="coser.ui.validators.content"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1"> + <JScrollPane> + <ValidatorsTreeModel id="validatorsTreeModel"/> + <JTree id="validatorsTree" model="{validatorsTreeModel}" cellRenderer="{new ValidatorsTreeRenderer()}" + showsRootHandles="true" rootVisible="false" + onValueChanged="getHandler().selectValidator(this)"/> + </JScrollPane> + </cell> + <cell weightx="2" weighty="1" fill="both"> + <Editor id="validationEditor"/> + </cell> + </row> + <row> + <cell columns="2" anchor="east" insets="0"> + <JPanel> + <JButton text="coser.ui.validators.restoredefaults" onActionPerformed="getHandler().restoreDefaults(this)"/> + <JButton id="createNewButton" text="coser.ui.validators.createNew" + onActionPerformed="getHandler().createNew(this)" enabled="false"/> + <JButton id="saveButton" text="coser.ui.validators.saveValidator" + onActionPerformed="getHandler().saveValidator(this)" enabled="false"/> + <JButton id="deleteButton" text="coser.ui.validators.deleteValidator" + onActionPerformed="getHandler().deleteValidator(this)" enabled="false"/> + <JButton text="coser.ui.validators.close" onActionPerformed="dispose()"/> + </JPanel> + </cell> + </row> + </Table> + </JXLayer> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java index 8031ac3..b658e65 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java @@ -22,27 +22,21 @@ package fr.ifremer.coser.ui.option; -import java.util.ArrayList; -import java.util.List; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; +import org.apache.commons.lang3.ArrayUtils; +import org.jdesktop.swingx.tree.TreeModelSupport; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; - -import org.apache.commons.lang3.ArrayUtils; -import org.jdesktop.swingx.tree.TreeModelSupport; - -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserConstants.ValidationLevel; +import java.util.ArrayList; +import java.util.List; /** * Validators tree model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ValidatorsTreeModel implements TreeModel { @@ -52,7 +46,7 @@ public class ValidatorsTreeModel implements TreeModel { public ValidatorsTreeModel() { support = new TreeModelSupport(this); - + // les categories contiennent des données non liés aux données List<Category> dataCategories = new ArrayList<Category>(); for (Category category : Category.values()) { @@ -81,8 +75,7 @@ public class ValidatorsTreeModel implements TreeModel { if (parent == getRoot()) { child = dataCategory[index]; - } - else if (parent instanceof Category) { + } else if (parent instanceof Category) { child = ValidationLevel.values()[index]; } @@ -94,13 +87,12 @@ public class ValidatorsTreeModel implements TreeModel { */ @Override public int getChildCount(Object parent) { - + int result = 0; - + if (parent == getRoot()) { result = dataCategory.length; - } - else if (parent instanceof Category) { + } else if (parent instanceof Category) { result = ValidationLevel.values().length; } @@ -129,11 +121,10 @@ public class ValidatorsTreeModel implements TreeModel { @Override public int getIndexOfChild(Object parent, Object child) { int result = -1; - + if (parent == getRoot()) { result = ArrayUtils.indexOf(dataCategory, child); - } - else if (parent instanceof Category) { + } else if (parent instanceof Category) { result = ArrayUtils.indexOf(ValidationLevel.values(), child); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java index a8e07ae..c48010e 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java @@ -22,47 +22,41 @@ package fr.ifremer.coser.ui.option; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; +import java.awt.Component; -import fr.ifremer.coser.CoserConstants.Category; -import fr.ifremer.coser.CoserConstants.ValidationLevel; +import static org.nuiton.i18n.I18n.t; /** * Renderer pour l'arbre des navigateurs. - * + * * Affiche les noms explicites à la place des Category et ValidationLevel. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ValidatorsTreeRenderer extends DefaultTreeCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -2211918491839391988L; @Override public Component getTreeCellRendererComponent(JTree tree, Object value, - boolean sel, boolean expanded, boolean leaf, int row, - boolean hasFocus) { - + boolean sel, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + Object stringValue = value; - + if (value instanceof Category) { - stringValue = t(((Category)value).getTranslationKey()); - } - else if (value instanceof ValidationLevel) { + stringValue = t(((Category) value).getTranslationKey()); + } else if (value instanceof ValidationLevel) { // en attendant mieux - stringValue = t(((ValidationLevel)value).getXWorkContext()); + stringValue = t(((ValidationLevel) value).getXWorkContext()); } return super.getTreeCellRendererComponent(tree, stringValue, sel, expanded, leaf, - row, hasFocus); + row, hasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx index b9713f4..100b64e 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx @@ -20,28 +20,28 @@ #L% --> <Table> - <import> + <import> javax.swing.JCheckBox fr.ifremer.coser.bean.SpeciesFieldType - </import> - <ProjectHandler id="handler" javaBean="null" /> + </import> + <ProjectHandler id="handler" javaBean="null"/> - <!-- Validation --> - <fr.ifremer.coser.bean.Project id="project" /> - <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='createProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> - <BeanValidator id='validatorProject' bean='project' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" - errorTableModel="errorsTableModel"> - <field name="name" component="projectProjectName" /> - <field name="author" component="projectAuthor" /> - <field name="catchFile" component="projectCatchFile" /> - <field name="strataFile" component="projectStrataFile" /> - <field name="lengthFile" component="projectLengthFile" /> - <field name="haulFile" component="projectHaulFile" /> - </BeanValidator> + <!-- Validation --> + <fr.ifremer.coser.bean.Project id="project"/> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='createProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> + <BeanValidator id='validatorProject' bean='project' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="projectProjectName"/> + <field name="author" component="projectAuthor"/> + <field name="catchFile" component="projectCatchFile"/> + <field name="strataFile" component="projectStrataFile"/> + <field name="lengthFile" component="projectLengthFile"/> + <field name="haulFile" component="projectHaulFile"/> + </BeanValidator> - <script><![CDATA[ + <script><![CDATA[ JCheckBox customReferenceCheckBox = new JCheckBox(t("coser.ui.project.useCustomReferenceSpeciesFile")); void $afterCompleteSetup() { fr.ifremer.coser.ui.widgets.ComponentTitledBorder componentBorder = @@ -53,203 +53,208 @@ } ]]></script> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.newProject"))}'> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectname" /> - </cell> - <cell> - <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}' /> - </cell> - <cell anchor="west" weightx="1" fill="horizontal"> - <JTextField id="projectProjectName" text="{getProject().getName()}" /> - <javax.swing.text.Document javaBean="projectProjectName.getDocument()" - onInsertUpdate='getProject().setName(projectProjectName.getText())' - onRemoveUpdate='getProject().setName(projectProjectName.getText())' /> - - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectauthor" /> - </cell> - <cell weightx="1" fill="horizontal" columns="2"> - <JTextField id="projectAuthor" text="{getProject().getAuthor()}" /> - <javax.swing.text.Document javaBean="projectAuthor.getDocument()" - onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' - onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())' /> - - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.catchFile" /> - </cell> - <cell weightx="1" fill="horizontal" columns="2"> - <JTextField id="projectCatchFile" text="{getProject().getCatchFile()}" /> - <javax.swing.text.Document javaBean="projectCatchFile.getDocument()" - onInsertUpdate='getProject().setCatchFile(projectCatchFile.getText())' - onRemoveUpdate='getProject().setCatchFile(projectCatchFile.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton id="projectCapturesSelectButton" text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, projectCatchFile)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.strataFile" /> - </cell> - <cell fill="horizontal" columns="2"> - <JTextField id="projectStrataFile" text="{getProject().getStrataFile()}" /> - <javax.swing.text.Document javaBean="projectStrataFile.getDocument()" - onInsertUpdate='getProject().setStrataFile(projectStrataFile.getText())' - onRemoveUpdate='getProject().setStrataFile(projectStrataFile.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton id="projectStratesFileSelectButton" text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, projectStrataFile)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.lengthFile" /> - </cell> - <cell fill="horizontal" columns="2"> - <JTextField id="projectLengthFile" text="{getProject().getLengthFile()}" /> - <javax.swing.text.Document javaBean="projectLengthFile.getDocument()" - onInsertUpdate='getProject().setLengthFile(projectLengthFile.getText())' - onRemoveUpdate='getProject().setLengthFile(projectLengthFile.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton id="projectSizeFileSelectButton" text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, projectLengthFile)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.haulFile" /> - </cell> - <cell fill="horizontal" columns="2"> - <JTextField id="projectHaulFile" text="{getProject().getHaulFile()}" /> - <javax.swing.text.Document javaBean="projectHaulFile.getDocument()" - onInsertUpdate='getProject().setHaulFile(projectHaulFile.getText())' - onRemoveUpdate='getProject().setHaulFile(projectHaulFile.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton id="projectTraitsFileSelectButton" text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, projectHaulFile)" /> - </cell> - </row> - <row> - <cell anchor="northwest" rows="2"> - <JLabel text="coser.ui.project.maps" /> - </cell> - <cell fill="horizontal" columns="2" rows="2"> - <JScrollPane> - <ProjectMapsListModel id="projectMapsModel" /> - <JList id="projectMaps" model="{projectMapsModel}" /> - </JScrollPane> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.project.addMaps" onActionPerformed="getHandler().selectMapFiles(this)" /> - </cell> - </row> - <row> - <cell anchor="north" fill="horizontal"> - <JButton text="coser.ui.project.removeMaps" enabled="{getProjectMaps().getSelectedIndices().length != 0}" - onActionPerformed="getHandler().removeSelectedMapFiles(this)" /> - </cell> - </row> - <row> - <cell> - <JLabel id="referenceSpeciesDescriptionLabel" text="coser.ui.project.usedReferenceSpeciesFile" - enabled="{!customReferenceCheckBox.isSelected()}" /> - </cell> - <cell anchor="west" columns="2"> - <JLabel id="referenceSpeciesFileLabel" text="{getContextValue(fr.ifremer.coser.CoserConfig.class).getReferenceSpeciesPath()}" - enabled="{!customReferenceCheckBox.isSelected()}" /> - </cell> - </row> - <row> - <cell columns="4" fill="horizontal"> - <Table id="useCustomReferenceFilePanel"> - <row> - <cell> - <JLabel id="customReferenceSpeciesFileLabel" text="coser.ui.project.customReferenceSpeciesFile" - enabled="{customReferenceCheckBox.isSelected()}"/> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="customReferenceSpeciesFileTextField" - enabled="{customReferenceCheckBox.isSelected()}"/> - </cell> - <cell> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectInputFile(this, customReferenceSpeciesFileTextField)" - enabled="{customReferenceCheckBox.isSelected()}"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.storageSpeciesType" /> - </cell> - <cell anchor="west" columns="2"> - <JComboBox id="projectStorageSpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - onItemStateChanged="getProject().setStorageSpeciesType((SpeciesFieldType)projectStorageSpeciesType.getSelectedItem())"/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.displaySpeciesType" /> - </cell> - <cell anchor="west" columns="2"> - <JComboBox id="projectDisplaySpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - onItemStateChanged="getProject().setDisplaySpeciesType((SpeciesFieldType)projectDisplaySpeciesType.getSelectedItem())"/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.outputSpeciesType" /> - </cell> - <cell anchor="west" columns="2"> - <JComboBox id="projectOutputSpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - onItemStateChanged="getProject().setOutputSpeciesType((SpeciesFieldType)projectOutputSpeciesType.getSelectedItem())"/> - </cell> - </row> - <row> - <cell anchor="northwest"> - <JLabel text="coser.ui.project.projectcomment" /> - </cell> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="projectComment" rows="3" /> - </JScrollPane> - <javax.swing.text.Document javaBean="projectComment.getDocument()" - onInsertUpdate='getProject().setComment(projectComment.getText())' - onRemoveUpdate='getProject().setComment(projectComment.getText())' /> - - </cell> - </row> - <row> - <cell columns="4" anchor="east"> - <JButton id="createProjectButton" text="coser.ui.project.createProject" - onActionPerformed="getHandler().createProject(this)" /> - </cell> - </row> - <row> - <cell columns="4" fill="horizontal"> - <fr.ifremer.coser.ui.util.CoserProgressBar id="loadProgressBar" stringPainted="true" /> - </cell> - </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.newProject"))}'> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectname"/> + </cell> + <cell> + <JLabel + text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}'/> + </cell> + <cell anchor="west" weightx="1" fill="horizontal"> + <JTextField id="projectProjectName" text="{getProject().getName()}"/> + <javax.swing.text.Document javaBean="projectProjectName.getDocument()" + onInsertUpdate='getProject().setName(projectProjectName.getText())' + onRemoveUpdate='getProject().setName(projectProjectName.getText())'/> + + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectauthor"/> + </cell> + <cell weightx="1" fill="horizontal" columns="2"> + <JTextField id="projectAuthor" text="{getProject().getAuthor()}"/> + <javax.swing.text.Document javaBean="projectAuthor.getDocument()" + onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' + onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())'/> + + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.catchFile"/> + </cell> + <cell weightx="1" fill="horizontal" columns="2"> + <JTextField id="projectCatchFile" text="{getProject().getCatchFile()}"/> + <javax.swing.text.Document javaBean="projectCatchFile.getDocument()" + onInsertUpdate='getProject().setCatchFile(projectCatchFile.getText())' + onRemoveUpdate='getProject().setCatchFile(projectCatchFile.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton id="projectCapturesSelectButton" text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, projectCatchFile)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.strataFile"/> + </cell> + <cell fill="horizontal" columns="2"> + <JTextField id="projectStrataFile" text="{getProject().getStrataFile()}"/> + <javax.swing.text.Document javaBean="projectStrataFile.getDocument()" + onInsertUpdate='getProject().setStrataFile(projectStrataFile.getText())' + onRemoveUpdate='getProject().setStrataFile(projectStrataFile.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton id="projectStratesFileSelectButton" text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, projectStrataFile)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.lengthFile"/> + </cell> + <cell fill="horizontal" columns="2"> + <JTextField id="projectLengthFile" text="{getProject().getLengthFile()}"/> + <javax.swing.text.Document javaBean="projectLengthFile.getDocument()" + onInsertUpdate='getProject().setLengthFile(projectLengthFile.getText())' + onRemoveUpdate='getProject().setLengthFile(projectLengthFile.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton id="projectSizeFileSelectButton" text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, projectLengthFile)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.haulFile"/> + </cell> + <cell fill="horizontal" columns="2"> + <JTextField id="projectHaulFile" text="{getProject().getHaulFile()}"/> + <javax.swing.text.Document javaBean="projectHaulFile.getDocument()" + onInsertUpdate='getProject().setHaulFile(projectHaulFile.getText())' + onRemoveUpdate='getProject().setHaulFile(projectHaulFile.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton id="projectTraitsFileSelectButton" text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, projectHaulFile)"/> + </cell> + </row> + <row> + <cell anchor="northwest" rows="2"> + <JLabel text="coser.ui.project.maps"/> + </cell> + <cell fill="horizontal" columns="2" rows="2"> + <JScrollPane> + <ProjectMapsListModel id="projectMapsModel"/> + <JList id="projectMaps" model="{projectMapsModel}"/> + </JScrollPane> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.project.addMaps" onActionPerformed="getHandler().selectMapFiles(this)"/> + </cell> + </row> + <row> + <cell anchor="north" fill="horizontal"> + <JButton text="coser.ui.project.removeMaps" enabled="{getProjectMaps().getSelectedIndices().length != 0}" + onActionPerformed="getHandler().removeSelectedMapFiles(this)"/> + </cell> + </row> + <row> + <cell> + <JLabel id="referenceSpeciesDescriptionLabel" text="coser.ui.project.usedReferenceSpeciesFile" + enabled="{!customReferenceCheckBox.isSelected()}"/> + </cell> + <cell anchor="west" columns="2"> + <JLabel id="referenceSpeciesFileLabel" + text="{getContextValue(fr.ifremer.coser.CoserConfig.class).getReferenceSpeciesPath()}" + enabled="{!customReferenceCheckBox.isSelected()}"/> + </cell> + </row> + <row> + <cell columns="4" fill="horizontal"> + <Table id="useCustomReferenceFilePanel"> + <row> + <cell> + <JLabel id="customReferenceSpeciesFileLabel" text="coser.ui.project.customReferenceSpeciesFile" + enabled="{customReferenceCheckBox.isSelected()}"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="customReferenceSpeciesFileTextField" + enabled="{customReferenceCheckBox.isSelected()}"/> + </cell> + <cell> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectInputFile(this, customReferenceSpeciesFileTextField)" + enabled="{customReferenceCheckBox.isSelected()}"/> + </cell> + </row> </Table> - </cell> - </row> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.storageSpeciesType"/> + </cell> + <cell anchor="west" columns="2"> + <JComboBox id="projectStorageSpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + onItemStateChanged="getProject().setStorageSpeciesType((SpeciesFieldType)projectStorageSpeciesType.getSelectedItem())"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.displaySpeciesType"/> + </cell> + <cell anchor="west" columns="2"> + <JComboBox id="projectDisplaySpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + onItemStateChanged="getProject().setDisplaySpeciesType((SpeciesFieldType)projectDisplaySpeciesType.getSelectedItem())"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.outputSpeciesType"/> + </cell> + <cell anchor="west" columns="2"> + <JComboBox id="projectOutputSpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + onItemStateChanged="getProject().setOutputSpeciesType((SpeciesFieldType)projectOutputSpeciesType.getSelectedItem())"/> + </cell> + </row> + <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.project.projectcomment"/> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="projectComment" rows="3"/> + </JScrollPane> + <javax.swing.text.Document javaBean="projectComment.getDocument()" + onInsertUpdate='getProject().setComment(projectComment.getText())' + onRemoveUpdate='getProject().setComment(projectComment.getText())'/> + + </cell> + </row> + <row> + <cell columns="4" anchor="east"> + <JButton id="createProjectButton" text="coser.ui.project.createProject" + onActionPerformed="getHandler().createProject(this)"/> + </cell> + </row> + <row> + <cell columns="4" fill="horizontal"> + <fr.ifremer.coser.ui.util.CoserProgressBar id="loadProgressBar" stringPainted="true"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx index 63a3fb5..4620510 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx @@ -20,122 +20,126 @@ #L% --> <Table> - <import> + <import> fr.ifremer.coser.bean.SpeciesFieldType - </import> + </import> - <ProjectHandler id="handler" javaBean="null" /> + <ProjectHandler id="handler" javaBean="null"/> - <!-- Validation --> - <fr.ifremer.coser.bean.Project id="project" javaBean="null" /> - <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='saveProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> - <BeanValidator id='validatorProject' bean='project' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" - errorTableModel="errorsTableModel"> - <field name="name" component="projectProjectName" /> - <field name="author" component="projectAuthor" /> - </BeanValidator> + <!-- Validation --> + <fr.ifremer.coser.bean.Project id="project" javaBean="null"/> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='saveProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> + <BeanValidator id='validatorProject' bean='project' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="projectProjectName"/> + <field name="author" component="projectAuthor"/> + </BeanValidator> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.editProject"))}'> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectname" /> - </cell> - <cell> - <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}' /> - </cell> - <cell anchor="west" weightx="1" fill="horizontal"> - <JTextField id="projectProjectName" enabled="false" text="{getProject().getName()}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectauthor" /> - </cell> - <cell weightx="1" fill="horizontal" columns="2"> - <JTextField id="projectAuthor" text="{getProject().getAuthor()}" /> - <javax.swing.text.Document javaBean="projectAuthor.getDocument()" - onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' - onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())' /> - </cell> - </row> - <row> - <cell anchor="northwest" rows="2"> - <JLabel text="coser.ui.project.maps" /> - </cell> - <cell fill="horizontal" columns="2" rows="2"> - <JScrollPane> - <ProjectMapsListModel id="projectMapsModel" maps="{getProject().getMaps()}" /> - <JList id="projectMaps" model="{projectMapsModel}" /> - </JScrollPane> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.project.addMaps" onActionPerformed="getHandler().selectMapFiles(this)" /> - </cell> - </row> - <row> - <cell anchor="north" fill="horizontal"> - <JButton text="coser.ui.project.removeMaps" enabled="{getProjectMaps().getSelectedIndices().length != 0}" - onActionPerformed="getHandler().removeSelectedMapFiles(this)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.storageSpeciesType" /> - </cell> - <cell> - <JComboBox id="projectStorageSpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - selectedItem="{getProject().getStorageSpeciesType()}" - enabled="false" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.displaySpeciesType" /> - </cell> - <cell> - <JComboBox id="projectDisplaySpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - selectedItem="{getProject().getDisplaySpeciesType()}" - onItemStateChanged="getProject().setDisplaySpeciesType((SpeciesFieldType)projectDisplaySpeciesType.getSelectedItem())" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.outputSpeciesType" /> - </cell> - <cell> - <JComboBox id="projectOutputSpeciesType" model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" - renderer="{new SpeciesFieldTypeListRenderer()}" - selectedItem="{getProject().getOutputSpeciesType()}" - onItemStateChanged="getProject().setOutputSpeciesType((SpeciesFieldType)projectOutputSpeciesType.getSelectedItem())" /> - </cell> - </row> - <row> - <cell anchor="northwest"> - <JLabel text="coser.ui.project.projectcomment" /> - </cell> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="projectComment" rows="3" text="{getProject().getComment()}"/> - </JScrollPane> - <javax.swing.text.Document javaBean="projectComment.getDocument()" - onInsertUpdate='getProject().setComment(projectComment.getText())' - onRemoveUpdate='getProject().setComment(projectComment.getText())' /> - - </cell> - </row> - <row> - <cell columns="4" anchor="east"> - <JButton id="saveProjectButton" text="coser.ui.project.saveProject" - onActionPerformed="getHandler().saveProject(this)" /> - </cell> - </row> - </Table> - </cell> - </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.editProject"))}'> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectname"/> + </cell> + <cell> + <JLabel + text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}'/> + </cell> + <cell anchor="west" weightx="1" fill="horizontal"> + <JTextField id="projectProjectName" enabled="false" text="{getProject().getName()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectauthor"/> + </cell> + <cell weightx="1" fill="horizontal" columns="2"> + <JTextField id="projectAuthor" text="{getProject().getAuthor()}"/> + <javax.swing.text.Document javaBean="projectAuthor.getDocument()" + onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' + onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())'/> + </cell> + </row> + <row> + <cell anchor="northwest" rows="2"> + <JLabel text="coser.ui.project.maps"/> + </cell> + <cell fill="horizontal" columns="2" rows="2"> + <JScrollPane> + <ProjectMapsListModel id="projectMapsModel" maps="{getProject().getMaps()}"/> + <JList id="projectMaps" model="{projectMapsModel}"/> + </JScrollPane> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.project.addMaps" onActionPerformed="getHandler().selectMapFiles(this)"/> + </cell> + </row> + <row> + <cell anchor="north" fill="horizontal"> + <JButton text="coser.ui.project.removeMaps" enabled="{getProjectMaps().getSelectedIndices().length != 0}" + onActionPerformed="getHandler().removeSelectedMapFiles(this)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.storageSpeciesType"/> + </cell> + <cell> + <JComboBox id="projectStorageSpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + selectedItem="{getProject().getStorageSpeciesType()}" + enabled="false"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.displaySpeciesType"/> + </cell> + <cell> + <JComboBox id="projectDisplaySpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + selectedItem="{getProject().getDisplaySpeciesType()}" + onItemStateChanged="getProject().setDisplaySpeciesType((SpeciesFieldType)projectDisplaySpeciesType.getSelectedItem())"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.outputSpeciesType"/> + </cell> + <cell> + <JComboBox id="projectOutputSpeciesType" + model="{new org.jdesktop.swingx.combobox.EnumComboBoxModel(SpeciesFieldType.class)}" + renderer="{new SpeciesFieldTypeListRenderer()}" + selectedItem="{getProject().getOutputSpeciesType()}" + onItemStateChanged="getProject().setOutputSpeciesType((SpeciesFieldType)projectOutputSpeciesType.getSelectedItem())"/> + </cell> + </row> + <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.project.projectcomment"/> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="projectComment" rows="3" text="{getProject().getComment()}"/> + </JScrollPane> + <javax.swing.text.Document javaBean="projectComment.getDocument()" + onInsertUpdate='getProject().setComment(projectComment.getText())' + onRemoveUpdate='getProject().setComment(projectComment.getText())'/> + + </cell> + </row> + <row> + <cell columns="4" anchor="east"> + <JButton id="saveProjectButton" text="coser.ui.project.saveProject" + onActionPerformed="getHandler().saveProject(this)"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java index fbecd65..b1f9cf9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java @@ -22,25 +22,6 @@ package fr.ifremer.coser.ui.project; -import static org.nuiton.i18n.I18n.t; - -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JTextField; -import javax.swing.SwingWorker; -import javax.swing.filechooser.FileFilter; - -import jaxx.runtime.JAXXUtil; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserConstants.Category; @@ -49,32 +30,45 @@ import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.ui.CoserFrame; import fr.ifremer.coser.ui.common.CommonHandler; +import jaxx.runtime.JAXXUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.SwingWorker; +import javax.swing.filechooser.FileFilter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n.t; /** * Handler for project related ui. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProjectHandler extends CommonHandler { private static final Log log = LogFactory.getLog(ProjectHandler.class); protected JFileChooser mapFileChooser; - + /** * Retourne une unique instance du file chooser pour conserver * le répertoire de sélection d'un appel sur l'autre. - * + * * @return l'unique instance de file chooser */ protected JFileChooser getMapFileChooser() { if (mapFileChooser == null) { mapFileChooser = new JFileChooser(); mapFileChooser.addChoosableFileFilter(new FileFilter() { + @Override public boolean accept(File f) { return f.isDirectory() || f.getName().matches(".*\\.shp"); @@ -92,8 +86,8 @@ public class ProjectHandler extends CommonHandler { /** * Display user file selection dialog and fill given text component * with given file. - * - * @param projectView project view + * + * @param projectView project view * @param textComponent text component to fill */ public void selectInputFile(ProjectCreationView projectView, JTextField textComponent) { @@ -107,26 +101,26 @@ public class ProjectHandler extends CommonHandler { textComponent.setText(selectedFile.getAbsolutePath()); } } - + /** * Display user file selection dialog and fill maps list. - * + * * @param projectView project view */ public void selectMapFiles(ProjectCreationView projectView) { JFileChooser selectFileChooser = getMapFileChooser(); - + int result = selectFileChooser.showOpenDialog(projectView); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = selectFileChooser.getSelectedFile(); projectView.getProjectMapsModel().addMap(selectedFile); } } - + /** * Display user file selection dialog and fill given text component * with given file. - * + * * @param projectView project view */ public void removeSelectedMapFiles(ProjectCreationView projectView) { @@ -135,26 +129,26 @@ public class ProjectHandler extends CommonHandler { projectView.getProjectMapsModel().removeMap(value); } } - + /** * Display user file selection dialog and fill maps list. - * + * * @param projectView project view */ public void selectMapFiles(ProjectEditView projectView) { JFileChooser selectFileChooser = getMapFileChooser(); - + int result = selectFileChooser.showOpenDialog(projectView); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = selectFileChooser.getSelectedFile(); projectView.getProjectMapsModel().addMap(selectedFile); } } - + /** * Display user file selection dialog and fill given text component * with given file. - * + * * @param projectView project view */ public void removeSelectedMapFiles(ProjectEditView projectView) { @@ -163,10 +157,10 @@ public class ProjectHandler extends CommonHandler { projectView.getProjectMapsModel().removeMap(value); } } - + /** * Create project. - * + * * @param projectView project view */ public void createProject(final ProjectCreationView projectView) { @@ -178,8 +172,7 @@ public class ProjectHandler extends CommonHandler { String reftaxSpeciesPath = null; if (projectView.getCustomReferenceCheckBox().isSelected()) { reftaxSpeciesPath = projectView.getCustomReferenceSpeciesFileTextField().getText().trim(); - } - else { + } else { reftaxSpeciesPath = config.getReferenceSpeciesPath(); } @@ -199,19 +192,19 @@ public class ProjectHandler extends CommonHandler { project.setLengthFileName(taillesFile.getName()); project.setHaulFileName(traitsFile.getName()); project.setStrataFileName(stratesFile.getName()); - + // get map list final List<File> newMaps = projectView.getProjectMapsModel().getMaps(); // check some files existences if (!reftaxSpeciesFile.isFile()) { JOptionPane.showMessageDialog(projectView, t("coser.ui.project.createProjectMissingReftax"), - t("coser.ui.project.missingFile"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.project.missingFile"), JOptionPane.ERROR_MESSAGE); return; } if (!codeTypeEspeceFile.isFile()) { JOptionPane.showMessageDialog(projectView, t("coser.ui.project.createProjectMissingCodeTypeSpecies"), - t("coser.ui.project.missingFile"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.project.missingFile"), JOptionPane.ERROR_MESSAGE); return; } @@ -229,8 +222,9 @@ public class ProjectHandler extends CommonHandler { setWaitCursor(projectView); SwingWorker<Project, Void> task = new SwingWorker<Project, Void>() { + protected long before = System.currentTimeMillis(); - + @Override protected Project doInBackground() { ProjectService projectService = projectView.getContextValue(ProjectService.class); @@ -255,7 +249,7 @@ public class ProjectHandler extends CommonHandler { protected void done() { if (log.isInfoEnabled()) { long after = System.currentTimeMillis(); - log.info("4 import take " + (after-before) + "ms"); + log.info("4 import take " + (after - before) + "ms"); } try { Project resultProject = get(); @@ -266,18 +260,17 @@ public class ProjectHandler extends CommonHandler { } catch (Exception ex) { // conserve le meme mesage que la cause throw new CoserException(ex.getMessage(), ex); - } - finally { + } finally { setDefaultCursor(projectView); } } }; task.execute(); } - + /** * Sauve le projet apres edition. - * + * * @param projectView project edit view */ public void saveProject(ProjectEditView projectView) { @@ -287,30 +280,28 @@ public class ProjectHandler extends CommonHandler { setWaitCursor(projectView); try { - + // get map list List<File> newMaps = projectView.getProjectMapsModel().getMaps(); projectService.saveProject(project, newMaps); parent.getHandler().showSummaryView(); - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't save project", ex); - } - finally { + } finally { setDefaultCursor(projectView); } } - + /** * Reload project (name selected in ui). - * + * * @param projectView view */ public void loadProject(ProjectOpenView projectView) { int selectedIndex = projectView.getProjectsList().getSelectedIndex(); - String projectName = (String)projectView.getProjectsList().getModel().getElementAt(selectedIndex); + String projectName = (String) projectView.getProjectsList().getModel().getElementAt(selectedIndex); ProjectService projectService = projectView.getContextValue(ProjectService.class); CoserFrame parent = projectView.getContextValue(CoserFrame.class, JAXXUtil.PARENT); @@ -324,17 +315,17 @@ public class ProjectHandler extends CommonHandler { log.error("Can't open project", ex); } JOptionPane.showMessageDialog(projectView, ex.getMessage(), t("coser.ui.project.openError"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.ERROR_MESSAGE); } finally { setDefaultCursor(projectView); } } - + /** * Reload project (name selected in ui). - * + * * @param projectView view - * @param event mouse event + * @param event mouse event */ public void loadProjectOnDoubleClick(ProjectOpenView projectView, MouseEvent event) { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectMapsListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectMapsListModel.java index 0dbc6cc..09aaed2 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectMapsListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectMapsListModel.java @@ -22,24 +22,19 @@ package fr.ifremer.coser.ui.project; +import javax.swing.DefaultListModel; import java.io.File; import java.util.ArrayList; import java.util.List; -import javax.swing.DefaultListModel; - /** * Project maps files list model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProjectMapsListModel extends DefaultListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 7354496943155548103L; protected List<File> maps; @@ -51,13 +46,12 @@ public class ProjectMapsListModel extends DefaultListModel { public void setMaps(List<File> maps) { if (maps != null) { this.maps = new ArrayList<File>(maps); - } - else { + } else { this.maps = new ArrayList<File>(); } fireContentsChanged(this, 0, this.maps.size() - 1); } - + public List<File> getMaps() { return maps; } @@ -66,7 +60,7 @@ public class ProjectMapsListModel extends DefaultListModel { maps.add(map); fireContentsChanged(this, 0, maps.size() - 1); } - + public void removeMap(Object map) { maps.remove(map); fireContentsChanged(this, 0, maps.size() - 1); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectNamesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectNamesListModel.java index f33810b..038a473 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectNamesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectNamesListModel.java @@ -22,25 +22,20 @@ package fr.ifremer.coser.ui.project; -import java.util.List; +import fr.ifremer.coser.services.ProjectService; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; - -import fr.ifremer.coser.services.ProjectService; +import java.util.List; /** * Validation categories list model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ProjectNamesListModel extends AbstractListModel implements ComboBoxModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 6700971928409164642L; protected ProjectOpenView view; @@ -84,7 +79,7 @@ public class ProjectNamesListModel extends AbstractListModel implements ComboBox @Override public void setSelectedItem(Object anItem) { this.selectedItem = anItem; - + } /* diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx index 724ff0b..d3652ea 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx @@ -20,34 +20,35 @@ #L% --> <Table> - <ProjectHandler id="handler" javaBean="null" /> + <ProjectHandler id="handler" javaBean="null"/> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.openProjectTitle"))}'> - <row> - <cell anchor="north"> - <JLabel text="coser.ui.project.project" /> - </cell> - <cell anchor="north"> - <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}' /> - </cell> - <cell fill="both" weightx="1"> - <JScrollPane> - <JList id="projectsList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" - model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" - onMouseClicked="getHandler().loadProjectOnDoubleClick(this, event)" /> - </JScrollPane> - </cell> - </row> - <row> - <cell weightx="1" anchor="east" columns="3"> - <JButton text="coser.ui.project.openProject" - enabled="{projectsList.getSelectedIndex() >= 0}" - onActionPerformed="getHandler().loadProject(this)" /> - </cell> - </row> - </Table> - </cell> - </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.openProjectTitle"))}'> + <row> + <cell anchor="north"> + <JLabel text="coser.ui.project.project"/> + </cell> + <cell anchor="north"> + <JLabel + text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator}'/> + </cell> + <cell fill="both" weightx="1"> + <JScrollPane> + <JList id="projectsList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" + model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" + onMouseClicked="getHandler().loadProjectOnDoubleClick(this, event)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell weightx="1" anchor="east" columns="3"> + <JButton text="coser.ui.project.openProject" + enabled="{projectsList.getSelectedIndex() >= 0}" + onActionPerformed="getHandler().loadProject(this)"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectSummaryView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectSummaryView.jaxx index 08cfd8a..590efa3 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectSummaryView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectSummaryView.jaxx @@ -20,110 +20,112 @@ #L% --> <Table> - <ProjectHandler id="handler" javaBean="null" /> + <ProjectHandler id="handler" javaBean="null"/> - <fr.ifremer.coser.bean.Project id="project" javaBean="null" /> + <fr.ifremer.coser.bean.Project id="project" javaBean="null"/> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.summary.title"))}'> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.path" /> - </cell> - <cell anchor="west" weightx="1" fill="horizontal"> - <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator + getProject().getName()}' /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectcreation" /> - </cell> - <cell anchor="west"> - <JLabel text="{java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.SHORT, getContextValue(fr.ifremer.coser.CoserConfig.class).getLocale()).format(getProject().getCreationDate())}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.projectauthor" /> - </cell> - <cell anchor="west"> - <JLabel text="{getProject().getAuthor()}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.catchFileName" /> - </cell> - <cell anchor="west"> - <JLabel text="{getProject().getCatchFileName()}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.haulFileName" /> - </cell> - <cell anchor="west"> - <JLabel text="{getProject().getHaulFileName()}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.strataFileName" /> - </cell> - <cell anchor="west"> - <JLabel text="{getProject().getStrataFileName()}" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.lengthFileName" /> - </cell> - <cell anchor="west"> - <JLabel text="{getProject().getLengthFileName()}" /> - </cell> - </row> - <row> - <cell anchor="northwest"> - <JLabel text="coser.ui.project.projectcomment" /> - </cell> - <cell anchor="west" fill="horizontal"> - <JTextArea text="{getProject().getComment()}" editable="false" rows="3" /> - </cell> - </row> - <row> - <cell weightx="1" columns="2" fill="horizontal"> - <JSeparator /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.validated" /> - </cell> - <cell anchor="west"> - <JPanel> - <JLabel icon='accept.png' visible="{getProject().getControl().isValidated()}" /> - <JLabel icon='cancel.png' visible="{!getProject().getControl().isValidated()}" /> - </JPanel> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.selectionCount" /> - </cell> - <cell anchor="west"> - <JLabel id="projectSelectionCount" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.project.summary.resultCount" /> - </cell> - <cell anchor="west"> - <JLabel id="projectResultCount" /> - </cell> - </row> - </Table> - </cell> - </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.project.summary.title"))}'> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.path"/> + </cell> + <cell anchor="west" weightx="1" fill="horizontal"> + <JLabel + text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getRSufiProjectsDirectory().getAbsolutePath() + java.io.File.separator + getProject().getName()}'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectcreation"/> + </cell> + <cell anchor="west"> + <JLabel + text="{java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.SHORT, getContextValue(fr.ifremer.coser.CoserConfig.class).getLocale()).format(getProject().getCreationDate())}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectauthor"/> + </cell> + <cell anchor="west"> + <JLabel text="{getProject().getAuthor()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.catchFileName"/> + </cell> + <cell anchor="west"> + <JLabel text="{getProject().getCatchFileName()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.haulFileName"/> + </cell> + <cell anchor="west"> + <JLabel text="{getProject().getHaulFileName()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.strataFileName"/> + </cell> + <cell anchor="west"> + <JLabel text="{getProject().getStrataFileName()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.lengthFileName"/> + </cell> + <cell anchor="west"> + <JLabel text="{getProject().getLengthFileName()}"/> + </cell> + </row> + <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.project.projectcomment"/> + </cell> + <cell anchor="west" fill="horizontal"> + <JTextArea text="{getProject().getComment()}" editable="false" rows="3"/> + </cell> + </row> + <row> + <cell weightx="1" columns="2" fill="horizontal"> + <JSeparator/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.validated"/> + </cell> + <cell anchor="west"> + <JPanel> + <JLabel icon='accept.png' visible="{getProject().getControl().isValidated()}"/> + <JLabel icon='cancel.png' visible="{!getProject().getControl().isValidated()}"/> + </JPanel> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.selectionCount"/> + </cell> + <cell anchor="west"> + <JLabel id="projectSelectionCount"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.summary.resultCount"/> + </cell> + <cell anchor="west"> + <JLabel id="projectResultCount"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/SpeciesFieldTypeListRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/SpeciesFieldTypeListRenderer.java index 43e8567..0c22b02 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/project/SpeciesFieldTypeListRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/project/SpeciesFieldTypeListRenderer.java @@ -22,49 +22,48 @@ package fr.ifremer.coser.ui.project; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; +import fr.ifremer.coser.bean.SpeciesFieldType; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; +import java.awt.Component; -import fr.ifremer.coser.bean.SpeciesFieldType; +import static org.nuiton.i18n.I18n.t; /** * List renderer used to render {@link SpeciesFieldType} enum values with * additionnal comment. - * + * * @author echatellier * @since 1.3 */ public class SpeciesFieldTypeListRenderer extends DefaultListCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = 6335214555392070266L; @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { - SpeciesFieldType type = (SpeciesFieldType)value; + SpeciesFieldType type = (SpeciesFieldType) value; String text = type.getReftaxField(); // add another human comment switch (type) { - case C_Valide: - text += " (" + t("coser.ui.project.cValideSpeciesTypeDesc") + ")"; - break; - case C_PERM: - text += " (" + t("coser.ui.project.cPermSpeciesTypeDesc") + ")"; - break; - case L_Valide: - text += " (" + t("coser.ui.project.lValideSpeciesTypeDesc") + ")"; - break; + case C_Valide: + text += " (" + t("coser.ui.project.cValideSpeciesTypeDesc") + ")"; + break; + case C_PERM: + text += " (" + t("coser.ui.project.cPermSpeciesTypeDesc") + ")"; + break; + case L_Valide: + text += " (" + t("coser.ui.project.lValideSpeciesTypeDesc") + ")"; + break; } return super.getListCellRendererComponent(list, text, index, isSelected, - cellHasFocus); + cellHasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultHandler.java index 4a666f4..c0aef67 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultHandler.java @@ -51,10 +51,8 @@ import static org.nuiton.i18n.I18n.t; * Handler for rsufi result management. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ + * + * <p/> */ public class GlobalResultHandler extends CommonHandler { @@ -172,6 +170,7 @@ public class GlobalResultHandler extends CommonHandler { if (CollectionUtils.isNotEmpty(selectedResults)) { SwingWorker<String, Void> task = new SwingWorker<String, Void>() { + @Override protected String doInBackground() { try { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultRenderer.java index c4c3e51..5433ae9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultRenderer.java @@ -32,7 +32,7 @@ import java.awt.Component; /** * Created on 3/17/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GlobalResultRenderer extends DefaultTableCellRenderer { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultTableModel.java index 4fa0e6b..0380fd4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultTableModel.java @@ -35,7 +35,7 @@ import static org.nuiton.i18n.I18n.t; /** * Created on 3/17/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GlobalResultTableModel extends AbstractTableModel { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultZoneRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultZoneRenderer.java index d27bfd7..b0d3970 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultZoneRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/publication/GlobalResultZoneRenderer.java @@ -36,7 +36,7 @@ import java.awt.Component; */ public class GlobalResultZoneRenderer extends DefaultTableCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -9030155088814184637L; protected SelectUploadResultView view; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ExportUploadDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ExportUploadDialog.jaxx index 41d8ebf..987d23b 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ExportUploadDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ExportUploadDialog.jaxx @@ -21,65 +21,65 @@ --> <!--@Deprecated--> <JDialog title="coser.ui.uploadresult.exportUploadTitle" modal="true"> - <Table> - <ResultHandler id="handler" javaBean="null" /> + <Table> + <ResultHandler id="handler" javaBean="null"/> - <row> - <cell weightx="1" weighty="1" fill="both"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.uploadresult.extractChoice"))}'> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.uploadresult.extractTo" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="extractToTextField" /> - </cell> - <cell> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectExportDirectory(this, extractToTextField)" /> - </cell> - </row> - <row> - <cell columns="3" anchor="east"> - <JButton text="coser.ui.uploadresult.extract" - onActionPerformed="getHandler().performExtractResult(this)" /> - </cell> - </row> - </Table> + <row> + <cell weightx="1" weighty="1" fill="both"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.uploadresult.extractChoice"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.uploadresult.extractTo"/> </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.uploadresult.uploadChoice"))}'> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.uploadresult.uploadLogin" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="uploadLogintextField" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.uploadresult.uploadPassword" /> - </cell> - <cell fill="horizontal"> - <JPasswordField id="uploadPasswordtextField" /> - </cell> - </row> - <row> - <cell columns="2" anchor="east"> - <JButton text="coser.ui.uploadresult.upload" - onActionPerformed="getHandler().performUploadResult(this)" /> - </cell> - </row> - <row> - <cell weightx="1" fill="horizontal" columns="2"> - <fr.ifremer.coser.ui.util.CoserProgressBar id="uploadProgressBar" stringPainted="true" /> - </cell> - </row> - </Table> + <cell weightx="1" fill="horizontal"> + <JTextField id="extractToTextField"/> </cell> - </row> - </Table> + <cell> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectExportDirectory(this, extractToTextField)"/> + </cell> + </row> + <row> + <cell columns="3" anchor="east"> + <JButton text="coser.ui.uploadresult.extract" + onActionPerformed="getHandler().performExtractResult(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.uploadresult.uploadChoice"))}'> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.uploadresult.uploadLogin"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="uploadLogintextField"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.uploadresult.uploadPassword"/> + </cell> + <cell fill="horizontal"> + <JPasswordField id="uploadPasswordtextField"/> + </cell> + </row> + <row> + <cell columns="2" anchor="east"> + <JButton text="coser.ui.uploadresult.upload" + onActionPerformed="getHandler().performUploadResult(this)"/> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal" columns="2"> + <fr.ifremer.coser.ui.util.CoserProgressBar id="uploadProgressBar" stringPainted="true"/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultHandler.java index 64d7a30..d43668e 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultHandler.java @@ -22,24 +22,6 @@ package fr.ifremer.coser.ui.result; -import static org.nuiton.i18n.I18n.t; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JTextField; -import javax.swing.SwingWorker; - -import jaxx.runtime.JAXXUtil; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserException; @@ -48,21 +30,32 @@ import fr.ifremer.coser.services.WebService; import fr.ifremer.coser.ui.common.CommonHandler; import fr.ifremer.coser.ui.util.CoserProgressBar; import fr.ifremer.coser.ui.util.ErrorHelper; +import jaxx.runtime.JAXXUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.SwingWorker; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Handler for rsufi result management. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ResultHandler extends CommonHandler { /** * Initialise la vue (principalement en recuperant les données. - * + * * @param view view */ public void init(SelectUploadResultView view) { @@ -94,10 +87,10 @@ public class ResultHandler extends CommonHandler { Date beginDate = view.getFilterBeginDate().getDate(); Date endDate = view.getFilterEndDate().getDate(); boolean onlyPubliable = view.getPubliableResults().isSelected(); - + // get result WebService webService = view.getContextValue(WebService.class); - + try { List<RSufiResultPath> results = webService.findAllProjectWithResult(beginDate, endDate, onlyPubliable); view.getAvailableResultTableModel().setResultPaths(results); @@ -108,7 +101,7 @@ public class ResultHandler extends CommonHandler { /** * Add selected result in available table to selected table. - * + * * @param view view */ public void addAvailableResult(SelectUploadResultView view) { @@ -120,7 +113,7 @@ public class ResultHandler extends CommonHandler { RSufiResultPath resultData = view.getAvailableResultTableModel().getResultPaths().get(selectedAvailableRow); if (!currentResult.contains(resultData)) { currentResult.add(resultData); - + // indicator results are auto selected // can be done only here view.getSelectedResultTableModel().getIndicatorResults().add(resultData); @@ -135,14 +128,14 @@ public class ResultHandler extends CommonHandler { /** * Remove selected result from selected list. - * + * * @param view view */ public void removeSelectedResult(SelectUploadResultView view) { List<RSufiResultPath> currentResult = view.getSelectedResultTableModel().getResultPaths(); int[] selectedSelectedRows = view.getSelectedResultTable().getSelectedRows(); // need to remove reverse order - for (int index = selectedSelectedRows.length - 1 ; index >= 0 ; --index) { + for (int index = selectedSelectedRows.length - 1; index >= 0; --index) { int selectedSelectedRow = selectedSelectedRows[index]; currentResult.remove(selectedSelectedRow); } @@ -171,18 +164,18 @@ public class ResultHandler extends CommonHandler { if (CollectionUtils.isNotEmpty(selectedResults)) { SwingWorker<String, Void> task = new SwingWorker<String, Void>() { + @Override protected String doInBackground() { try { setWaitCursor(view); - + // get progress bar CoserProgressBar progressBar = view.getUploadProgressBar(); WebService webService = view.getContextValue(WebService.class); String status = webService.performResultUpload(selectedResults, indicatorResults, mapResults, publishDataResults, login, password, progressBar); return status; - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException(ex.getMessage(), ex); } } @@ -193,25 +186,22 @@ public class ResultHandler extends CommonHandler { // laisser cet appel, sinon les exceptions sont silencieuse try { String status = get(); - + if (StringUtils.isNotEmpty(status)) { JOptionPane.showMessageDialog(view, t("coser.ui.uploadresult.resultsuploaderror", status), - t("coser.ui.uploadresult.title"), JOptionPane.ERROR_MESSAGE); - } - else { + t("coser.ui.uploadresult.title"), JOptionPane.ERROR_MESSAGE); + } else { JOptionPane.showMessageDialog(view, t("coser.ui.uploadresult.resultsuploaded"), - t("coser.ui.uploadresult.title"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.uploadresult.title"), JOptionPane.INFORMATION_MESSAGE); } - + view.dispose(); - } - catch (Exception ex) { + } catch (Exception ex) { //throw new CoserException("Can't get upload status", ex); // FIXME chatellier 20110126 le dispatch global marche pas ? :( ErrorHelper errorHelper = new ErrorHelper(); errorHelper.showErrorDialog(view, ex.getMessage(), ex); - } - finally { + } finally { setDefaultCursor(view); } } @@ -242,20 +232,18 @@ public class ResultHandler extends CommonHandler { webService.performResultExtract(selectedResult, publishDataResults, extractDirectory); JOptionPane.showMessageDialog(view, t("coser.ui.uploadresult.resultsextracted"), - t("coser.ui.uploadresult.title"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.uploadresult.title"), JOptionPane.INFORMATION_MESSAGE); view.dispose(); - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { throw new CoserException("Can't upload results", ex); - } - finally { + } finally { setDefaultCursor(view); } } /** * Just display export / upload dialog. - * + * * @param view parent view */ public void showExportUploadDialog(SelectUploadResultView view) { @@ -267,8 +255,8 @@ public class ResultHandler extends CommonHandler { /** * Select result file (directory only). - * - * @param view view + * + * @param view view * @param textComponent text component to set selected file */ public void selectExportDirectory(ExportUploadDialog view, JTextField textComponent) { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java index fb5e6da..1b2311d 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java @@ -22,36 +22,31 @@ package fr.ifremer.coser.ui.result; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.bean.RSufiResult; +import fr.ifremer.coser.bean.Selection; +import fr.ifremer.coser.ui.selection.SelectionRsufiView; +import javax.swing.table.AbstractTableModel; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import javax.swing.table.AbstractTableModel; - -import fr.ifremer.coser.bean.RSufiResult; -import fr.ifremer.coser.bean.Selection; -import fr.ifremer.coser.ui.selection.SelectionRsufiView; +import static org.nuiton.i18n.I18n.t; /** * Modele de la table des résultats RSufi. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ResultTableModel extends AbstractTableModel implements PropertyChangeListener { - /** serialVersionUID. */ + private static final long serialVersionUID = -1192463259386773117L; protected Selection selection; public ResultTableModel(SelectionRsufiView view) { selection = view.getContextValue(Selection.class); - + selection.addPropertyChangeListener(Selection.PROPERTY_RSUFI_RESULTS, this); } @@ -71,33 +66,33 @@ public class ResultTableModel extends AbstractTableModel implements PropertyChan return 7; } - + @Override public String getColumnName(int column) { String name = null; switch (column) { - case 0: - name = t("coser.ui.result.table.resultName"); - break; - case 1: - name = t("coser.ui.result.table.rsufiVersion"); - break; - case 2: - name = t("coser.ui.result.table.zone"); - break; - case 3: - name = t("coser.ui.result.table.estComIndFile"); - break; - case 4: - name = t("coser.ui.result.table.estPopIndFile"); - break; - case 5: - name = t("coser.ui.result.table.maps"); - break; - case 6: - name = t("coser.ui.result.table.otherfiles"); - break; + case 0: + name = t("coser.ui.result.table.resultName"); + break; + case 1: + name = t("coser.ui.result.table.rsufiVersion"); + break; + case 2: + name = t("coser.ui.result.table.zone"); + break; + case 3: + name = t("coser.ui.result.table.estComIndFile"); + break; + case 4: + name = t("coser.ui.result.table.estPopIndFile"); + break; + case 5: + name = t("coser.ui.result.table.maps"); + break; + case 6: + name = t("coser.ui.result.table.otherfiles"); + break; } return name; } @@ -111,27 +106,27 @@ public class ResultTableModel extends AbstractTableModel implements PropertyChan Object result = null; RSufiResult rsufiResult = getValue(rowIndex); switch (columnIndex) { - case 0: - result = rsufiResult.getName(); - break; - case 1: - result = rsufiResult.getRsufiVersion(); - break; - case 2: - result = rsufiResult.getZone(); - break; - case 3: - result = rsufiResult.getEstComIndName(); - break; - case 4: - result = rsufiResult.getEstPopIndName(); - break; - case 5: - result = rsufiResult.isMapsAvailable(); - break; - case 6: - result = !rsufiResult.getOtherFiles().isEmpty(); - break; + case 0: + result = rsufiResult.getName(); + break; + case 1: + result = rsufiResult.getRsufiVersion(); + break; + case 2: + result = rsufiResult.getZone(); + break; + case 3: + result = rsufiResult.getEstComIndName(); + break; + case 4: + result = rsufiResult.getEstPopIndName(); + break; + case 5: + result = rsufiResult.isMapsAvailable(); + break; + case 6: + result = !rsufiResult.getOtherFiles().isEmpty(); + break; } return result; @@ -139,7 +134,7 @@ public class ResultTableModel extends AbstractTableModel implements PropertyChan /** * Get value for wall row. - * + * * @param rowIndex row index * @return rsufi result at row index */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableRenderer.java index d84ee24..e492777 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableRenderer.java @@ -36,14 +36,12 @@ import static org.nuiton.i18n.I18n.t; * Selection result table renderer. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ + * + * <p/> */ public class ResultTableRenderer extends DefaultTableCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -9030155088814184637L; // protected SelectionRsufiView view; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultRenderer.java index 353f31b..bf9279c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultRenderer.java @@ -22,40 +22,35 @@ package fr.ifremer.coser.ui.result; -import java.awt.Component; +import fr.ifremer.coser.bean.RSufiResultPath; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; - -import fr.ifremer.coser.bean.RSufiResultPath; +import java.awt.Component; /** * Available and selected result path renderer. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ @Deprecated public class RsufiResultRenderer extends DefaultTableCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -9030155088814184637L; @Override public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { + boolean isSelected, boolean hasFocus, int row, int column) { Object localValue = value; if (value instanceof RSufiResultPath) { - RSufiResultPath rsufiResultPath = (RSufiResultPath)value; + RSufiResultPath rsufiResultPath = (RSufiResultPath) value; localValue = rsufiResultPath.getProject().getName() + "/" + - rsufiResultPath.getSelection().getName() + "/" + - rsufiResultPath.getRsufiResult().getName(); + rsufiResultPath.getSelection().getName() + "/" + + rsufiResultPath.getRsufiResult().getName(); } return super.getTableCellRendererComponent(table, localValue, isSelected, hasFocus, - row, column); + row, column); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultTableModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultTableModel.java index cadb148..ff8961f 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultTableModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultTableModel.java @@ -22,32 +22,27 @@ package fr.ifremer.coser.ui.result; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.bean.RSufiResult; +import fr.ifremer.coser.bean.RSufiResultPath; +import javax.swing.table.AbstractTableModel; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.swing.table.AbstractTableModel; - -import fr.ifremer.coser.bean.RSufiResult; -import fr.ifremer.coser.bean.RSufiResultPath; +import static org.nuiton.i18n.I18n.t; /** * Modele respresant une liste de resultat avec details sur les resulats * affichés et options de selection. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ @Deprecated public class RsufiResultTableModel extends AbstractTableModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 6404018386062830677L; /** Les données de la table. */ @@ -67,7 +62,7 @@ public class RsufiResultTableModel extends AbstractTableModel { public RsufiResultTableModel(boolean selected) { this.selected = selected; - + // les selections ne sont jamais supprimé // mais vu l'equivalence equals/hascode // ca ne doit pas poser de problemes @@ -112,25 +107,25 @@ public class RsufiResultTableModel extends AbstractTableModel { @Override public String getColumnName(int column) { String result = null; - switch(column) { - case 0: - result = t("coser.ui.uploadresult.creationDate"); - break; - case 1: - result = t("coser.ui.uploadresult.path"); - break; - case 2: - result = t("coser.ui.uploadresult.zone"); - break; - case 3: - result = t("coser.ui.uploadresult.indicatorResult"); - break; - case 4: - result = t("coser.ui.uploadresult.mapResult"); - break; - case 5: - result = t("coser.ui.uploadresult.publishData"); - break; + switch (column) { + case 0: + result = t("coser.ui.uploadresult.creationDate"); + break; + case 1: + result = t("coser.ui.uploadresult.path"); + break; + case 2: + result = t("coser.ui.uploadresult.zone"); + break; + case 3: + result = t("coser.ui.uploadresult.indicatorResult"); + break; + case 4: + result = t("coser.ui.uploadresult.mapResult"); + break; + case 5: + result = t("coser.ui.uploadresult.publishData"); + break; } return result; } @@ -138,25 +133,25 @@ public class RsufiResultTableModel extends AbstractTableModel { @Override public Class<?> getColumnClass(int columnIndex) { Class<?> result = null; - switch(columnIndex) { - case 0: - result = Date.class; - break; - case 1: - result = String[].class; - break; - case 2: - result = String.class; - break; - case 3: - result = Boolean.class; - break; - case 4: - result = Boolean.class; - break; - case 5: - result = Boolean.class; - break; + switch (columnIndex) { + case 0: + result = Date.class; + break; + case 1: + result = String[].class; + break; + case 2: + result = String.class; + break; + case 3: + result = Boolean.class; + break; + case 4: + result = Boolean.class; + break; + case 5: + result = Boolean.class; + break; } return result; } @@ -184,24 +179,24 @@ public class RsufiResultTableModel extends AbstractTableModel { RSufiResultPath data = resultPaths.get(rowIndex); RSufiResult rsufiResult = data.getRsufiResult(); switch (columnIndex) { - case 0: - result = rsufiResult.getCreationDate(); - break; - case 1: - result = data; - break; - case 2: - result = rsufiResult.getZone(); - break; - case 3: - result = indicatorResults.contains(data); - break; - case 4: - result = mapResults.contains(data); - break; - case 5: - result = publishDataResults.contains(data); - break; + case 0: + result = rsufiResult.getCreationDate(); + break; + case 1: + result = data; + break; + case 2: + result = rsufiResult.getZone(); + break; + case 3: + result = indicatorResults.contains(data); + break; + case 4: + result = mapResults.contains(data); + break; + case 5: + result = publishDataResults.contains(data); + break; } return result; @@ -218,31 +213,24 @@ public class RsufiResultTableModel extends AbstractTableModel { RSufiResultPath data = resultPaths.get(rowIndex); if (columnIndex == 3) { - Boolean bValue = (Boolean)aValue; + Boolean bValue = (Boolean) aValue; if (bValue.booleanValue()) { indicatorResults.add(data); - } - else { + } else { indicatorResults.remove(data); } - } - - else if (columnIndex == 4) { - Boolean bValue = (Boolean)aValue; + } else if (columnIndex == 4) { + Boolean bValue = (Boolean) aValue; if (bValue.booleanValue()) { mapResults.add(data); - } - else { + } else { mapResults.remove(data); } - } - - else if (columnIndex == 5) { - Boolean bValue = (Boolean)aValue; + } else if (columnIndex == 5) { + Boolean bValue = (Boolean) aValue; if (bValue.booleanValue()) { publishDataResults.add(data); - } - else { + } else { publishDataResults.remove(data); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultZoneRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultZoneRenderer.java index 610f733..d0a09cb 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultZoneRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/RsufiResultZoneRenderer.java @@ -22,28 +22,23 @@ package fr.ifremer.coser.ui.result; -import java.awt.Component; - -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserException; import fr.ifremer.coser.services.WebService; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Component; + /** * Available and selected result zone renderer. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ @Deprecated public class RsufiResultZoneRenderer extends DefaultTableCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -9030155088814184637L; protected SelectUploadResultView view; @@ -54,14 +49,14 @@ public class RsufiResultZoneRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { + boolean isSelected, boolean hasFocus, int row, int column) { // get web service WebService webService = view.getContextValue(WebService.class); Object localValue = value; if (value != null && value instanceof String) { - String zoneId = (String)value; + String zoneId = (String) value; try { localValue = webService.getZoneFullName(zoneId); } catch (CoserBusinessException ex) { @@ -69,6 +64,6 @@ public class RsufiResultZoneRenderer extends DefaultTableCellRenderer { } } return super.getTableCellRendererComponent(table, localValue, isSelected, hasFocus, - row, column); + row, column); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectUploadResultView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectUploadResultView.jaxx index 29d4bcb..95a3557 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectUploadResultView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectUploadResultView.jaxx @@ -19,90 +19,90 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> - <!--@Deprecated--> +<!--@Deprecated--> <Table> - <ResultHandler id="handler" javaBean="null" /> + <ResultHandler id="handler" javaBean="null"/> - <row> - <cell weightx="1" fill="horizontal"> - <JLabel text="coser.ui.uploadresult.explanation" /> - </cell> - </row> - <row> - <cell weightx="1" fill="horizontal"> - <JLabel text="coser.ui.uploadresult.availableResults" /> - </cell> - </row> - <row> - <cell weightx="1" fill="horizontal"> - <Table> - <row> - <cell> - <JLabel text="coser.ui.uploadresult.filter.beginDate" /> - </cell> - <cell> - <JXDatePicker id="filterBeginDate" - onActionPerformed="getHandler().updateAvailableResultsFilter(this)" /> - </cell> - <cell> - <JLabel text="coser.ui.uploadresult.filter.endDate" /> - </cell> - <cell> - <JXDatePicker id="filterEndDate" - onActionPerformed="getHandler().updateAvailableResultsFilter(this)" /> - </cell> - <cell> - <JLabel text="coser.ui.uploadresult.filter.publiableResults" /> - </cell> - <cell> - <JCheckBox id="publiableResults" selected="true" - onActionPerformed="getHandler().updateAvailableResultsFilter(this)" /> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both"> - <JScrollPane> - <RsufiResultTableModel id="availableResultTableModel" initializer='new RsufiResultTableModel(false)' /> - <JTable id="availableResultTable" model="{getAvailableResultTableModel()}"/> - <ListSelectionModel javaBean="availableResultTable.getSelectionModel()" - onValueChanged="addResultButton.setEnabled(getAvailableResultTable().getSelectedRow() != -1)" /> - </JScrollPane> - </cell> - </row> - <row> - <cell weightx="1" anchor="center"> - <JButton id="addResultButton" text="coser.ui.uploadresult.addResults" - onActionPerformed="getHandler().addAvailableResult(this)" enabled="false" /> - </cell> - </row> - <row> - <cell weightx="1" fill="horizontal"> - <JLabel text="coser.ui.uploadresult.selectedResults" /> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both"> - <JScrollPane> - <RsufiResultTableModel id="selectedResultTableModel" initializer='new RsufiResultTableModel(true)' /> - <JTable id="selectedResultTable" model="{getSelectedResultTableModel()}" /> - <ListSelectionModel javaBean="selectedResultTable.getSelectionModel()" - onValueChanged="removeResultButton.setEnabled(getSelectedResultTable().getSelectedRow() != -1)" /> - </JScrollPane> - </cell> - </row> - <row> - <cell weightx="1" anchor="center"> - <JButton id="removeResultButton" text="coser.ui.uploadresult.removeResults" - onActionPerformed="getHandler().removeSelectedResult(this)" enabled="false" /> - </cell> - </row> - <row> - <cell weightx="1" anchor="east"> - <JButton text="coser.ui.uploadresult.exportupload" - onActionPerformed="getHandler().showExportUploadDialog(this)"/> - </cell> - </row> + <row> + <cell weightx="1" fill="horizontal"> + <JLabel text="coser.ui.uploadresult.explanation"/> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal"> + <JLabel text="coser.ui.uploadresult.availableResults"/> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table> + <row> + <cell> + <JLabel text="coser.ui.uploadresult.filter.beginDate"/> + </cell> + <cell> + <JXDatePicker id="filterBeginDate" + onActionPerformed="getHandler().updateAvailableResultsFilter(this)"/> + </cell> + <cell> + <JLabel text="coser.ui.uploadresult.filter.endDate"/> + </cell> + <cell> + <JXDatePicker id="filterEndDate" + onActionPerformed="getHandler().updateAvailableResultsFilter(this)"/> + </cell> + <cell> + <JLabel text="coser.ui.uploadresult.filter.publiableResults"/> + </cell> + <cell> + <JCheckBox id="publiableResults" selected="true" + onActionPerformed="getHandler().updateAvailableResultsFilter(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both"> + <JScrollPane> + <RsufiResultTableModel id="availableResultTableModel" initializer='new RsufiResultTableModel(false)'/> + <JTable id="availableResultTable" model="{getAvailableResultTableModel()}"/> + <ListSelectionModel javaBean="availableResultTable.getSelectionModel()" + onValueChanged="addResultButton.setEnabled(getAvailableResultTable().getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell weightx="1" anchor="center"> + <JButton id="addResultButton" text="coser.ui.uploadresult.addResults" + onActionPerformed="getHandler().addAvailableResult(this)" enabled="false"/> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal"> + <JLabel text="coser.ui.uploadresult.selectedResults"/> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both"> + <JScrollPane> + <RsufiResultTableModel id="selectedResultTableModel" initializer='new RsufiResultTableModel(true)'/> + <JTable id="selectedResultTable" model="{getSelectedResultTableModel()}"/> + <ListSelectionModel javaBean="selectedResultTable.getSelectionModel()" + onValueChanged="removeResultButton.setEnabled(getSelectedResultTable().getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell weightx="1" anchor="center"> + <JButton id="removeResultButton" text="coser.ui.uploadresult.removeResults" + onActionPerformed="getHandler().removeSelectedResult(this)" enabled="false"/> + </cell> + </row> + <row> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.uploadresult.exportupload" + onActionPerformed="getHandler().showExportUploadDialog(this)"/> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx index bf85d74..12522d9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx @@ -20,150 +20,150 @@ #L% --> <JDialog title="coser.ui.result.newResult" modal="true"> - <Table> - <fr.ifremer.coser.ui.selection.SelectionHandler id="handler" javaBean="null" /> + <Table> + <fr.ifremer.coser.ui.selection.SelectionHandler id="handler" javaBean="null"/> - <fr.ifremer.coser.bean.RSufiResult id="rsufiResult" javaBean="null" /> - <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='saveResultButton.setEnabled(errorsTableModel.getRowCount()==0)'/> - <BeanValidator id='validatorRSufiResult' bean='rsufiResult' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" - errorTableModel="errorsTableModel"> - <field name="name" component="resultNameField" /> - <field name="rsufiVersion" component="resultRsufiVersion" /> - <field name="estComIndPath" component="estComIndFileTextField" /> - <field name="estPopIndPath" component="estPopIndFileTextField" /> - <field name="mapsPath" component="mapsDirectoryTextField" /> - </BeanValidator> + <fr.ifremer.coser.bean.RSufiResult id="rsufiResult" javaBean="null"/> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='saveResultButton.setEnabled(errorsTableModel.getRowCount()==0)'/> + <BeanValidator id='validatorRSufiResult' bean='rsufiResult' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="resultNameField"/> + <field name="rsufiVersion" component="resultRsufiVersion"/> + <field name="estComIndPath" component="estComIndFileTextField"/> + <field name="estPopIndPath" component="estPopIndFileTextField"/> + <field name="mapsPath" component="mapsDirectoryTextField"/> + </BeanValidator> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.resultName" /> - </cell> - <cell fill="horizontal" columns="2"> - <JTextField id="resultNameField" text="{getRsufiResult().getName()}"/> - <javax.swing.text.Document javaBean="resultNameField.getDocument()" - onInsertUpdate='getRsufiResult().setName(resultNameField.getText())' - onRemoveUpdate='getRsufiResult().setName(resultNameField.getText())' /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.rsufiVersion" /> - </cell> - <cell fill="horizontal" columns="2"> - <JTextField id="resultRsufiVersion" /> - <javax.swing.text.Document javaBean="resultRsufiVersion.getDocument()" - onInsertUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' - onRemoveUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.creationDate" /> - </cell> - <cell fill="horizontal" columns="2"> - <JXDatePicker id="resultCreationDate" date="{new java.util.Date()}" - onActionPerformed="getRsufiResult().setCreationDate(resultCreationDate.getDate())"/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.zone" /> - </cell> - <cell fill="horizontal" columns="2"> - <ZoneComboBoxModel id="resultZoneComboModel" javaBean="ZoneComboBoxModel.newModel(this)" /> - <JComboBox id="resultZoneCombo" model="{getResultZoneComboModel()}" - renderer="{new ZoneComboBoxRenderer()}" - onActionPerformed='getRsufiResult().setZone((String)resultZoneCombo.getSelectedItem())'/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.estComIndFile" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="estComIndFileTextField" /> - <javax.swing.text.Document javaBean="estComIndFileTextField.getDocument()" - onInsertUpdate='getRsufiResult().setEstComIndPath(estComIndFileTextField.getText())' - onRemoveUpdate='getRsufiResult().setEstComIndPath(estComIndFileTextField.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectResultFile(this, estComIndFileTextField)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.estPopIndFile" /> - </cell> - <cell fill="horizontal"> - <JTextField id="estPopIndFileTextField" /> - <javax.swing.text.Document javaBean="estPopIndFileTextField.getDocument()" - onInsertUpdate='getRsufiResult().setEstPopIndPath(estPopIndFileTextField.getText())' - onRemoveUpdate='getRsufiResult().setEstPopIndPath(estPopIndFileTextField.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectResultFile(this, estPopIndFileTextField)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.mapsDirectory" /> - </cell> - <cell fill="horizontal"> - <JTextField id="mapsDirectoryTextField" /> - <javax.swing.text.Document javaBean="mapsDirectoryTextField.getDocument()" - onInsertUpdate='getRsufiResult().setMapsPath(mapsDirectoryTextField.getText())' - onRemoveUpdate='getRsufiResult().setMapsPath(mapsDirectoryTextField.getText())' /> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectMapsDirectory(this, mapsDirectoryTextField)" /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.publiableResult" /> - </cell> - <cell fill="horizontal" columns="2"> - <JCheckBox id="publiableResultCheckBox" - onActionPerformed="getRsufiResult().setPubliableResult(publiableResultCheckBox.isSelected())"/> - </cell> - </row> - <row> - <cell anchor="west" columns="3"> - <JLabel text="coser.ui.result.otherDataFile" /> - </cell> - </row> - <row> - <cell columns="3" weighty="1" fill="both"> - <JScrollPane> - <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel" /> - <JList id="otherDataFileList" model="{otherDataFileListModel}"/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns="3" fill="horizontal" insets="0"> - <Table> - <row> - <cell> - <JButton text="coser.ui.result.addOtherDataFile" - onActionPerformed="getHandler().selectResultFileOrDirectory(this, otherDataFileList)"/> - </cell> - <cell weightx="1" anchor="east"> - <JButton text="coser.ui.result.cancel" - onActionPerformed="dispose()"/> - </cell> - <cell> - <JButton id="saveResultButton" text="coser.ui.result.validNewResult" - onActionPerformed="getHandler().performAddResult(this)"/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.resultName"/> + </cell> + <cell fill="horizontal" columns="2"> + <JTextField id="resultNameField" text="{getRsufiResult().getName()}"/> + <javax.swing.text.Document javaBean="resultNameField.getDocument()" + onInsertUpdate='getRsufiResult().setName(resultNameField.getText())' + onRemoveUpdate='getRsufiResult().setName(resultNameField.getText())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.rsufiVersion"/> + </cell> + <cell fill="horizontal" columns="2"> + <JTextField id="resultRsufiVersion"/> + <javax.swing.text.Document javaBean="resultRsufiVersion.getDocument()" + onInsertUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' + onRemoveUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.creationDate"/> + </cell> + <cell fill="horizontal" columns="2"> + <JXDatePicker id="resultCreationDate" date="{new java.util.Date()}" + onActionPerformed="getRsufiResult().setCreationDate(resultCreationDate.getDate())"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.zone"/> + </cell> + <cell fill="horizontal" columns="2"> + <ZoneComboBoxModel id="resultZoneComboModel" javaBean="ZoneComboBoxModel.newModel(this)"/> + <JComboBox id="resultZoneCombo" model="{getResultZoneComboModel()}" + renderer="{new ZoneComboBoxRenderer()}" + onActionPerformed='getRsufiResult().setZone((String)resultZoneCombo.getSelectedItem())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.estComIndFile"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="estComIndFileTextField"/> + <javax.swing.text.Document javaBean="estComIndFileTextField.getDocument()" + onInsertUpdate='getRsufiResult().setEstComIndPath(estComIndFileTextField.getText())' + onRemoveUpdate='getRsufiResult().setEstComIndPath(estComIndFileTextField.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectResultFile(this, estComIndFileTextField)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.estPopIndFile"/> + </cell> + <cell fill="horizontal"> + <JTextField id="estPopIndFileTextField"/> + <javax.swing.text.Document javaBean="estPopIndFileTextField.getDocument()" + onInsertUpdate='getRsufiResult().setEstPopIndPath(estPopIndFileTextField.getText())' + onRemoveUpdate='getRsufiResult().setEstPopIndPath(estPopIndFileTextField.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectResultFile(this, estPopIndFileTextField)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.mapsDirectory"/> + </cell> + <cell fill="horizontal"> + <JTextField id="mapsDirectoryTextField"/> + <javax.swing.text.Document javaBean="mapsDirectoryTextField.getDocument()" + onInsertUpdate='getRsufiResult().setMapsPath(mapsDirectoryTextField.getText())' + onRemoveUpdate='getRsufiResult().setMapsPath(mapsDirectoryTextField.getText())'/> + </cell> + <cell fill="horizontal"> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectMapsDirectory(this, mapsDirectoryTextField)"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.publiableResult"/> + </cell> + <cell fill="horizontal" columns="2"> + <JCheckBox id="publiableResultCheckBox" + onActionPerformed="getRsufiResult().setPubliableResult(publiableResultCheckBox.isSelected())"/> + </cell> + </row> + <row> + <cell anchor="west" columns="3"> + <JLabel text="coser.ui.result.otherDataFile"/> + </cell> + </row> + <row> + <cell columns="3" weighty="1" fill="both"> + <JScrollPane> + <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel"/> + <JList id="otherDataFileList" model="{otherDataFileListModel}"/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns="3" fill="horizontal" insets="0"> + <Table> + <row> + <cell> + <JButton text="coser.ui.result.addOtherDataFile" + onActionPerformed="getHandler().selectResultFileOrDirectory(this, otherDataFileList)"/> + </cell> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.result.cancel" + onActionPerformed="dispose()"/> + </cell> + <cell> + <JButton id="saveResultButton" text="coser.ui.result.validNewResult" + onActionPerformed="getHandler().performAddResult(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx index dec4686..8146954 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx @@ -20,99 +20,99 @@ #L% --> <JDialog title="coser.ui.result.editResult" modal="true"> - <Table> - <fr.ifremer.coser.ui.selection.SelectionHandler id="handler" javaBean="null" /> + <Table> + <fr.ifremer.coser.ui.selection.SelectionHandler id="handler" javaBean="null"/> - <fr.ifremer.coser.bean.RSufiResult id="rsufiResult" javaBean="null" /> + <fr.ifremer.coser.bean.RSufiResult id="rsufiResult" javaBean="null"/> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.resultName" /> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.resultName"/> + </cell> + <cell fill="horizontal"> + <JTextField id="resultNameField" enabled="false" text="{getRsufiResult().getName()}"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.rsufiVersion"/> + </cell> + <cell fill="horizontal"> + <JTextField id="resultRsufiVersion" text="{getRsufiResult().getRsufiVersion()}"/> + <javax.swing.text.Document javaBean="resultRsufiVersion.getDocument()" + onInsertUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' + onRemoveUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.creationDate"/> + </cell> + <cell fill="horizontal"> + <JXDatePicker id="resultCreationDate" date="{getRsufiResult().getCreationDate()}" + onActionPerformed="getRsufiResult().setCreationDate(resultCreationDate.getDate())"/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.zone"/> + </cell> + <cell fill="horizontal"> + <ZoneComboBoxModel id="resultZoneComboModel" javaBean="ZoneComboBoxModel.newModel(this)" + selectedItem="{getRsufiResult().getZone()}"/> + <JComboBox id="resultZoneCombo" model="{getResultZoneComboModel()}" + renderer="{new ZoneComboBoxRenderer()}" + onActionPerformed='getRsufiResult().setZone((String)resultZoneCombo.getSelectedItem())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.result.publiableResult"/> + </cell> + <cell fill="horizontal"> + <JCheckBox id="publiableResultCheckBox" selected="{getRsufiResult().isPubliableResult()}" + onActionPerformed="getRsufiResult().setPubliableResult(publiableResultCheckBox.isSelected())"/> + </cell> + </row> + <row> + <cell anchor="west" columns="2"> + <JLabel text="coser.ui.result.otherDataFile"/> + </cell> + </row> + <row> + <cell columns="2" weighty="1" fill="both"> + <JScrollPane> + <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel"/> + <JList id="otherDataFileList" model="{otherDataFileListModel}"/> + <ListSelectionModel javaBean="otherDataFileList.getSelectionModel()" + onValueChanged="removeOtherFile.setEnabled(getOtherDataFileList().getSelectedIndex() != -1)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns="2" fill="horizontal" weightx="1"> + <Table> + <row> + <cell> + <JButton text="coser.ui.result.addOtherDataFile" + onActionPerformed="getHandler().selectResultFileOrDirectory(this, otherDataFileList)"/> </cell> - <cell fill="horizontal"> - <JTextField id="resultNameField" enabled="false" text="{getRsufiResult().getName()}"/> + <cell> + <JButton id="removeOtherFile" text="coser.ui.result.removeOtherDataFile" + onActionPerformed="getHandler().removeSelectedFile(this)" + enabled="false"/> </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.rsufiVersion" /> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.result.cancel" + onActionPerformed="dispose()"/> </cell> - <cell fill="horizontal"> - <JTextField id="resultRsufiVersion" text="{getRsufiResult().getRsufiVersion()}" /> - <javax.swing.text.Document javaBean="resultRsufiVersion.getDocument()" - onInsertUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' - onRemoveUpdate='getRsufiResult().setRsufiVersion(resultRsufiVersion.getText())' /> + <cell> + <JButton id="saveResultButton" text="coser.ui.result.validEditResult" + onActionPerformed="getHandler().performEditResult(this)"/> </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.creationDate" /> - </cell> - <cell fill="horizontal"> - <JXDatePicker id="resultCreationDate" date="{getRsufiResult().getCreationDate()}" - onActionPerformed="getRsufiResult().setCreationDate(resultCreationDate.getDate())"/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.zone" /> - </cell> - <cell fill="horizontal"> - <ZoneComboBoxModel id="resultZoneComboModel" javaBean="ZoneComboBoxModel.newModel(this)" - selectedItem="{getRsufiResult().getZone()}"/> - <JComboBox id="resultZoneCombo" model="{getResultZoneComboModel()}" - renderer="{new ZoneComboBoxRenderer()}" - onActionPerformed='getRsufiResult().setZone((String)resultZoneCombo.getSelectedItem())'/> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.result.publiableResult" /> - </cell> - <cell fill="horizontal"> - <JCheckBox id="publiableResultCheckBox" selected="{getRsufiResult().isPubliableResult()}" - onActionPerformed="getRsufiResult().setPubliableResult(publiableResultCheckBox.isSelected())"/> - </cell> - </row> - <row> - <cell anchor="west" columns="2"> - <JLabel text="coser.ui.result.otherDataFile" /> - </cell> - </row> - <row> - <cell columns="2" weighty="1" fill="both"> - <JScrollPane> - <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel" /> - <JList id="otherDataFileList" model="{otherDataFileListModel}"/> - <ListSelectionModel javaBean="otherDataFileList.getSelectionModel()" - onValueChanged="removeOtherFile.setEnabled(getOtherDataFileList().getSelectedIndex() != -1)" /> - </JScrollPane> - </cell> - </row> - <row> - <cell columns="2" fill="horizontal" weightx="1"> - <Table> - <row> - <cell> - <JButton text="coser.ui.result.addOtherDataFile" - onActionPerformed="getHandler().selectResultFileOrDirectory(this, otherDataFileList)"/> - </cell> - <cell> - <JButton id="removeOtherFile" text="coser.ui.result.removeOtherDataFile" - onActionPerformed="getHandler().removeSelectedFile(this)" - enabled="false"/> - </cell> - <cell weightx="1" anchor="east"> - <JButton text="coser.ui.result.cancel" - onActionPerformed="dispose()"/> - </cell> - <cell> - <JButton id="saveResultButton" text="coser.ui.result.validEditResult" - onActionPerformed="getHandler().performEditResult(this)"/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> + </row> + </Table> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxModel.java index 519366f..fe86212 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxModel.java @@ -34,14 +34,12 @@ import javax.swing.DefaultComboBoxModel; * side. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ + * + * <p/> */ public class ZoneComboBoxModel extends DefaultComboBoxModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 4452070553401468762L; protected DataStorage zonesMap; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java index 45f15b5..0edcc7e 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java @@ -22,31 +22,26 @@ package fr.ifremer.coser.ui.result; -import java.awt.Component; - import javax.swing.DefaultListCellRenderer; import javax.swing.JList; +import java.awt.Component; /** * Zone list combo renderer (display zone name for zone id). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ZoneComboBoxRenderer extends DefaultListCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -8231189755539976714L; @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { - String zoneId = (String)value; - ZoneComboBoxModel model = (ZoneComboBoxModel)list.getModel(); + String zoneId = (String) value; + ZoneComboBoxModel model = (ZoneComboBoxModel) list.getModel(); // "id";"facadeid";"facade";"zone";"periode";"serie";"comment";"map" String[] zoneData = model.getZone(zoneId); @@ -56,11 +51,10 @@ public class ZoneComboBoxRenderer extends DefaultListCellRenderer { // mais est la a titre d'information par rapport // à l'affichage cote web zoneName = zoneData[2] + " - " + zoneData[3] + " - " + zoneData[4] + " - " + zoneData[5]; - } - else { + } else { zoneName = zoneId; } return super.getListCellRendererComponent(list, zoneName, index, isSelected, - cellHasFocus); + cellHasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java index 9085b41..6f63e01 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SamplingEffortRenderer.java @@ -22,28 +22,23 @@ package fr.ifremer.coser.ui.selection; -import java.awt.Color; -import java.awt.Component; - -import javax.swing.JTable; - import org.nuiton.math.matrix.gui.MatrixTableModelND; import org.nuiton.math.matrix.gui.MatrixTableModelND.MatrixCellRenderer; +import javax.swing.JTable; +import java.awt.Color; +import java.awt.Component; + /** * Renderer de nombre entier pour le panel matrix de sampling effort. - * + * * Surligne en rouge les valeurs nulle. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SamplingEffortRenderer extends MatrixCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -5652185461372011347L; /** @@ -55,36 +50,34 @@ public class SamplingEffortRenderer extends MatrixCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) { + boolean isSelected, boolean hasFocus, int row, int column) { Component comp = null; - + if (value instanceof Double) { - Double number = (Double)value; + Double number = (Double) value; int intNumber = number.intValue(); - + comp = super.getTableCellRendererComponent(table, intNumber, isSelected, hasFocus, - row, column); - + row, column); + if (intNumber <= 0) { comp.setBackground(Color.RED); - } - else { + } else { if (isSelected) { comp.setBackground(table.getSelectionBackground()); } else { comp.setBackground(table.getBackground()); } } - } - else { + } else { comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, - row, column); + row, column); } return comp; } - + } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx index cd93ba3..affb424 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx @@ -21,7 +21,7 @@ --> <Table> - <import> + <import> java.awt.Dimension java.awt.GridBagLayout fr.ifremer.coser.ui.selection.model.SpeciesListModel @@ -31,9 +31,9 @@ fr.ifremer.coser.ui.util.CoserListSelectionModel fr.ifremer.coser.ui.widgets.AccordionPane fr.ifremer.coser.ui.widgets.AccordionPaneSubPanel - </import> + </import> - <script><![CDATA[ + <script><![CDATA[ void $afterCompleteSetup() { // modification (species -> selection model) filteredSpeciesListModel.addListDataListener((CoserListSelectionModel)filteredSpeciesList.getSelectionModel()); @@ -41,308 +41,313 @@ } ]]></script> - <SelectionHandler id="handler" javaBean="null" /> + <SelectionHandler id="handler" javaBean="null"/> - <Boolean id="creationState" javaBean="false" /> - <Boolean id="yearsValidated" javaBean="false" /> - <Boolean id="strataValidated" javaBean="false" /> - <Boolean id="speciesValidated" javaBean="false" /> + <Boolean id="creationState" javaBean="false"/> + <Boolean id="yearsValidated" javaBean="false"/> + <Boolean id="strataValidated" javaBean="false"/> + <Boolean id="speciesValidated" javaBean="false"/> - <!-- Validation --> - <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> - <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && isSpeciesValidated())'/> - <BeanValidator id='validatorSelection' bean='selection' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" - errorTableModel="errorsTableModel"> - <field name="name" component="detailsSelectionNameField" /> - <field name="description" component="detailsDescriptionSP" /> - </BeanValidator> + <!-- Validation --> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null"/> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0 && isSpeciesValidated())'/> + <BeanValidator id='validatorSelection' bean='selection' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="detailsSelectionNameField"/> + <field name="description" component="detailsDescriptionSP"/> + </BeanValidator> - <row> - <cell weightx="1" insets="0" fill="horizontal" > - <JToolBar floatable="false"> - <JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)" - text="coser.ui.selection.selectionreport" /> - <JToolBar.Separator /> - <JButton icon="arrow_rotate_clockwise.png" onActionPerformed="getHandler().reloadControlData(this)" - text="coser.ui.selection.reloadcontroldata" /> - <Component initializer="javax.swing.Box.createHorizontalGlue()" /> - <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection" - icon="disk.png" onActionPerformed="getHandler().saveSelection(this)" /> - </JToolBar> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both"> - <JSplitPane> - <AccordionPane id="detailAccordionPane" minimumSize="{new Dimension(100, 0)}"> - <AccordionPaneSubPanel title="coser.ui.selection.detail.mainAccordion"> + <row> + <cell weightx="1" insets="0" fill="horizontal"> + <JToolBar floatable="false"> + <JButton icon="report.png" onActionPerformed="getHandler().displayLogReport(this)" + text="coser.ui.selection.selectionreport"/> + <JToolBar.Separator/> + <JButton icon="arrow_rotate_clockwise.png" onActionPerformed="getHandler().reloadControlData(this)" + text="coser.ui.selection.reloadcontroldata"/> + <Component initializer="javax.swing.Box.createHorizontalGlue()"/> + <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection" + icon="disk.png" onActionPerformed="getHandler().saveSelection(this)"/> + </JToolBar> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both"> + <JSplitPane> + <AccordionPane id="detailAccordionPane" minimumSize="{new Dimension(100, 0)}"> + <AccordionPaneSubPanel title="coser.ui.selection.detail.mainAccordion"> + <Table> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.selection.details.name"/> + </cell> + <cell weightx="1" fill="horizontal" columns="3"> + <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}" + enabled="{isCreationState()}"/> + <javax.swing.text.Document javaBean="detailsSelectionNameField.getDocument()" + onInsertUpdate='getSelection().setName(detailsSelectionNameField.getText())' + onRemoveUpdate='getSelection().setName(detailsSelectionNameField.getText())'/> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.selection.details.description"/> + </cell> + <cell weightx="1" fill="horizontal" columns="3"> + <JScrollPane id="detailsDescriptionSP"> + <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3"/> + </JScrollPane> + <javax.swing.text.Document javaBean="detailsDescription.getDocument()" + onInsertUpdate='getSelection().setDescription(detailsDescription.getText())' + onRemoveUpdate='getSelection().setDescription(detailsDescription.getText())'/> + </cell> + </row> + <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.selection.details.comment"/> + </cell> + <cell anchor="north" fill="horizontal" weighty="1" columns="3"> + <JScrollPane id="detailsCommentSP"> + <JTextArea id="detailsComment" text="{getSelection().getComment()}" rows="3"/> + <javax.swing.text.Document javaBean="detailsComment.getDocument()" + onInsertUpdate='getSelection().setComment(detailsComment.getText())' + onRemoveUpdate='getSelection().setComment(detailsComment.getText())'/> + </JScrollPane> + </cell> + </row> + </Table> + </AccordionPaneSubPanel> + <AccordionPaneSubPanel title="coser.ui.selection.detail.yearAccordion"> + <Table> + <row> + <cell anchor="west" columns="2"> + <JLabel text="coser.ui.selection.details.years"/> + </cell> + </row> + <row> + <cell weighty="1" weightx="1" fill="both"> + <JScrollPane> + <YearListModel id="yearsListModel"/> + <JList id="yearsList" model="{yearsListModel}" + onMouseClicked="getHandler().showYearsContextMenu(this, event)" + selectionModel="{new CoserListSelectionModel(yearsList.getSelectionModel(), yearsListModel)}" + onValueChanged="setYearsValidated(false)"/> + <ListSelectionModel id="yearsListSelectionModel" javaBean="yearsList.getSelectionModel()"/> + </JScrollPane> + </cell> + <cell anchor="south"> + <JButton id="validDatesButton" text="coser.ui.selection.details.validYears" + onActionPerformed="getHandler().validSelectionYearsData(this);setYearsValidated(true)" + enabled="{!isYearsValidated()}"/> + </cell> + </row> + </Table> + </AccordionPaneSubPanel> + <AccordionPaneSubPanel title="coser.ui.selection.detail.strataAccordion"> + <Table> + <row> + <cell fill="horizontal"> + <JLabel id="strataLabel" text='{t("coser.ui.selection.details.strata", 0, 0)}'/> + </cell> + </row> + <row> + <cell weightx="1" weighty="2" fill="both" rows="2"> + <JScrollPane> + <StrataListModel id="strataListModel" + onContentsChanged='strataLabel.setText(t("coser.ui.selection.details.strata", strataList.getSelectedIndices().length, strataList.getModel().getSize()))'/> + <JList id="strataList" model="{strataListModel}" + onMouseClicked="getHandler().showStrataContextMenu(this, event)" + selectionModel="{new CoserListSelectionModel(strataList.getSelectionModel(), strataListModel)}" + onValueChanged='setStrataValidated(false); strataLabel.setText(t("coser.ui.selection.details.strata", strataList.getSelectedIndices().length, strataList.getModel().getSize()))'/> + </JScrollPane> + </cell> + <cell anchor="northeast"> + <JButton icon="map.png" toolTipText="coser.ui.selection.details.showMapTip" + onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "ZONEMAP");getHandler().showStataOnMap(this);'/> + </cell> + <cell anchor="northeast"> + <JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpeciesTip" + onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "SPECIESDATA");getHandler().showSamplingEffort(this);'/> + </cell> + </row> + <row> + <cell anchor="south" columns="2"> + <JButton id="validStrataButton" text="coser.ui.selection.details.validStrata" + onActionPerformed="getHandler().validSelectionStrataData(this);setStrataValidated(true)" + enabled="{isYearsValidated() && !isStrataValidated()}"/> + </cell> + </row> + </Table> + </AccordionPaneSubPanel> + <AccordionPaneSubPanel title="coser.ui.selection.detail.speciesAccordion"> + <Table> + <row> + <cell fill="horizontal" columns="4"> + <JLabel id="typeSpeciesLabel" + text='{t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize())}'/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" columns="2"> + <JScrollPane> + <SpeciesTypesListModel id="typeSpeciesModel" constructorParams="this" + onContentsChanged='typeSpeciesLabel.setText(t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))'/> + <JList id="typeSpeciesList" model="{typeSpeciesModel}" + cellRenderer="{new SpeciesTypesRenderer()}" + selectionModel="{new CoserListSelectionModel(typeSpeciesList.getSelectionModel(), typeSpeciesModel)}" + enabled="{isYearsValidated() && isStrataValidated()}" + onValueChanged='validFilterButton.setEnabled(true); typeSpeciesLabel.setText(t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))'/> + </JScrollPane> + </cell> + <cell anchor="south" columns="2"> + <JButton id="validFilterButton" text="coser.ui.selection.details.validFilter" + onActionPerformed="getHandler().updateSelectionSpecies(this);validFilterButton.setEnabled(false)" + enabled="false"/> + </cell> + </row> + <row> + <cell weighty="3" fill="both" columns="4"> + <Table> + <row> + <cell fill="horizontal" columns="2"> + <JLabel id="filteredSpeciesLabel" + text='{t("coser.ui.selection.details.filteredSpecies", 0, 0)}'/> + </cell> + <cell fill="horizontal"> + <JLabel id="selectedSpeciesLabel" + text='{t("coser.ui.selection.details.selectedSpecies", 0, 0)}'/> + </cell> + </row> + <row> + <cell weightx="1" weighty="1" fill="both"> + <JScrollPane> + <SpeciesListModel id="filteredSpeciesListModel" + onContentsChanged='filteredSpeciesLabel.setText(t("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))'/> + <JList id="filteredSpeciesList" model="{filteredSpeciesListModel}" + onMouseClicked="getHandler().showFilteredSpeciesContextMenu(this, event)" + selectionModel="{new CoserListSelectionModel(filteredSpeciesList.getSelectionModel(), filteredSpeciesListModel)}" + enabled="{isYearsValidated() && isStrataValidated()}" + onValueChanged='filteredSpeciesLabel.setText(t("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))'/> + <ListSelectionModel id="filteredSpeciesListSelectionModel" + javaBean="filteredSpeciesList.getSelectionModel()"/> + </JScrollPane> + </cell> + <cell anchor="north" insets="2"> <Table> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.selection.details.name" /> - </cell> - <cell weightx="1" fill="horizontal" columns="3"> - <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}" - enabled="{isCreationState()}"/> - <javax.swing.text.Document javaBean="detailsSelectionNameField.getDocument()" - onInsertUpdate='getSelection().setName(detailsSelectionNameField.getText())' - onRemoveUpdate='getSelection().setName(detailsSelectionNameField.getText())' /> - </cell> - </row> - <row> - <cell anchor="west"> - <JLabel text="coser.ui.selection.details.description" /> - </cell> - <cell weightx="1" fill="horizontal" columns="3"> - <JScrollPane id="detailsDescriptionSP"> - <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3" /> - </JScrollPane> - <javax.swing.text.Document javaBean="detailsDescription.getDocument()" - onInsertUpdate='getSelection().setDescription(detailsDescription.getText())' - onRemoveUpdate='getSelection().setDescription(detailsDescription.getText())' /> - </cell> - </row> - <row> - <cell anchor="northwest"> - <JLabel text="coser.ui.selection.details.comment" /> - </cell> - <cell anchor="north" fill="horizontal" weighty="1" columns="3"> - <JScrollPane id="detailsCommentSP"> - <JTextArea id="detailsComment" text="{getSelection().getComment()}" rows="3" /> - <javax.swing.text.Document javaBean="detailsComment.getDocument()" - onInsertUpdate='getSelection().setComment(detailsComment.getText())' - onRemoveUpdate='getSelection().setComment(detailsComment.getText())' /> - </JScrollPane> - </cell> - </row> - </Table> - </AccordionPaneSubPanel> - <AccordionPaneSubPanel title="coser.ui.selection.detail.yearAccordion"> - <Table> - <row> - <cell anchor="west" columns="2"> - <JLabel text="coser.ui.selection.details.years" /> - </cell> - </row> - <row> - <cell weighty="1" weightx="1" fill="both"> - <JScrollPane> - <YearListModel id="yearsListModel" /> - <JList id="yearsList" model="{yearsListModel}" - onMouseClicked="getHandler().showYearsContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(yearsList.getSelectionModel(), yearsListModel)}" - onValueChanged="setYearsValidated(false)" /> - <ListSelectionModel id="yearsListSelectionModel" javaBean="yearsList.getSelectionModel()" /> - </JScrollPane> - </cell> - <cell anchor="south"> - <JButton id="validDatesButton" text="coser.ui.selection.details.validYears" - onActionPerformed="getHandler().validSelectionYearsData(this);setYearsValidated(true)" - enabled="{!isYearsValidated()}"/> - </cell> - </row> - </Table> - </AccordionPaneSubPanel> - <AccordionPaneSubPanel title="coser.ui.selection.detail.strataAccordion"> - <Table> - <row> - <cell fill="horizontal"> - <JLabel id="strataLabel" text='{t("coser.ui.selection.details.strata", 0, 0)}' /> - </cell> - </row> - <row> - <cell weightx="1" weighty="2" fill="both" rows="2"> - <JScrollPane> - <StrataListModel id="strataListModel" - onContentsChanged='strataLabel.setText(t("coser.ui.selection.details.strata", strataList.getSelectedIndices().length, strataList.getModel().getSize()))'/> - <JList id="strataList" model="{strataListModel}" - onMouseClicked="getHandler().showStrataContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(strataList.getSelectionModel(), strataListModel)}" - onValueChanged='setStrataValidated(false); strataLabel.setText(t("coser.ui.selection.details.strata", strataList.getSelectedIndices().length, strataList.getModel().getSize()))'/> - </JScrollPane> - </cell> - <cell anchor="northeast"> - <JButton icon="map.png" toolTipText="coser.ui.selection.details.showMapTip" - onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "ZONEMAP");getHandler().showStataOnMap(this);' /> - </cell> - <cell anchor="northeast"> - <JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpeciesTip" - onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "SPECIESDATA");getHandler().showSamplingEffort(this);' /> - </cell> - </row> - <row> - <cell anchor="south" columns="2"> - <JButton id="validStrataButton" text="coser.ui.selection.details.validStrata" - onActionPerformed="getHandler().validSelectionStrataData(this);setStrataValidated(true)" - enabled="{isYearsValidated() && !isStrataValidated()}"/> - </cell> - </row> - </Table> - </AccordionPaneSubPanel> - <AccordionPaneSubPanel title="coser.ui.selection.detail.speciesAccordion"> - <Table> - <row> - <cell fill="horizontal" columns="4"> - <JLabel id="typeSpeciesLabel" text='{t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize())}' /> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" columns="2"> - <JScrollPane> - <SpeciesTypesListModel id="typeSpeciesModel" constructorParams="this" - onContentsChanged='typeSpeciesLabel.setText(t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))'/> - <JList id="typeSpeciesList" model="{typeSpeciesModel}" - cellRenderer="{new SpeciesTypesRenderer()}" - selectionModel="{new CoserListSelectionModel(typeSpeciesList.getSelectionModel(), typeSpeciesModel)}" - enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='validFilterButton.setEnabled(true); typeSpeciesLabel.setText(t("coser.ui.selection.details.type", typeSpeciesList.getSelectedIndices().length, typeSpeciesList.getModel().getSize()))' /> - </JScrollPane> - </cell> - <cell anchor="south" columns="2"> - <JButton id="validFilterButton" text="coser.ui.selection.details.validFilter" - onActionPerformed="getHandler().updateSelectionSpecies(this);validFilterButton.setEnabled(false)" - enabled="false"/> - </cell> - </row> - <row> - <cell weighty="3" fill="both" columns="4"> - <Table> - <row> - <cell fill="horizontal" columns="2"> - <JLabel id="filteredSpeciesLabel" text='{t("coser.ui.selection.details.filteredSpecies", 0, 0)}' /> - </cell> - <cell fill="horizontal"> - <JLabel id="selectedSpeciesLabel" text='{t("coser.ui.selection.details.selectedSpecies", 0, 0)}' /> - </cell> - </row> - <row> - <cell weightx="1" weighty="1" fill="both"> - <JScrollPane> - <SpeciesListModel id="filteredSpeciesListModel" - onContentsChanged='filteredSpeciesLabel.setText(t("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))'/> - <JList id="filteredSpeciesList" model="{filteredSpeciesListModel}" - onMouseClicked="getHandler().showFilteredSpeciesContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(filteredSpeciesList.getSelectionModel(), filteredSpeciesListModel)}" - enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='filteredSpeciesLabel.setText(t("coser.ui.selection.details.filteredSpecies", filteredSpeciesList.getSelectedIndices().length, filteredSpeciesList.getModel().getSize()))' /> - <ListSelectionModel id="filteredSpeciesListSelectionModel" javaBean="filteredSpeciesList.getSelectionModel()" /> - </JScrollPane> - </cell> - <cell anchor="north" insets="2"> - <Table> - <row> - <cell insets="0"> - <JButton icon="arrow_right.png" - toolTipText="coser.ui.selection.details.addToSelectedListTip" - onActionPerformed="getHandler().addSelectedFilteredSpecies(this)" - enabled="{getFilteredSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> - </cell> - </row> - <row> - <cell insets="0"> - <JButton icon="arrow_left.png" - toolTipText="coser.ui.selection.details.removeFromSelectedListTip" - onActionPerformed="getHandler().removeSelectedSpecies(this)" - enabled="{getSelectedSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> - </cell> - </row> - <row> - <cell> - <JSeparator /> - </cell> - </row> - <row> - <cell insets="0"> - <JButton icon="stock_select_table.png" - toolTipText="coser.ui.selection.details.selectAllSpeciesTip" - onActionPerformed="getHandler().selectAllListSpecies(this)" /> - </cell> - </row> - <row> - <cell insets="0"> - <JButton icon="stock_select_clear.png" - toolTipText="coser.ui.selection.details.unSelectAllSpeciesTip" - onActionPerformed="getHandler().unSelectAllListSpecies(this)" /> - </cell> - </row> - <row> - <cell insets="0"> - <JButton icon="chart_curve.png" - toolTipText="coser.ui.selection.details.displayDiffCatchLengthGraphTip" - onActionPerformed="getHandler().showSelectedSpeciesGraph(this, null)" - enabled="{isYearsValidated() && isStrataValidated() && (getSelectedSpeciesList().getSelectedIndex() != -1 || getFilteredSpeciesList().getSelectedIndex() != -1)}" /> - </cell> - </row> - - <row> - <cell insets="0"> - <JButton icon="arrow_jion_up.png" - toolTipText="coser.ui.selection.details.mergeSpeciesTip" - onActionPerformed="getHandler().showSpeciesMergeDialog(this)" - enabled="{getFilteredSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> - </cell> - </row> - </Table> - </cell> - <cell weightx="1" weighty="1" fill="both"> - <JScrollPane> - <SpeciesListModel id="selectedSpeciesListModel" - onContentsChanged='setSpeciesValidated(false);selectedSpeciesLabel.setText(t("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/> - <JList id="selectedSpeciesList" model="{selectedSpeciesListModel}" - onMouseClicked="getHandler().showSelectedSpeciesContextMenu(this, event)" - selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}" - enabled="{isYearsValidated() && isStrataValidated()}" - onValueChanged='selectedSpeciesLabel.setText(t("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/> - <ListSelectionModel id="selectedSpeciesListSelectionModel" javaBean="selectedSpeciesList.getSelectionModel()" /> - </JScrollPane> - </cell> - </row> - <row> - <cell fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.details.speciescontextmenu" font-style="italic"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell anchor="east" columns="4"> - <JButton id="validSpeciesButton" text="coser.ui.selection.details.validSpecies" - onActionPerformed="getHandler().validSelectionSpeciesData(this);setSpeciesValidated(true);saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0)" - enabled="{isYearsValidated() && isStrataValidated() && !isSpeciesValidated()}"/> - </cell> - </row> - </Table> - </AccordionPaneSubPanel> - </AccordionPane> + <row> + <cell insets="0"> + <JButton icon="arrow_right.png" + toolTipText="coser.ui.selection.details.addToSelectedListTip" + onActionPerformed="getHandler().addSelectedFilteredSpecies(this)" + enabled="{getFilteredSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> + </cell> + </row> + <row> + <cell insets="0"> + <JButton icon="arrow_left.png" + toolTipText="coser.ui.selection.details.removeFromSelectedListTip" + onActionPerformed="getHandler().removeSelectedSpecies(this)" + enabled="{getSelectedSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> + </cell> + </row> + <row> + <cell> + <JSeparator/> + </cell> + </row> + <row> + <cell insets="0"> + <JButton icon="stock_select_table.png" + toolTipText="coser.ui.selection.details.selectAllSpeciesTip" + onActionPerformed="getHandler().selectAllListSpecies(this)"/> + </cell> + </row> + <row> + <cell insets="0"> + <JButton icon="stock_select_clear.png" + toolTipText="coser.ui.selection.details.unSelectAllSpeciesTip" + onActionPerformed="getHandler().unSelectAllListSpecies(this)"/> + </cell> + </row> + <row> + <cell insets="0"> + <JButton icon="chart_curve.png" + toolTipText="coser.ui.selection.details.displayDiffCatchLengthGraphTip" + onActionPerformed="getHandler().showSelectedSpeciesGraph(this, null)" + enabled="{isYearsValidated() && isStrataValidated() && (getSelectedSpeciesList().getSelectedIndex() != -1 || getFilteredSpeciesList().getSelectedIndex() != -1)}"/> + </cell> + </row> - <CardLayout id="detailDecisionPanelLayout" /> - <JPanel id="detailDecisionPanel" layout="{detailDecisionPanelLayout}"> - <JScrollPane constraints='"SPECIESDATA"'> - <Table> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.selection.details.speciesDataDescription" /> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1"> - <org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanelEditor" /> - </cell> - </row> + <row> + <cell insets="0"> + <JButton icon="arrow_jion_up.png" + toolTipText="coser.ui.selection.details.mergeSpeciesTip" + onActionPerformed="getHandler().showSpeciesMergeDialog(this)" + enabled="{getFilteredSpeciesList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> + </cell> + </row> </Table> - </JScrollPane> - <JPanel layout="{new BorderLayout()}" constraints='"ZONEMAP"'> - <fr.ifremer.coser.ui.maps.CoserMap id="strataMap" constraints='BorderLayout.CENTER' /> - <com.bbn.openmap.InformationDelegator id="stataMapInfo" constraints='BorderLayout.SOUTH' /> - </JPanel> - <JScrollPane constraints='"SPECIESGRAPH"'> - <JPanel id="speciesGraphPanel" layout="{new GridBagLayout()}"/> - </JScrollPane> - </JPanel> - </JSplitPane> - </cell> - </row> + </cell> + <cell weightx="1" weighty="1" fill="both"> + <JScrollPane> + <SpeciesListModel id="selectedSpeciesListModel" + onContentsChanged='setSpeciesValidated(false);selectedSpeciesLabel.setText(t("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/> + <JList id="selectedSpeciesList" model="{selectedSpeciesListModel}" + onMouseClicked="getHandler().showSelectedSpeciesContextMenu(this, event)" + selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}" + enabled="{isYearsValidated() && isStrataValidated()}" + onValueChanged='selectedSpeciesLabel.setText(t("coser.ui.selection.details.selectedSpecies", selectedSpeciesList.getSelectedIndices().length, selectedSpeciesList.getModel().getSize()))'/> + <ListSelectionModel id="selectedSpeciesListSelectionModel" + javaBean="selectedSpeciesList.getSelectionModel()"/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" columns="3"> + <JLabel text="coser.ui.selection.details.speciescontextmenu" font-style="italic"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell anchor="east" columns="4"> + <JButton id="validSpeciesButton" text="coser.ui.selection.details.validSpecies" + onActionPerformed="getHandler().validSelectionSpeciesData(this);setSpeciesValidated(true);saveSelectionButton.setEnabled(getErrorsTableModel().getRowCount() == 0)" + enabled="{isYearsValidated() && isStrataValidated() && !isSpeciesValidated()}"/> + </cell> + </row> + </Table> + </AccordionPaneSubPanel> + </AccordionPane> + + <CardLayout id="detailDecisionPanelLayout"/> + <JPanel id="detailDecisionPanel" layout="{detailDecisionPanelLayout}"> + <JScrollPane constraints='"SPECIESDATA"'> + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.selection.details.speciesDataDescription"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1"> + <org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanelEditor"/> + </cell> + </row> + </Table> + </JScrollPane> + <JPanel layout="{new BorderLayout()}" constraints='"ZONEMAP"'> + <fr.ifremer.coser.ui.maps.CoserMap id="strataMap" constraints='BorderLayout.CENTER'/> + <com.bbn.openmap.InformationDelegator id="stataMapInfo" constraints='BorderLayout.SOUTH'/> + </JPanel> + <JScrollPane constraints='"SPECIESGRAPH"'> + <JPanel id="speciesGraphPanel" layout="{new GridBagLayout()}"/> + </JScrollPane> + </JPanel> + </JSplitPane> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx index 70fa22c..c09b647 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx @@ -20,46 +20,46 @@ #L% --> <JDialog title="coser.ui.selection.option.editFilesTitle" modal="true"> - <SelectionHandler id="handler" javaBean="null" /> - <Table> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.selection.option.filesDetails" /> + <SelectionHandler id="handler" javaBean="null"/> + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.selection.option.filesDetails"/> + </cell> + </row> + <row> + <cell weighty="1" fill="both"> + <JScrollPane> + <fr.ifremer.coser.ui.selection.model.FileListModel id="selectionFilesListModel"/> + <JList id="selectionFilesList" model="{selectionFilesListModel}" + onValueChanged="removeOtherFile.setEnabled(getSelectionFilesList().getSelectedIndex() != -1)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" insets="0"> + <Table> + <row> + <cell> + <JButton text="coser.ui.selection.option.addSelectionFile" + onActionPerformed="getHandler().selectResultFileOrDirectory(this, selectionFilesList)"/> </cell> - </row> - <row> - <cell weighty="1" fill="both"> - <JScrollPane> - <fr.ifremer.coser.ui.selection.model.FileListModel id="selectionFilesListModel" /> - <JList id="selectionFilesList" model="{selectionFilesListModel}" - onValueChanged="removeOtherFile.setEnabled(getSelectionFilesList().getSelectedIndex() != -1)" /> - </JScrollPane> + <cell> + <JButton id="removeOtherFile" text="coser.ui.selection.option.removeSelectionFile" + onActionPerformed="getHandler().removeSelectedFile(this)" + enabled="false"/> </cell> - </row> - <row> - <cell fill="horizontal" insets="0"> - <Table> - <row> - <cell> - <JButton text="coser.ui.selection.option.addSelectionFile" - onActionPerformed="getHandler().selectResultFileOrDirectory(this, selectionFilesList)"/> - </cell> - <cell> - <JButton id="removeOtherFile" text="coser.ui.selection.option.removeSelectionFile" - onActionPerformed="getHandler().removeSelectedFile(this)" - enabled="false"/> - </cell> - <cell weightx="1" anchor="east"> - <JButton text="coser.ui.result.cancel" - onActionPerformed="dispose()"/> - </cell> - <cell> - <JButton id="saveResultButton" text="coser.ui.selection.option.validSelectionFiles" - onActionPerformed="getHandler().performSaveSelectionFiles(this)"/> - </cell> - </row> - </Table> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.result.cancel" + onActionPerformed="dispose()"/> </cell> - </row> - </Table> + <cell> + <JButton id="saveResultButton" text="coser.ui.selection.option.validSelectionFiles" + onActionPerformed="getHandler().performSaveSelectionFiles(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java index 0d9be7a..43be53f 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java @@ -22,46 +22,6 @@ package fr.ifremer.coser.ui.selection; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JList; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; -import javax.swing.event.ChangeEvent; - -import jaxx.runtime.JAXXUtil; - -import jaxx.runtime.swing.session.SwingSession; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.combobox.ListComboBoxModel; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.nuiton.math.matrix.MatrixND; -import org.nuiton.math.matrix.gui.MatrixTableModelND; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserException; @@ -71,7 +31,6 @@ import fr.ifremer.coser.bean.RSufiResult; import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.services.PublicationService; -import fr.ifremer.coser.ui.CoserFrameHandler.SelectionFileFilter; import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.common.SpeciesListRenderer; import fr.ifremer.coser.ui.control.ControlGraphFrame; @@ -81,15 +40,48 @@ import fr.ifremer.coser.ui.result.SelectionEditResultDialog; import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel; import fr.ifremer.coser.ui.util.CoserListSelectionModel; import fr.ifremer.coser.util.Coordinate; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.swing.session.SwingSession; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.combobox.ListComboBoxModel; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixTableModelND; + +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import javax.swing.event.ChangeEvent; +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.nuiton.i18n.I18n.t; /** * Selection handler. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SelectionHandler extends DataHandler { @@ -97,11 +89,11 @@ public class SelectionHandler extends DataHandler { /** * Appelé sur un changement d'onglet dans l'interface de sélection. - * + * * Les listes L1à4 n'ecoutent pas directement les modifications du premier * onglet. Opération manuelle, calcul de matrice en plus. - * - * @param view view + * + * @param view view * @param event change event */ public void selectionTabChanged(SelectionView view, ChangeEvent event) { @@ -112,14 +104,14 @@ public class SelectionHandler extends DataHandler { // selected tab is Lists Component selectedComponent = view.getSelectedComponent(); if (selectedComponent instanceof SelectionListsView) { - SelectionListsView selectionListsView = (SelectionListsView)selectedComponent; + SelectionListsView selectionListsView = (SelectionListsView) selectedComponent; if (log.isDebugEnabled()) { log.debug("List details tab selected"); } Selection selection = view.getContextValue(Selection.class); - + // si la selection n'est pas la même que que celle de la sélection // on met à jour la liste de "Toutes les especes" (L1) @@ -152,25 +144,24 @@ public class SelectionHandler extends DataHandler { // fill all species data (at final) selectionListsView.getSelectionAllSpeciesListModel().setSpecies(selectionSpeciesList); - ((CoserListSelectionModel)selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection(); + ((CoserListSelectionModel) selectionListsView.getSelectionAllSpeciesList().getSelectionModel()).fillSelection(); selectionListsView.getSelectionSizeAllYearListModel().setSizeAllYearSpecies(speciesAllYear); selectionListsView.getSelectionMaturityListModel().setMaturitySpecies(speciesWithMaturity); // rechargement de la selection sauvegardée // si aucune des autres listes n'est vide if (!selection.getSelectedSpeciesOccDens().isEmpty() || - !selection.getSelectedSpeciesSizeAllYear().isEmpty() || - !selection.getSelectedSpeciesMaturity().isEmpty()) { + !selection.getSelectedSpeciesSizeAllYear().isEmpty() || + !selection.getSelectedSpeciesMaturity().isEmpty()) { selectionListsView.getSelectionFilterOccurrenceField().setText(String.valueOf(selection.getOccurrenceFilter())); selectionListsView.getSelectionFilterDensityField().setText(String.valueOf(selection.getDensityFilter())); // restauration de la selection sauvegardée - ((CoserListSelectionModel)selectionListsView.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesOccDens()); - ((CoserListSelectionModel)selectionListsView.getSelectionSizeAllYearList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesSizeAllYear()); - ((CoserListSelectionModel)selectionListsView.getSelectionMaturityList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesMaturity()); - } - else { + ((CoserListSelectionModel) selectionListsView.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesOccDens()); + ((CoserListSelectionModel) selectionListsView.getSelectionSizeAllYearList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesSizeAllYear()); + ((CoserListSelectionModel) selectionListsView.getSelectionMaturityList().getSelectionModel()).setSelectedObjects(selection.getSelectedSpeciesMaturity()); + } else { if (log.isDebugEnabled()) { log.debug("Apply occurrence/density filter"); @@ -190,7 +181,7 @@ public class SelectionHandler extends DataHandler { /** * Initialize certains donnés différement que le ferait le rechargement * d'une selection. - * + * * @param view view */ public void initSelection(SelectionView view) { @@ -209,7 +200,7 @@ public class SelectionHandler extends DataHandler { /** * Initialise la listes des années disponible dans les données chargées. - * + * * @param view view */ public void initSelectionYears(SelectionDetailsView view) { @@ -217,7 +208,7 @@ public class SelectionHandler extends DataHandler { view.getYearsListModel().setYears(selection.getAllYears()); // tout est selectionné par defaut - ((CoserListSelectionModel)view.getYearsList().getSelectionModel()).setSelectedObjects(selection.getSelectedYears()); + ((CoserListSelectionModel) view.getYearsList().getSelectionModel()).setSelectedObjects(selection.getSelectedYears()); // clear other lists view.getStrataListModel().setStrata(new ArrayList<String>()); @@ -226,17 +217,17 @@ public class SelectionHandler extends DataHandler { view.getFilteredSpeciesList().clearSelection(); view.getSelectedSpeciesListModel().setSpecies(new ArrayList<String>()); view.getSelectedSpeciesList().clearSelection(); - + // update sampling effort data table showSamplingEffort(view); } /** * Recharge la selection en valorisant les différentes listes. - * + * * Fait ici, car sinon, les evenements ne se déclenchent pas au même * moment. - * + * * @param view view to fill */ public void reloadSelection(SelectionView view) { @@ -251,12 +242,12 @@ public class SelectionHandler extends DataHandler { // details view : fill details view detailView.getYearsListModel().setYears(selection.getAllYears()); List<String> selectedYears = selection.getSelectedYears(); - ((CoserListSelectionModel)detailView.getYearsList().getSelectionModel()).setSelectedObjects(selectedYears); + ((CoserListSelectionModel) detailView.getYearsList().getSelectionModel()).setSelectedObjects(selectedYears); // details view : fill strata data and selection updateSelectionYearsData(detailView); List<String> selectedStrata = selection.getSelectedStrata(); - ((CoserListSelectionModel)detailView.getStrataList().getSelectionModel()).setSelectedObjects(selectedStrata); + ((CoserListSelectionModel) detailView.getStrataList().getSelectionModel()).setSelectedObjects(selectedStrata); // details view : fill species list and selection detailView.getSelectedSpeciesListModel().setSpecies(selection.getSelectedSpecies()); @@ -269,27 +260,27 @@ public class SelectionHandler extends DataHandler { detailView.setStrataValidated(!selectedStrata.isEmpty()); detailView.setSpeciesValidated(!selectedSpecies.isEmpty()); view.setEnabledAt(2, selection.isValidated()); // rsufi - + // update sampling effort data table showSamplingEffort(detailView); } /** * Recharge les données de controle sur action utilsateur. - * + * * Si confirmation: * <ul> * <li>recharge les données * <li>reactive le bouton année * <li>affiche l'accordeon année * </ul> - * + * * @param view view */ public void reloadControlData(SelectionDetailsView view) { int response = JOptionPane.showConfirmDialog(view, t("coser.ui.selection.detail.confirmcontrolreload"), - t("coser.ui.selection.selectionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { Project project = view.getContextValue(Project.class); @@ -302,9 +293,9 @@ public class SelectionHandler extends DataHandler { initSelectionYears(view); view.getValidDatesButton().setEnabled(true); view.getDetailAccordionPane().setSelected(1); - + JOptionPane.showMessageDialog(view, t("coser.ui.selection.detail.controldatareloaded"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } catch (CoserBusinessException ex) { throw new CoserException("Can't reload control data", ex); @@ -315,7 +306,7 @@ public class SelectionHandler extends DataHandler { /** * Rafraichit la liste des zones suite à la selection des années. * Rechargement de selection ou action utilisateur. - * + * * @param view view */ protected void updateSelectionYearsData(SelectionDetailsView view) { @@ -327,7 +318,7 @@ public class SelectionHandler extends DataHandler { Object[] selectedDates = view.getYearsList().getSelectedValues(); List<String> years = new ArrayList<String>(selectedDates.length); for (Object selectedDate : selectedDates) { - years.add((String)selectedDate); + years.add((String) selectedDate); } if (log.isDebugEnabled()) { @@ -339,7 +330,7 @@ public class SelectionHandler extends DataHandler { // don't set yourself List<String> strata = projectService.filterDataYearsAndGetStrata(project, selection, years); view.getStrataListModel().setStrata(strata); - + // auto selectionne les strates par default view.getStrataList().addSelectionInterval(0, strata.size() - 1); @@ -356,12 +347,12 @@ public class SelectionHandler extends DataHandler { throw new CoserException("Can't filters data with specified years", ex); } } - + /** * Rafraichit la liste des zones suite à la selection des années. - * + * * Action utilisateur. - * + * * @param view view */ public void validSelectionYearsData(SelectionDetailsView view) { @@ -375,7 +366,7 @@ public class SelectionHandler extends DataHandler { showSamplingEffort(view); JOptionPane.showMessageDialog(view, t("coser.ui.selection.detail.yearsvalidated"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); // auto select strata accordion pane view.getDetailAccordionPane().setSelected(2); @@ -386,7 +377,7 @@ public class SelectionHandler extends DataHandler { /** * Init openmap toolbar and openmap layers. - * + * * @param view view */ public void initView(SelectionView view) { @@ -397,7 +388,7 @@ public class SelectionHandler extends DataHandler { /** * Init detail tab view - * + * * @param view view */ protected void initView(SelectionDetailsView view) { @@ -408,7 +399,7 @@ public class SelectionHandler extends DataHandler { view.getStataMapInfo().setMap(view.getStrataMap().getMapBean()); view.getStataMapInfo().setShowCoordsInfoLine(true); view.getStataMapInfo().setShowInfoLine(true); - + // fill species type selection by default int count = view.getTypeSpeciesModel().getSize(); view.getTypeSpeciesList().addSelectionInterval(0, count - 1); @@ -418,10 +409,10 @@ public class SelectionHandler extends DataHandler { view.getFilteredSpeciesList().setCellRenderer(renderer); view.getSelectedSpeciesList().setCellRenderer(renderer); } - + /** * Init selection list tab view. - * + * * @param view view */ protected void initView(SelectionListsView view) { @@ -437,7 +428,7 @@ public class SelectionHandler extends DataHandler { /** * Appelé lorsque la selection de la liste des strate a changé. * Rechargement de selection ou action utilsateur. - * + * * @param view view */ protected void updateSelectionStrataData(SelectionDetailsView view) { @@ -454,7 +445,7 @@ public class SelectionHandler extends DataHandler { Object[] selectedStrata = view.getStrataList().getSelectedValues(); List<String> strata = new ArrayList<String>(selectedStrata.length); for (Object selectedStratum : selectedStrata) { - strata.add((String)selectedStratum); + strata.add((String) selectedStratum); } // do selection.setSelectedStrata(strata); @@ -462,15 +453,15 @@ public class SelectionHandler extends DataHandler { // remove non selected stata non in data anymore // maybe will be improved for v2 view.getStrataListModel().setStrata(strata); - ((CoserListSelectionModel)view.getStrataList().getSelectionModel()).setSelectedObjects(strata); + ((CoserListSelectionModel) view.getStrataList().getSelectionModel()).setSelectedObjects(strata); updateSelectionSpecies(view); } - + /** * Appelé lorsque la selection de la liste des strate a changé. * Action utilsteur seulement. - * + * * @param view view */ public void validSelectionStrataData(SelectionDetailsView view) { @@ -483,12 +474,11 @@ public class SelectionHandler extends DataHandler { showSamplingEffort(view); JOptionPane.showMessageDialog(view, t("coser.ui.selection.detail.stratavalidated"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); // auto select species accordion pane view.getDetailAccordionPane().setSelected(3); - } - finally { + } finally { setDefaultCursor(view); } } @@ -497,9 +487,9 @@ public class SelectionHandler extends DataHandler { * Rafraichit la liste des especes avec les dates sélectionnées * et les strates selectionnées ET filtrées par la liste * des type d'especes. - * + * * Appelé lorsque la selection de la liste des zones change. - * + * * @param view view */ public void updateSelectionSpecies(SelectionDetailsView view) { @@ -516,7 +506,7 @@ public class SelectionHandler extends DataHandler { Object[] selectedSpeciesTypes = view.getTypeSpeciesList().getSelectedValues(); List<String> speciesTypes = new ArrayList<String>(); for (Object selectedSpeciesType : selectedSpeciesTypes) { - speciesTypes.add((String)selectedSpeciesType); + speciesTypes.add((String) selectedSpeciesType); } List<String> filteredSpecies = projectService.getProjectSpecies(selection, project, speciesTypes); @@ -530,14 +520,14 @@ public class SelectionHandler extends DataHandler { filteredSpecies.removeAll(selectedSpecies); view.getFilteredSpeciesListModel().setSpecies(filteredSpecies); } - + /** * Rafraichit la liste des especes avec les dates sélectionnées * et les strates selectionnées ET filtrées par la liste * des type d'especes. - * + * * Appelé lorsque la selection de la liste des zones change. - * + * * @param view view */ public void validSelectionSpeciesData(SelectionDetailsView view) { @@ -556,17 +546,16 @@ public class SelectionHandler extends DataHandler { updateSelectionSpecies(view); JOptionPane.showMessageDialog(view, t("coser.ui.selection.detail.speciesvalidated"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); - } - finally { + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + } finally { setDefaultCursor(view); } } /** * Affiche un menu contextuel lors du clic (droit) sur la liste des années. - * - * @param view view + * + * @param view view * @param event mouse event */ public void showYearsContextMenu(final SelectionDetailsView view, MouseEvent event) { @@ -579,6 +568,7 @@ public class SelectionHandler extends DataHandler { // select all menu JMenuItem selectAllMenu = new JMenuItem(t("coser.ui.common.selectAll")); selectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { int size = view.getYearsList().getModel().getSize(); @@ -586,10 +576,11 @@ public class SelectionHandler extends DataHandler { } }); popupMenu.add(selectAllMenu); - + // unselect all menu JMenuItem unselectAllMenu = new JMenuItem(t("coser.ui.common.unselectAll")); unselectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { view.getYearsList().getSelectionModel().clearSelection(); @@ -600,11 +591,11 @@ public class SelectionHandler extends DataHandler { popupMenu.show(view.getYearsList(), event.getX(), event.getY()); } } - + /** * Affiche un menu contextuel lors du clic (droit) sur la liste des strates. - * - * @param view view + * + * @param view view * @param event mouse event */ public void showStrataContextMenu(final SelectionDetailsView view, MouseEvent event) { @@ -617,6 +608,7 @@ public class SelectionHandler extends DataHandler { // select all menu JMenuItem selectAllMenu = new JMenuItem(t("coser.ui.common.selectAll")); selectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { int size = view.getStrataList().getModel().getSize(); @@ -624,10 +616,11 @@ public class SelectionHandler extends DataHandler { } }); popupMenu.add(selectAllMenu); - + // unselect all menu JMenuItem unselectAllMenu = new JMenuItem(t("coser.ui.common.unselectAll")); unselectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { view.getStrataList().getSelectionModel().clearSelection(); @@ -641,8 +634,8 @@ public class SelectionHandler extends DataHandler { /** * Affiche un menu contextuel lors du clic (droit) sur la liste filtrées des especes. - * - * @param view view + * + * @param view view * @param event mouse event */ public void showFilteredSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { @@ -658,6 +651,7 @@ public class SelectionHandler extends DataHandler { // merge menu JMenuItem fusionMenu = new JMenuItem(t("coser.ui.selection.speciesMenuFusion")); fusionMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { showSpeciesMergeDialog(view); @@ -668,6 +662,7 @@ public class SelectionHandler extends DataHandler { // graph JMenuItem graphMenu = new JMenuItem(t("coser.ui.selection.details.displayDiffCatchLengthGraph")); graphMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { showSelectedSpeciesGraph(view, view.getFilteredSpeciesList()); @@ -679,6 +674,7 @@ public class SelectionHandler extends DataHandler { // select all menu JMenuItem selectAllMenu = new JMenuItem(t("coser.ui.common.selectAll")); selectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { int size = view.getFilteredSpeciesList().getModel().getSize(); @@ -686,10 +682,11 @@ public class SelectionHandler extends DataHandler { } }); popupMenu.add(selectAllMenu); - + // unselect all menu JMenuItem unselectAllMenu = new JMenuItem(t("coser.ui.common.unselectAll")); unselectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { view.getFilteredSpeciesList().getSelectionModel().clearSelection(); @@ -704,8 +701,8 @@ public class SelectionHandler extends DataHandler { /** * Affiche un menu contextuel lors du clic (droit) sur la liste des especes * sélectionnées. - * - * @param view view + * + * @param view view * @param event mouse event */ public void showSelectedSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { @@ -720,6 +717,7 @@ public class SelectionHandler extends DataHandler { // graph JMenuItem graphMenu = new JMenuItem(t("coser.ui.selection.details.displayDiffCatchLengthGraph")); graphMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { showSelectedSpeciesGraph(view, view.getSelectedSpeciesList()); @@ -731,6 +729,7 @@ public class SelectionHandler extends DataHandler { // select all menu JMenuItem selectAllMenu = new JMenuItem(t("coser.ui.common.selectAll")); selectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { int size = view.getSelectedSpeciesList().getModel().getSize(); @@ -742,6 +741,7 @@ public class SelectionHandler extends DataHandler { // unselect all menu JMenuItem unselectAllMenu = new JMenuItem(t("coser.ui.common.unselectAll")); unselectAllMenu.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { view.getSelectedSpeciesList().getSelectionModel().clearSelection(); @@ -755,7 +755,7 @@ public class SelectionHandler extends DataHandler { /** * Show species merge dialog. Called from view action or context menu. - * + * * @param view parent view */ public void showSpeciesMergeDialog(SelectionDetailsView view) { @@ -770,9 +770,9 @@ public class SelectionHandler extends DataHandler { speciesFusionDialog.getSpeciesCombo().setRenderer(new SpeciesListRenderer(reftaxSpecies)); // init selected element - String firstSelected = (String)view.getFilteredSpeciesList().getSelectedValue(); + String firstSelected = (String) view.getFilteredSpeciesList().getSelectedValue(); speciesFusionDialog.getSpeciesCombo().setSelectedItem(firstSelected); - + Object[] selectedValues = view.getFilteredSpeciesList().getSelectedValues(); if (selectedValues.length == 1) { speciesFusionDialog.setTitle(t("coser.ui.selection.fusion.rename.title")); @@ -788,7 +788,7 @@ public class SelectionHandler extends DataHandler { * Clic sur le bouton selectionner tout. * Selectionne toutes les espèces dans les 2 listes contrairement au * menu contextuel qui ne selectionne que dans une seule liste. - * + * * @param view parent view * @since 1.3 */ @@ -805,7 +805,7 @@ public class SelectionHandler extends DataHandler { * Clic sur le bouton selectionner tout. * Selectionne toutes les espèces dans les 2 listes contrairement au * menu contextuel qui ne selectionne que dans une seule liste. - * + * * @param view parent view * @since 1.3 */ @@ -818,7 +818,7 @@ public class SelectionHandler extends DataHandler { /** * Sauvegarde (ou creer) la sélection (partie details). - * + * * @param view parent view */ public void saveSelection(SelectionDetailsView view) { @@ -831,17 +831,16 @@ public class SelectionHandler extends DataHandler { if (view.isCreationState()) { projectService.createProjectSelection(project, selection); selectionView.setCreationState(false); - + JOptionPane.showMessageDialog(view, t("coser.ui.selection.selectionCreated"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } else { projectService.saveProjectSelection(project, selection); - + JOptionPane.showMessageDialog(view, t("coser.ui.selection.selectionSaved"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { if (log.isErrorEnabled()) { log.error("Can't save selection", ex); } @@ -854,32 +853,32 @@ public class SelectionHandler extends DataHandler { /** * Sauve les éléments selectionnés dans la sélection. - * - * @param view view containing jlist + * + * @param view view containing jlist * @param selection selection to save lists to */ protected void saveSelectionLists(SelectionListsView view, Selection selection) { - + // do not use CoserSelectionModel.getSelectedValues here (not same datas) List<String> occDensList = new ArrayList<String>(); Object[] occDensSpeciesSelection = view.getSelectionOccurrenceDensityList().getSelectedValues(); for (Object occDensSpecies : occDensSpeciesSelection) { - occDensList.add((String)occDensSpecies); + occDensList.add((String) occDensSpecies); } - + List<String> sizeAllYearList = new ArrayList<String>(); Object[] sizeAllYearSpeciesSelection = view.getSelectionSizeAllYearList().getSelectedValues(); for (Object sizeAllYearSpecies : sizeAllYearSpeciesSelection) { - sizeAllYearList.add((String)sizeAllYearSpecies); + sizeAllYearList.add((String) sizeAllYearSpecies); } - + List<String> maturityList = new ArrayList<String>(); Object[] maturitySpeciesSelection = view.getSelectionMaturityList().getSelectedValues(); for (Object maturitySpecies : maturitySpeciesSelection) { - maturityList.add((String)maturitySpecies); + maturityList.add((String) maturitySpecies); } - + selection.setSelectedSpeciesOccDens(occDensList); selection.setSelectedSpeciesSizeAllYear(sizeAllYearList); selection.setSelectedSpeciesMaturity(maturityList); @@ -887,10 +886,10 @@ public class SelectionHandler extends DataHandler { /** * Marque la selection comme validée et la sauve ensuite). - * + * * Test que si une liste a été modifiée par l'utilisateur, le champs * commentaire associé est bien renseigné. - * + * * @param view view */ public void validSelection(SelectionListsView view) { @@ -904,7 +903,7 @@ public class SelectionHandler extends DataHandler { saveSelectionLists(view, selection); service.validSelection(project, selection); JOptionPane.showMessageDialog(view, t("coser.ui.selection.selectionValidated"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); // enable tabs SelectionView selectionView = view.getParentContainer(SelectionView.class); @@ -921,7 +920,7 @@ public class SelectionHandler extends DataHandler { /** * Test que les selections sont complete ou alors justifiée par un * commentaires. - * + * * @param view view containing jlist * @return {@code true} if selection can be saved */ @@ -941,7 +940,7 @@ public class SelectionHandler extends DataHandler { if (!currentOccDensSelection.equals(originalOccDensSelection) && StringUtils.isBlank(selection.getSelectedSpeciesOccDensComment())) { JOptionPane.showMessageDialog(view, t("coser.ui.selection.nonJustifiedOccurenceDensity"), - t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); view.getOccurrenceDensityCommentField().requestFocus(); canValidate = false; } @@ -953,7 +952,7 @@ public class SelectionHandler extends DataHandler { if (sizeAllYearSpeciesSelection.length < sizeAllYearSpeciesInModel && StringUtils.isBlank(selection.getSelectedSpeciesSizeAllYearComment())) { JOptionPane.showMessageDialog(view, t("coser.ui.selection.nonJustifiedSizeAllYear"), - t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); view.getSizeAllYearCommentField().requestFocus(); canValidate = false; } @@ -966,25 +965,25 @@ public class SelectionHandler extends DataHandler { if (maturitySpeciesSelection.length < maturitySpeciesInModel && StringUtils.isBlank(selection.getSelectedSpeciesMaturityComment())) { JOptionPane.showMessageDialog(view, t("coser.ui.selection.nonJustifiedMaturity"), - t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.selection.nonJustifiedTitle"), JOptionPane.ERROR_MESSAGE); view.getMaturityCommentField().requestFocus(); canValidate = false; } } - + return canValidate; } /** * Mise à jour du filtre d'ocurrence et densité. - * + * * Selectionne dans la liste seulement les especes ayant une densité * suppérieure à celle indique (idem pour l'occurence). - * + * * @param view selection list view */ public void updateOccurrenceDensityFilter(SelectionListsView view) { - + Selection selection = view.getContextValue(Selection.class); String stringOccurrence = view.getSelectionFilterOccurrenceField().getText().trim(); @@ -1003,13 +1002,12 @@ public class SelectionHandler extends DataHandler { Collections.sort(filteredSpecies); // application de la nouvelle selection - ((CoserListSelectionModel)view.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(filteredSpecies); - + ((CoserListSelectionModel) view.getSelectionOccurrenceDensityList().getSelectionModel()).setSelectedObjects(filteredSpecies); + // selectionne automatiquement les listes L3 & L4 - ((CoserListSelectionModel)view.getSelectionSizeAllYearList().getSelectionModel()).fillSelection(); - ((CoserListSelectionModel)view.getSelectionMaturityList().getSelectionModel()).fillSelection(); - } - catch (NumberFormatException ex) { + ((CoserListSelectionModel) view.getSelectionSizeAllYearList().getSelectionModel()).fillSelection(); + ((CoserListSelectionModel) view.getSelectionMaturityList().getSelectionModel()).fillSelection(); + } catch (NumberFormatException ex) { if (log.isWarnEnabled()) { log.warn("Can't parse occurrence or density as double", ex); } @@ -1018,10 +1016,10 @@ public class SelectionHandler extends DataHandler { /** * Return l'ensemble des especes qui respece le filtrage par occurrence/densite. - * - * @param view view + * + * @param view view * @param occurrence occurrence - * @param density density + * @param density density * @return species set */ protected Set<String> getOccurenceDensityFilteredSpecies(SelectionListsView view, double occurrence, double density) { @@ -1029,8 +1027,8 @@ public class SelectionHandler extends DataHandler { OccurrenceDensitySpeciesListModel model = view.getSelectionOccurrenceDensityListModel(); int speciesCount = model.getSize(); Set<String> filteredSpecies = new HashSet<String>(); - for (int speciesIndex = 0 ; speciesIndex < speciesCount ; speciesIndex++) { - String species = (String)model.getElementAt(speciesIndex); + for (int speciesIndex = 0; speciesIndex < speciesCount; speciesIndex++) { + String species = (String) model.getElementAt(speciesIndex); if (model.getDensity(species) >= density && model.getOccurrence(species) >= occurrence) { filteredSpecies.add(species); } @@ -1042,15 +1040,15 @@ public class SelectionHandler extends DataHandler { * Check que les paramètres sont correct (nouveau nom existant) * et applique la fusion d'espece. Rafraichit la view * parente ensuite. - * - * @param view + * + * @param view */ public void performMergeSpecies(SpeciesFusionDialog view) { - + // TODO echatellier 20101021 attention a ce que la selection // ne change pas (la fenetre est modale pour l'instant) - - String newSpeciesCode = (String)view.getSpeciesCombo().getSelectedItem(); + + String newSpeciesCode = (String) view.getSpeciesCombo().getSelectedItem(); String comment = view.getCommentField().getText(); Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); @@ -1059,8 +1057,8 @@ public class SelectionHandler extends DataHandler { SelectionDetailsView parent = view.getContextValue(SelectionDetailsView.class, JAXXUtil.PARENT); Object[] selectedSpecies = parent.getFilteredSpeciesList().getSelectedValues(); String[] speciesCodes = new String[selectedSpecies.length]; - for (int i = 0 ; i < selectedSpecies.length ; ++i) { - String singleSelectedSpecies = (String)selectedSpecies[i]; + for (int i = 0; i < selectedSpecies.length; ++i) { + String singleSelectedSpecies = (String) selectedSpecies[i]; speciesCodes[i] = singleSelectedSpecies; } @@ -1073,15 +1071,14 @@ public class SelectionHandler extends DataHandler { if (speciesCodes.length == 1) { JOptionPane.showMessageDialog(view, t("coser.ui.selection.speciesRenamed"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(view, t("coser.ui.selection.speciesMerged"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } - } - catch (CoserBusinessException ex) { + } catch (CoserBusinessException ex) { JOptionPane.showMessageDialog(view, ex.getMessage(), - t("coser.ui.selection.fusion.title"), JOptionPane.ERROR_MESSAGE); + t("coser.ui.selection.fusion.title"), JOptionPane.ERROR_MESSAGE); } view.dispose(); @@ -1089,7 +1086,7 @@ public class SelectionHandler extends DataHandler { /** * Show sampling effort data. - * + * * @param view view */ public void showSamplingEffort(SelectionDetailsView view) { @@ -1105,24 +1102,24 @@ public class SelectionHandler extends DataHandler { // replace default renderer with a renderer that display // null values in red background view.getMatrixPanelEditor().getTable().setDefaultRenderer(String.class, - new SamplingEffortRenderer((MatrixTableModelND)view.getMatrixPanelEditor().getTable().getModel())); + new SamplingEffortRenderer((MatrixTableModelND) view.getMatrixPanelEditor().getTable().getModel())); } } - + /** * Display selected strata haul position in map. - * + * * @param view view */ public void showStataOnMap(SelectionDetailsView view) { Selection selection = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); - + // get selected stata Object[] selectedStrataArray = view.getStrataList().getSelectedValues(); Set<String> selectedStata = new HashSet<String>(); for (Object selectedStrataItem : selectedStrataArray) { - selectedStata.add((String)selectedStrataItem); + selectedStata.add((String) selectedStrataItem); } // display on map @@ -1137,9 +1134,9 @@ public class SelectionHandler extends DataHandler { /** * Display data graph, initialized with graph for selected specy * selected. - * + * * TODO chatellier 20110215 : set this code in common with control same code - * + * * @param view view */ public void displayCompareNumberCatchGraph(SelectionListsView view) { @@ -1169,14 +1166,14 @@ public class SelectionHandler extends DataHandler { session.add(frame); // session restore frame.toFront(); frame.setVisible(true); - + // register current frame view.setContextValue(frame, "comparenumberframe"); } /** * Display lengthStructure matrix in matrixviewerpanel. - * + * * @param view view */ public void displayLengthStructureGraph(SelectionListsView view) { @@ -1190,7 +1187,7 @@ public class SelectionHandler extends DataHandler { /** * Ajout les especes filtrées selectionnées dans la liste des especes * selectionnées. - * + * * @param view view */ public void addSelectedFilteredSpecies(SelectionDetailsView view) { @@ -1203,18 +1200,18 @@ public class SelectionHandler extends DataHandler { selectedSpecies.addAll(view.getSelectedSpeciesListModel().getSpecies()); } for (Object singleSelectedFilteredSpecies : selectedFilteredSpecies) { - selectedSpecies.add((String)singleSelectedFilteredSpecies); + selectedSpecies.add((String) singleSelectedFilteredSpecies); } // met a jour le liste des especes selectionnées List<String> selectedSpeciesList = new ArrayList<String>(selectedSpecies); - + // code pour que la liste des ids d'especes soit trié // comme celle de visualisation de l'utilisateur (vue triée du rendu) selectedSpeciesList = CoserUtils.sortCollectionWithMapKeys(project.getRefTaxSpeciesMap(), selectedSpeciesList); view.getSelectedSpeciesListModel().setSpecies(selectedSpeciesList); - + // met a jour la liste filtrée (retrait des especes selectionnées) // ne fait pas apparaitre les especes deja selectionnées List<String> filteredSpecies = view.getFilteredSpeciesListModel().getSpecies(); @@ -1224,7 +1221,7 @@ public class SelectionHandler extends DataHandler { /** * Retire les especes selectionnées de la liste des esepeces sélectionnées. - * + * * @param view view */ public void removeSelectedSpecies(SelectionDetailsView view) { @@ -1235,16 +1232,16 @@ public class SelectionHandler extends DataHandler { Object[] selectedSelectedSpecies = view.getSelectedSpeciesList().getSelectedValues(); for (Object singleSelectedSelectedSpecies : selectedSelectedSpecies) { selectedSpecies.remove(singleSelectedSelectedSpecies); - filteredSpecies.add((String)singleSelectedSelectedSpecies); + filteredSpecies.add((String) singleSelectedSelectedSpecies); } - + // code pour que la liste des ids d'especes soit trié // comme celle de visualisation de l'utilisateur (vue triée du rendu) filteredSpecies = CoserUtils.sortCollectionWithMapKeys(project.getRefTaxSpeciesMap(), filteredSpecies); - + // met à jour la liste des especes selectionnées view.getSelectedSpeciesListModel().setSpecies(selectedSpecies); - + // met a jour la liste filtrée (retrait des especes selectionnées) view.getFilteredSpeciesListModel().setSpecies(filteredSpecies); } @@ -1253,8 +1250,8 @@ public class SelectionHandler extends DataHandler { * Affiche les graphes de différence captures/taille dans le panel * reféréncé par {@code cardLayoutContraints} suivant la liste * sur laquelle porte l'appel. - * - * @param view view + * + * @param view view * @param source source list to choose selected values (can be {@code null}, read both lists) */ public void showSelectedSpeciesGraph(SelectionDetailsView view, JList source) { @@ -1268,20 +1265,20 @@ public class SelectionHandler extends DataHandler { if (source != null) { Object[] selectedSpecies = source.getSelectedValues(); for (Object selectedSingleSpecies : selectedSpecies) { - graphSpecies.add((String)selectedSingleSpecies); + graphSpecies.add((String) selectedSingleSpecies); } } else { // merge both lists Object[] selectedSpecies = view.getFilteredSpeciesList().getSelectedValues(); for (Object selectedSingleSpecies : selectedSpecies) { - graphSpecies.add((String)selectedSingleSpecies); + graphSpecies.add((String) selectedSingleSpecies); } selectedSpecies = view.getSelectedSpeciesList().getSelectedValues(); for (Object selectedSingleSpecies : selectedSpecies) { - graphSpecies.add((String)selectedSingleSpecies); + graphSpecies.add((String) selectedSingleSpecies); } } - + Map<String, JFreeChart> chartsMap = publicationService.getCompareCatchLengthGraph(project, selection, graphSpecies); Collection<JFreeChart> charts = chartsMap.values(); @@ -1292,11 +1289,11 @@ public class SelectionHandler extends DataHandler { int chartIndex = 0; while (itCharts.hasNext()) { JFreeChart chart = itCharts.next(); - + ChartPanel chartPanel = new ChartPanel(chart); view.getSpeciesGraphPanel().add(chartPanel, - new GridBagConstraints(0, chartIndex, 1, 1, 1, 1, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 3, 3, 3), 0, 0)); + new GridBagConstraints(0, chartIndex, 1, 1, 1, 1, GridBagConstraints.CENTER, + GridBagConstraints.BOTH, new Insets(0, 3, 3, 3), 0, 0)); chartIndex++; } view.getDetailDecisionPanelLayout().show(view.getDetailDecisionPanel(), "SPECIESGRAPH"); @@ -1306,7 +1303,7 @@ public class SelectionHandler extends DataHandler { /** * Display rsufi new result dialog. - * + * * @param view view */ public void showAddResultDialog(SelectionRsufiView view) { @@ -1329,7 +1326,7 @@ public class SelectionHandler extends DataHandler { /** * Save new result after clicking "ok" button on SelectionAddResultDialog * opened by {@link #showAddResultDialog(SelectionRsufiView)}. - * + * * @param view view */ public void performAddResult(SelectionAddResultDialog view) { @@ -1354,11 +1351,11 @@ public class SelectionHandler extends DataHandler { /** * Show rsufi result edit dialog with selected rsufiresult. - * + * * @param view view */ public void showEditResultDialog(SelectionRsufiView view) { - + // get selected rsufi result int selectedRow = view.getSelectionResultsTable().getSelectedRow(); RSufiResult result = view.getSelectionResultsTableModel().getValue(selectedRow); @@ -1376,7 +1373,7 @@ public class SelectionHandler extends DataHandler { /** * Save edited result (only save properties file). - * + * * @param view view */ public void performEditResult(SelectionEditResultDialog view) { @@ -1396,18 +1393,18 @@ public class SelectionHandler extends DataHandler { /** * Supprime le résultat après confirmation par l'utilisateur. - * + * * @param view view */ public void deleteResult(SelectionRsufiView view) { // get selected rsufi result int selectedRow = view.getSelectionResultsTable().getSelectedRow(); RSufiResult result = view.getSelectionResultsTableModel().getValue(selectedRow); - + int confirm = JOptionPane.showConfirmDialog(view, - t("coser.ui.result.confirmDeleteResult", result.getName()), - t("coser.ui.result.resultTitle"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + t("coser.ui.result.confirmDeleteResult", result.getName()), + t("coser.ui.result.resultTitle"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (confirm == JOptionPane.YES_OPTION) { Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); @@ -1424,8 +1421,8 @@ public class SelectionHandler extends DataHandler { /** * Selectionne le dossier d'extraction. - * - * @param view view + * + * @param view view * @param textComponent text component to set selected directory */ public void selectOutputDirectory(SelectionRsufiView view, JTextField textComponent) { @@ -1443,7 +1440,7 @@ public class SelectionHandler extends DataHandler { /** * Extract data as RSufi format. - * + * * @param view view */ public void extractRSufiData(SelectionRsufiView view) { @@ -1453,25 +1450,25 @@ public class SelectionHandler extends DataHandler { ProjectService projectService = view.getContextValue(ProjectService.class); Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); - + String directoryPath = view.getResultExtractDataField().getText(); File directory = new File(directoryPath); - + projectService.extractRSUfiData(project, selection, directory, false); - + JOptionPane.showMessageDialog(view, t("coser.ui.selection.rsufidataextracted"), - t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.selectionTitle"), JOptionPane.INFORMATION_MESSAGE); } catch (CoserBusinessException ex) { throw new CoserException("Can't extract rsufi files", ex); } finally { setDefaultCursor(view); } } - + /** * Select result file (file only). - * - * @param view view + * + * @param view view * @param textComponent text component to set selected file */ public void selectResultFile(SelectionAddResultDialog view, JTextField textComponent) { @@ -1488,8 +1485,8 @@ public class SelectionHandler extends DataHandler { /** * Select maps directory (directory only). - * - * @param view view + * + * @param view view * @param textComponent text component to set selected directory */ public void selectMapsDirectory(SelectionAddResultDialog view, JTextField textComponent) { @@ -1506,8 +1503,8 @@ public class SelectionHandler extends DataHandler { /** * Select other files (file or directory). - * - * @param view view + * + * @param view view * @param listComponent list component to set selected file */ public void selectResultFileOrDirectory(SelectionAddResultDialog view, JList listComponent) { @@ -1521,11 +1518,11 @@ public class SelectionHandler extends DataHandler { view.getOtherDataFileListModel().add(selectedFile); } } - + /** * Select other files (file or directory). - * - * @param view view + * + * @param view view * @param listComponent list component to set selected file */ public void selectResultFileOrDirectory(SelectionEditResultDialog view, JList listComponent) { @@ -1539,11 +1536,11 @@ public class SelectionHandler extends DataHandler { view.getOtherDataFileListModel().add(selectedFile); } } - + /** * Select other files (file or directory). - * - * @param view view + * + * @param view view * @param listComponent list component to set selected file */ public void selectResultFileOrDirectory(SelectionFilesView view, JList listComponent) { @@ -1560,30 +1557,30 @@ public class SelectionHandler extends DataHandler { /** * Remove selected file in other file list. - * + * * @param view * @since 1.3 */ public void removeSelectedFile(SelectionEditResultDialog view) { - File selectedFile = (File)view.getOtherDataFileList().getSelectedValue(); + File selectedFile = (File) view.getOtherDataFileList().getSelectedValue(); view.getOtherDataFileListModel().remove(selectedFile); } /** * Remove selected file in other file list. - * + * * @param view * @since 1.4 */ public void removeSelectedFile(SelectionFilesView view) { - File selectedFile = (File)view.getSelectionFilesList().getSelectedValue(); + File selectedFile = (File) view.getSelectionFilesList().getSelectedValue(); view.getSelectionFilesListModel().remove(selectedFile); } /** * Genere le log des modifications faites lors du control en HTML * et l'ouvre dans le navigateur systeme. - * + * * @param view */ public void displayLogReport(SelectionDetailsView view) { @@ -1603,7 +1600,7 @@ public class SelectionHandler extends DataHandler { /** * Affiche la dialog de modification des fichiers d'une selection. * (appelée depuis l'onglet rsufi) - * + * * @param view parent view * @since 1.4 */ @@ -1620,7 +1617,7 @@ public class SelectionHandler extends DataHandler { /** * Sauvegarde des options de la selection. - * + * * @param view view containing option */ public void performSaveSelectionFiles(SelectionFilesView view) { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx index d84376a..c9fbfae 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx @@ -20,18 +20,18 @@ #L% --> <Table> - <import> + <import> fr.ifremer.coser.ui.selection.model.SpeciesListModel fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel fr.ifremer.coser.ui.selection.model.SizeAllYearSpeciesListModel fr.ifremer.coser.ui.selection.model.MaturitySpeciesListModel fr.ifremer.coser.ui.util.CoserListSelectionModel - </import> + </import> - <SelectionHandler id="handler" javaBean="null" /> - <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> + <SelectionHandler id="handler" javaBean="null"/> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null"/> - <script><![CDATA[ + <script><![CDATA[ // le modele de la liste est allimenté par la selection de la précédente liste // la selection est mise à jour par la modification du model de la liste @@ -49,196 +49,201 @@ } ]]></script> - <row> - <cell columns="8" weightx="1" insets="0" fill="horizontal"> - <JToolBar floatable="false"> - <JButton icon="chart_curve.png" text="coser.ui.graph.compareNumberCatchLength" - onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)" /> - <JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure" - onActionPerformed="getHandler().displayLengthStructureGraph(this)" /> - <Component initializer="javax.swing.Box.createHorizontalGlue()" /> - <JButton id="validSelectionButton" text="coser.ui.selection.details.validSelection" - icon="accept.png" onActionPerformed="getHandler().validSelection(this)" /> - </JToolBar> - </cell> - </row> - <row> - <cell fill="horizontal" columns="2"> - <JXTitledSeparator id="allSpeciesLabel" title='{t("coser.ui.selection.allSpecies", 0, 0)}' /> - </cell> - <cell fill="horizontal" columns="2"> - <JXTitledSeparator id="occurrenceDensitySpeciesLabel" title='{t("coser.ui.selection.occurrenceDensitySpecies", 0, 0)}' /> - </cell> - <cell fill="horizontal" columns="2"> - <JXTitledSeparator id="sizeAllYearSpeciesLabel" title='{t("coser.ui.selection.sizeAllYearSpecies", 0, 0)}' /> - </cell> - <cell fill="horizontal" columns="2"> - <JXTitledSeparator id="maturitySpeciesLabel" title='{t("coser.ui.selection.maturitySpecies", 0, 0)}' /> - </cell> - </row> - <row> - <cell /> - <cell /> - <cell fill="horizontal" insets="0" columns="2"> - <Table> - <row> - <cell> - <JLabel text="coser.ui.selection.filter.occurrence" /> - </cell> - <cell> - <JTextField id="selectionFilterOccurrenceField" columns="3" text="{String.valueOf(getSelection().getOccurrenceFilter())}" /> - <javax.swing.text.Document javaBean="selectionFilterOccurrenceField.getDocument()" - onInsertUpdate='applyOccDensFilter.setEnabled(true)' - onRemoveUpdate='applyOccDensFilter.setEnabled(true)' /> - </cell> - <cell> - <JLabel text="coser.ui.selection.filter.occurrenceunit" /> - </cell> - <cell> - <JLabel text="coser.ui.selection.filter.density" /> - </cell> - <cell> - <JTextField id="selectionFilterDensityField" columns="3" text="{String.valueOf(getSelection().getDensityFilter())}" /> - <javax.swing.text.Document javaBean="selectionFilterDensityField.getDocument()" - onInsertUpdate='applyOccDensFilter.setEnabled(true)' - onRemoveUpdate='applyOccDensFilter.setEnabled(true)' /> - </cell> - <cell> - <JLabel text="coser.ui.selection.filter.densityunit" /> - </cell> - </row> - <row> - <cell columns="6" anchor="center"> - <JButton id="applyOccDensFilter" text="coser.ui.selection.filter.filter" enabled="false" - onActionPerformed="getHandler().updateOccurrenceDensityFilter(this);applyOccDensFilter.setEnabled(false)" /> - </cell> - </row> - </Table> - </cell> - <cell /> - <cell /> - <cell /> - <cell /> - </row> - <row> - <cell weighty="1" weightx="1" fill="both" columns="2"> - <JScrollPane> - <SpeciesListModel id="selectionAllSpeciesListModel" - onContentsChanged='allSpeciesLabel.setTitle(t("coser.ui.selection.allSpecies", selectionAllSpeciesList.getSelectedIndices().length, selectionAllSpeciesList.getModel().getSize()))' /> - <JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}" - selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}" - enabled="false" - onValueChanged='allSpeciesLabel.setTitle(t("coser.ui.selection.allSpecies", selectionAllSpeciesList.getSelectedIndices().length, selectionAllSpeciesList.getModel().getSize()))' /> - </JScrollPane> - </cell> - <cell weightx="1" fill="both" columns="2"> - <JScrollPane> - <OccurrenceDensitySpeciesListModel id="selectionOccurrenceDensityListModel" - onContentsChanged='occurrenceDensitySpeciesLabel.setTitle(t("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))' /> - <JList id="selectionOccurrenceDensityList" model="{selectionOccurrenceDensityListModel}" - selectionModel="{new CoserListSelectionModel(selectionOccurrenceDensityList.getSelectionModel(), selectionOccurrenceDensityListModel)}" - onValueChanged='applyOccDensFilter.setEnabled(true); occurrenceDensitySpeciesLabel.setTitle(t("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))' /> - </JScrollPane> - </cell> - <cell weightx="1" fill="both" columns="2"> - <JScrollPane> - <SizeAllYearSpeciesListModel id="selectionSizeAllYearListModel" - onContentsChanged='sizeAllYearSpeciesLabel.setTitle(t("coser.ui.selection.sizeAllYearSpecies", selectionSizeAllYearList.getSelectedIndices().length, selectionSizeAllYearList.getModel().getSize()))' /> - <JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}" - selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}" - onValueChanged='sizeAllYearSpeciesLabel.setTitle(t("coser.ui.selection.sizeAllYearSpecies", selectionSizeAllYearList.getSelectedIndices().length, selectionSizeAllYearList.getModel().getSize()))' /> - </JScrollPane> - </cell> - <cell weightx="1" fill="both" columns="2"> - <JScrollPane> - <MaturitySpeciesListModel id="selectionMaturityListModel" - onContentsChanged='maturitySpeciesLabel.setTitle(t("coser.ui.selection.maturitySpecies", selectionMaturityList.getSelectedIndices().length, selectionMaturityList.getModel().getSize()))' /> - <JList id="selectionMaturityList" model="{selectionMaturityListModel}" - selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}" - onValueChanged='maturitySpeciesLabel.setTitle(t("coser.ui.selection.maturitySpecies", selectionMaturityList.getSelectedIndices().length, selectionMaturityList.getModel().getSize()))' /> - </JScrollPane> - </cell> - </row> - <row> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.selectAll.short' enabled="false" - onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).fillSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.unselectAll.short' enabled="false" - onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).clearSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.selectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).fillSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.unselectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).clearSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.selectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).fillSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.unselectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).clearSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.selectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).fillSelection()"/> - </cell> - <cell fill="horizontal" weightx="1"> - <JButton text='coser.ui.common.unselectAll.short' - onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).clearSelection()"/> - </cell> - </row> - <row> - <cell fill="horizontal" columns="2"> - <JLabel text="coser.ui.selection.comment" /> - </cell> - <cell fill="horizontal" columns="2"> - <JLabel text="coser.ui.selection.comment" /> - </cell> - <cell fill="horizontal" columns="2"> - <JLabel text="coser.ui.selection.comment" /> - </cell> - <cell fill="horizontal" columns="2"> - <JLabel text="coser.ui.selection.comment" /> - </cell> - </row> - <row> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="allSpeciesCommentField" rows="3" text="{getSelection().getSelectedSpeciesComment()}"/> - <javax.swing.text.Document javaBean="allSpeciesCommentField.getDocument()" - onInsertUpdate='getSelection().setSelectedSpeciesComment(allSpeciesCommentField.getText())' - onRemoveUpdate='getSelection().setSelectedSpeciesComment(allSpeciesCommentField.getText())' /> - </JScrollPane> - </cell> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="occurrenceDensityCommentField" rows="3" text="{getSelection().getSelectedSpeciesOccDensComment()}"/> - <javax.swing.text.Document javaBean="occurrenceDensityCommentField.getDocument()" - onInsertUpdate='getSelection().setSelectedSpeciesOccDensComment(occurrenceDensityCommentField.getText())' - onRemoveUpdate='getSelection().setSelectedSpeciesOccDensComment(occurrenceDensityCommentField.getText())' /> - </JScrollPane> - </cell> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="sizeAllYearCommentField" rows="3" text="{getSelection().getSelectedSpeciesSizeAllYearComment()}"/> - <javax.swing.text.Document javaBean="sizeAllYearCommentField.getDocument()" - onInsertUpdate='getSelection().setSelectedSpeciesSizeAllYearComment(sizeAllYearCommentField.getText())' - onRemoveUpdate='getSelection().setSelectedSpeciesSizeAllYearComment(sizeAllYearCommentField.getText())' /> - </JScrollPane> - </cell> - <cell fill="horizontal" columns="2"> - <JScrollPane> - <JTextArea id="maturityCommentField" rows="3" text="{getSelection().getSelectedSpeciesMaturityComment()}"/> - <javax.swing.text.Document javaBean="maturityCommentField.getDocument()" - onInsertUpdate='getSelection().setSelectedSpeciesMaturityComment(maturityCommentField.getText())' - onRemoveUpdate='getSelection().setSelectedSpeciesMaturityComment(maturityCommentField.getText())' /> - </JScrollPane> - </cell> - </row> + <row> + <cell columns="8" weightx="1" insets="0" fill="horizontal"> + <JToolBar floatable="false"> + <JButton icon="chart_curve.png" text="coser.ui.graph.compareNumberCatchLength" + onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)"/> + <JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure" + onActionPerformed="getHandler().displayLengthStructureGraph(this)"/> + <Component initializer="javax.swing.Box.createHorizontalGlue()"/> + <JButton id="validSelectionButton" text="coser.ui.selection.details.validSelection" + icon="accept.png" onActionPerformed="getHandler().validSelection(this)"/> + </JToolBar> + </cell> + </row> + <row> + <cell fill="horizontal" columns="2"> + <JXTitledSeparator id="allSpeciesLabel" title='{t("coser.ui.selection.allSpecies", 0, 0)}'/> + </cell> + <cell fill="horizontal" columns="2"> + <JXTitledSeparator id="occurrenceDensitySpeciesLabel" + title='{t("coser.ui.selection.occurrenceDensitySpecies", 0, 0)}'/> + </cell> + <cell fill="horizontal" columns="2"> + <JXTitledSeparator id="sizeAllYearSpeciesLabel" title='{t("coser.ui.selection.sizeAllYearSpecies", 0, 0)}'/> + </cell> + <cell fill="horizontal" columns="2"> + <JXTitledSeparator id="maturitySpeciesLabel" title='{t("coser.ui.selection.maturitySpecies", 0, 0)}'/> + </cell> + </row> + <row> + <cell/> + <cell/> + <cell fill="horizontal" insets="0" columns="2"> + <Table> + <row> + <cell> + <JLabel text="coser.ui.selection.filter.occurrence"/> + </cell> + <cell> + <JTextField id="selectionFilterOccurrenceField" columns="3" + text="{String.valueOf(getSelection().getOccurrenceFilter())}"/> + <javax.swing.text.Document javaBean="selectionFilterOccurrenceField.getDocument()" + onInsertUpdate='applyOccDensFilter.setEnabled(true)' + onRemoveUpdate='applyOccDensFilter.setEnabled(true)'/> + </cell> + <cell> + <JLabel text="coser.ui.selection.filter.occurrenceunit"/> + </cell> + <cell> + <JLabel text="coser.ui.selection.filter.density"/> + </cell> + <cell> + <JTextField id="selectionFilterDensityField" columns="3" + text="{String.valueOf(getSelection().getDensityFilter())}"/> + <javax.swing.text.Document javaBean="selectionFilterDensityField.getDocument()" + onInsertUpdate='applyOccDensFilter.setEnabled(true)' + onRemoveUpdate='applyOccDensFilter.setEnabled(true)'/> + </cell> + <cell> + <JLabel text="coser.ui.selection.filter.densityunit"/> + </cell> + </row> + <row> + <cell columns="6" anchor="center"> + <JButton id="applyOccDensFilter" text="coser.ui.selection.filter.filter" enabled="false" + onActionPerformed="getHandler().updateOccurrenceDensityFilter(this);applyOccDensFilter.setEnabled(false)"/> + </cell> + </row> + </Table> + </cell> + <cell/> + <cell/> + <cell/> + <cell/> + </row> + <row> + <cell weighty="1" weightx="1" fill="both" columns="2"> + <JScrollPane> + <SpeciesListModel id="selectionAllSpeciesListModel" + onContentsChanged='allSpeciesLabel.setTitle(t("coser.ui.selection.allSpecies", selectionAllSpeciesList.getSelectedIndices().length, selectionAllSpeciesList.getModel().getSize()))'/> + <JList id="selectionAllSpeciesList" model="{selectionAllSpeciesListModel}" + selectionModel="{new CoserListSelectionModel(selectionAllSpeciesList.getSelectionModel(), selectionAllSpeciesListModel)}" + enabled="false" + onValueChanged='allSpeciesLabel.setTitle(t("coser.ui.selection.allSpecies", selectionAllSpeciesList.getSelectedIndices().length, selectionAllSpeciesList.getModel().getSize()))'/> + </JScrollPane> + </cell> + <cell weightx="1" fill="both" columns="2"> + <JScrollPane> + <OccurrenceDensitySpeciesListModel id="selectionOccurrenceDensityListModel" + onContentsChanged='occurrenceDensitySpeciesLabel.setTitle(t("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))'/> + <JList id="selectionOccurrenceDensityList" model="{selectionOccurrenceDensityListModel}" + selectionModel="{new CoserListSelectionModel(selectionOccurrenceDensityList.getSelectionModel(), selectionOccurrenceDensityListModel)}" + onValueChanged='applyOccDensFilter.setEnabled(true); occurrenceDensitySpeciesLabel.setTitle(t("coser.ui.selection.occurrenceDensitySpecies", selectionOccurrenceDensityList.getSelectedIndices().length, selectionOccurrenceDensityList.getModel().getSize()))'/> + </JScrollPane> + </cell> + <cell weightx="1" fill="both" columns="2"> + <JScrollPane> + <SizeAllYearSpeciesListModel id="selectionSizeAllYearListModel" + onContentsChanged='sizeAllYearSpeciesLabel.setTitle(t("coser.ui.selection.sizeAllYearSpecies", selectionSizeAllYearList.getSelectedIndices().length, selectionSizeAllYearList.getModel().getSize()))'/> + <JList id="selectionSizeAllYearList" model="{selectionSizeAllYearListModel}" + selectionModel="{new CoserListSelectionModel(selectionSizeAllYearList.getSelectionModel(), selectionSizeAllYearListModel)}" + onValueChanged='sizeAllYearSpeciesLabel.setTitle(t("coser.ui.selection.sizeAllYearSpecies", selectionSizeAllYearList.getSelectedIndices().length, selectionSizeAllYearList.getModel().getSize()))'/> + </JScrollPane> + </cell> + <cell weightx="1" fill="both" columns="2"> + <JScrollPane> + <MaturitySpeciesListModel id="selectionMaturityListModel" + onContentsChanged='maturitySpeciesLabel.setTitle(t("coser.ui.selection.maturitySpecies", selectionMaturityList.getSelectedIndices().length, selectionMaturityList.getModel().getSize()))'/> + <JList id="selectionMaturityList" model="{selectionMaturityListModel}" + selectionModel="{new CoserListSelectionModel(selectionMaturityList.getSelectionModel(), selectionMaturityListModel)}" + onValueChanged='maturitySpeciesLabel.setTitle(t("coser.ui.selection.maturitySpecies", selectionMaturityList.getSelectedIndices().length, selectionMaturityList.getModel().getSize()))'/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.selectAll.short' enabled="false" + onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).fillSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.unselectAll.short' enabled="false" + onActionPerformed="((CoserListSelectionModel)selectionAllSpeciesList.getSelectionModel()).clearSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.selectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).fillSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.unselectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionOccurrenceDensityList.getSelectionModel()).clearSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.selectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).fillSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.unselectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionSizeAllYearList.getSelectionModel()).clearSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.selectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).fillSelection()"/> + </cell> + <cell fill="horizontal" weightx="1"> + <JButton text='coser.ui.common.unselectAll.short' + onActionPerformed="((CoserListSelectionModel)selectionMaturityList.getSelectionModel()).clearSelection()"/> + </cell> + </row> + <row> + <cell fill="horizontal" columns="2"> + <JLabel text="coser.ui.selection.comment"/> + </cell> + <cell fill="horizontal" columns="2"> + <JLabel text="coser.ui.selection.comment"/> + </cell> + <cell fill="horizontal" columns="2"> + <JLabel text="coser.ui.selection.comment"/> + </cell> + <cell fill="horizontal" columns="2"> + <JLabel text="coser.ui.selection.comment"/> + </cell> + </row> + <row> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="allSpeciesCommentField" rows="3" text="{getSelection().getSelectedSpeciesComment()}"/> + <javax.swing.text.Document javaBean="allSpeciesCommentField.getDocument()" + onInsertUpdate='getSelection().setSelectedSpeciesComment(allSpeciesCommentField.getText())' + onRemoveUpdate='getSelection().setSelectedSpeciesComment(allSpeciesCommentField.getText())'/> + </JScrollPane> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="occurrenceDensityCommentField" rows="3" + text="{getSelection().getSelectedSpeciesOccDensComment()}"/> + <javax.swing.text.Document javaBean="occurrenceDensityCommentField.getDocument()" + onInsertUpdate='getSelection().setSelectedSpeciesOccDensComment(occurrenceDensityCommentField.getText())' + onRemoveUpdate='getSelection().setSelectedSpeciesOccDensComment(occurrenceDensityCommentField.getText())'/> + </JScrollPane> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="sizeAllYearCommentField" rows="3" + text="{getSelection().getSelectedSpeciesSizeAllYearComment()}"/> + <javax.swing.text.Document javaBean="sizeAllYearCommentField.getDocument()" + onInsertUpdate='getSelection().setSelectedSpeciesSizeAllYearComment(sizeAllYearCommentField.getText())' + onRemoveUpdate='getSelection().setSelectedSpeciesSizeAllYearComment(sizeAllYearCommentField.getText())'/> + </JScrollPane> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="maturityCommentField" rows="3" text="{getSelection().getSelectedSpeciesMaturityComment()}"/> + <javax.swing.text.Document javaBean="maturityCommentField.getDocument()" + onInsertUpdate='getSelection().setSelectedSpeciesMaturityComment(maturityCommentField.getText())' + onRemoveUpdate='getSelection().setSelectedSpeciesMaturityComment(maturityCommentField.getText())'/> + </JScrollPane> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx index 9552491..88fd609 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx @@ -20,84 +20,84 @@ #L% --> <Table> - <script><![CDATA[ + <script><![CDATA[ void $afterCompleteSetup() { fr.ifremer.coser.ui.result.ResultTableRenderer renderer = new fr.ifremer.coser.ui.result.ResultTableRenderer(this); selectionResultsTable.setDefaultRenderer(Object.class, renderer); } ]]></script> - <SelectionHandler id="handler" javaBean="null" /> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.selection.option.optionTitle"))}'> - <row> - <cell weightx="1" anchor="west"> - <JButton text="coser.ui.selection.option.editFiles" - onActionPerformed="getHandler().showSelectionFilesEdit(this)"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell weightx="1" fill="horizontal"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.result.extractDataTitle"))}'> - <row> - <cell> - <JLabel text="coser.ui.result.extractDataLabel" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JTextField id="resultExtractDataField" /> - </cell> - <cell> - <JButton text="coser.ui.common.selectFile" - onActionPerformed="getHandler().selectOutputDirectory(this, resultExtractDataField)" /> - </cell> - </row> - <row> - <cell columns="3"> - <JButton text="coser.ui.result.extractDataButton" enabled="{!resultExtractDataField.getText().isEmpty()}" - onActionPerformed="getHandler().extractRSufiData(this)"/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <!-- separation visuelle des 2 etapes --> - <cell insets="30"> - <JPanel /> - </cell> - </row> - <row> - <cell weightx="1" weighty="2" fill="both"> - <Table border='{BorderFactory.createTitledBorder(t("coser.ui.result.availableDataTitle"))}'> - <row> - <cell columns="3" weightx="1" weighty="1" fill="both"> - <JScrollPane> - <fr.ifremer.coser.ui.result.ResultTableModel id="selectionResultsTableModel" - javaBean="new fr.ifremer.coser.ui.result.ResultTableModel(this)" /> - <JTable id="selectionResultsTable" model="{getSelectionResultsTableModel()}"/> - <ListSelectionModel javaBean="selectionResultsTable.getSelectionModel()" - onValueChanged="editResultButton.setEnabled(getSelectionResultsTable().getSelectedRow() != -1);deleteResultButton.setEnabled(getSelectionResultsTable().getSelectedRow() != -1)" /> - </JScrollPane> - </cell> - </row> - <row> - <cell weightx="1" anchor="east"> - <JButton id="deleteResultButton" text="coser.ui.result.deleteResult" enabled="false" - onActionPerformed="getHandler().deleteResult(this)" /> - </cell> - <cell> - <JButton id="editResultButton" text="coser.ui.result.editResult" enabled="false" - onActionPerformed="getHandler().showEditResultDialog(this)" /> - </cell> - <cell> - <JButton text="coser.ui.result.addNewResult" - onActionPerformed="getHandler().showAddResultDialog(this)" /> - </cell> - </row> - </Table> - </cell> - </row> + <SelectionHandler id="handler" javaBean="null"/> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.selection.option.optionTitle"))}'> + <row> + <cell weightx="1" anchor="west"> + <JButton text="coser.ui.selection.option.editFiles" + onActionPerformed="getHandler().showSelectionFilesEdit(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.result.extractDataTitle"))}'> + <row> + <cell> + <JLabel text="coser.ui.result.extractDataLabel"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JTextField id="resultExtractDataField"/> + </cell> + <cell> + <JButton text="coser.ui.common.selectFile" + onActionPerformed="getHandler().selectOutputDirectory(this, resultExtractDataField)"/> + </cell> + </row> + <row> + <cell columns="3"> + <JButton text="coser.ui.result.extractDataButton" enabled="{!resultExtractDataField.getText().isEmpty()}" + onActionPerformed="getHandler().extractRSufiData(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <!-- separation visuelle des 2 etapes --> + <cell insets="30"> + <JPanel/> + </cell> + </row> + <row> + <cell weightx="1" weighty="2" fill="both"> + <Table border='{BorderFactory.createTitledBorder(t("coser.ui.result.availableDataTitle"))}'> + <row> + <cell columns="3" weightx="1" weighty="1" fill="both"> + <JScrollPane> + <fr.ifremer.coser.ui.result.ResultTableModel id="selectionResultsTableModel" + javaBean="new fr.ifremer.coser.ui.result.ResultTableModel(this)"/> + <JTable id="selectionResultsTable" model="{getSelectionResultsTableModel()}"/> + <ListSelectionModel javaBean="selectionResultsTable.getSelectionModel()" + onValueChanged="editResultButton.setEnabled(getSelectionResultsTable().getSelectedRow() != -1);deleteResultButton.setEnabled(getSelectionResultsTable().getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> + <row> + <cell weightx="1" anchor="east"> + <JButton id="deleteResultButton" text="coser.ui.result.deleteResult" enabled="false" + onActionPerformed="getHandler().deleteResult(this)"/> + </cell> + <cell> + <JButton id="editResultButton" text="coser.ui.result.editResult" enabled="false" + onActionPerformed="getHandler().showEditResultDialog(this)"/> + </cell> + <cell> + <JButton text="coser.ui.result.addNewResult" + onActionPerformed="getHandler().showAddResultDialog(this)"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx index 8c63e13..13fd39b 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx @@ -20,17 +20,17 @@ #L% --> <JTabbedPane> - <import> + <import> javax.swing.event.ChangeEvent javax.swing.event.ChangeListener - </import> + </import> - <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null"/> - <Boolean id="creationState" javaBean="false" /> + <Boolean id="creationState" javaBean="false"/> - <SelectionHandler id="handler" javaBean="null" /> - <script><![CDATA[ + <SelectionHandler id="handler" javaBean="null"/> + <script><![CDATA[ void $afterCompleteSetup() { addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { @@ -41,16 +41,16 @@ }); } ]]></script> - <tab title="coser.ui.selection.tab.details"> - <SelectionDetailsView id="selectionDetailsTab" constructorParams="this" - handler="{getHandler()}" selection="{getSelection()}" creationState="{isCreationState()}"/> - </tab> - <tab title="coser.ui.selection.tab.lists"> - <SelectionListsView id="selectionListsView" constructorParams="this" - handler="{getHandler()}" selection="{getSelection()}" /> - </tab> - <tab title="coser.ui.selection.tab.rsufi"> - <SelectionRsufiView id="selectionResultView" constructorParams="this" - handler="{getHandler()}" /> - </tab> + <tab title="coser.ui.selection.tab.details"> + <SelectionDetailsView id="selectionDetailsTab" constructorParams="this" + handler="{getHandler()}" selection="{getSelection()}" creationState="{isCreationState()}"/> + </tab> + <tab title="coser.ui.selection.tab.lists"> + <SelectionListsView id="selectionListsView" constructorParams="this" + handler="{getHandler()}" selection="{getSelection()}"/> + </tab> + <tab title="coser.ui.selection.tab.rsufi"> + <SelectionRsufiView id="selectionResultView" constructorParams="this" + handler="{getHandler()}"/> + </tab> </JTabbedPane> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx index 90d2af8..a3757d4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesFusionDialog.jaxx @@ -20,38 +20,38 @@ #L% --> <JDialog modal="true"> - <SelectionHandler id="handler" javaBean="null" /> - <Table> - <row> - <cell columns="2" fill="horizontal"> - <JLabel text="coser.ui.selection.fusion.description" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.selection.fusion.name" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JComboBox id="speciesCombo" /> - </cell> - </row> - <row> - <cell fill="horizontal" anchor="northwest"> - <JLabel text="coser.ui.selection.fusion.comment" /> - </cell> - <cell weightx="2" weighty="1" fill="both" columns="3"> - <JScrollPane> - <JTextArea id="commentField" rows="3" /> - </JScrollPane> - </cell> - </row> - <row> - <cell columns="4" anchor="east" insets="0"> - <JPanel> - <JButton text="coser.ui.common.cancel" onActionPerformed="dispose()"/> - <JButton text="coser.ui.common.valid" onActionPerformed="getHandler().performMergeSpecies(this)" /> - </JPanel> - </cell> - </row> - </Table> + <SelectionHandler id="handler" javaBean="null"/> + <Table> + <row> + <cell columns="2" fill="horizontal"> + <JLabel text="coser.ui.selection.fusion.description"/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.selection.fusion.name"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JComboBox id="speciesCombo"/> + </cell> + </row> + <row> + <cell fill="horizontal" anchor="northwest"> + <JLabel text="coser.ui.selection.fusion.comment"/> + </cell> + <cell weightx="2" weighty="1" fill="both" columns="3"> + <JScrollPane> + <JTextArea id="commentField" rows="3"/> + </JScrollPane> + </cell> + </row> + <row> + <cell columns="4" anchor="east" insets="0"> + <JPanel> + <JButton text="coser.ui.common.cancel" onActionPerformed="dispose()"/> + <JButton text="coser.ui.common.valid" onActionPerformed="getHandler().performMergeSpecies(this)"/> + </JPanel> + </cell> + </row> + </Table> </JDialog> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java index 9170faf..891f0d2 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesListOccDensRenderer.java @@ -22,29 +22,23 @@ package fr.ifremer.coser.ui.selection; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel; +import org.jdesktop.swingx.renderer.DefaultListRenderer; +import javax.swing.JList; import java.awt.Component; import java.util.Map; -import javax.swing.JList; - -import org.jdesktop.swingx.renderer.DefaultListRenderer; - -import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel; +import static org.nuiton.i18n.I18n.t; /** * Specy renderer with occurrence and density display. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesListOccDensRenderer extends DefaultListRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -5404111064519251687L; protected Map<String, String> reftaxSpecies; @@ -55,10 +49,10 @@ public class SpeciesListOccDensRenderer extends DefaultListRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { - String species = (String)value; - OccurrenceDensitySpeciesListModel model = (OccurrenceDensitySpeciesListModel)list.getModel(); + String species = (String) value; + OccurrenceDensitySpeciesListModel model = (OccurrenceDensitySpeciesListModel) list.getModel(); double occurrence = model.getOccurrence(species); double density = model.getDensity(species); @@ -68,8 +62,8 @@ public class SpeciesListOccDensRenderer extends DefaultListRenderer { speciesText = reftaxSpecies.get(species); } String stringValue = t("coser.ui.selection.occurrencedensityrenderer", speciesText, occurrence, density); - + return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); } - + } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java index a39cd36..b45f97a 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpeciesTypesRenderer.java @@ -22,46 +22,39 @@ package fr.ifremer.coser.ui.selection; -import java.awt.Component; - -import javax.swing.JList; - +import fr.ifremer.coser.ui.selection.model.SpeciesTypesListModel; import org.apache.commons.lang3.StringUtils; import org.jdesktop.swingx.renderer.DefaultListRenderer; -import fr.ifremer.coser.ui.selection.model.SpeciesTypesListModel; +import javax.swing.JList; +import java.awt.Component; /** * Specy type renderer (with comment display when available). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesTypesRenderer extends DefaultListRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = -6218097608544949959L; @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { - String species = (String)value; - SpeciesTypesListModel model = (SpeciesTypesListModel)list.getModel(); + String species = (String) value; + SpeciesTypesListModel model = (SpeciesTypesListModel) list.getModel(); String comment = model.getComment(species); String stringValue = null; if (StringUtils.isEmpty(comment)) { stringValue = species; - } - else { - stringValue = species + " (" + comment + ")"; + } else { + stringValue = species + " (" + comment + ")"; } return super.getListCellRendererComponent(list, stringValue, index, isSelected, cellHasFocus); } - + } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java index 0850e06..54a01b4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java @@ -22,25 +22,20 @@ package fr.ifremer.coser.ui.selection.model; +import javax.swing.AbstractListModel; import java.io.File; import java.util.ArrayList; import java.util.List; -import javax.swing.AbstractListModel; - /** * Modele de list pour la list des fichiers et répertoire des fichiers * additionnels. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class FileListModel extends AbstractListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -8652851018076968539L; protected List<File> files; @@ -52,7 +47,7 @@ public class FileListModel extends AbstractListModel { public List<File> getFiles() { return files; } - + public void setFiles(List<File> files) { this.files = files; fireContentsChanged(this, 0, files.size() - 1); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java index 72b4124..cbb9e3b 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/MaturitySpeciesListModel.java @@ -22,29 +22,24 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; import javax.swing.AbstractListModel; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * Specy list model with size all year. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class MaturitySpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<String> species = new ArrayList<String>(); @@ -85,7 +80,7 @@ public class MaturitySpeciesListModel extends AbstractListModel implements ListS return species.get(index); } - + /* * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) */ @@ -101,11 +96,11 @@ public class MaturitySpeciesListModel extends AbstractListModel implements ListS public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); + JList source = (JList) event.getSource(); Object[] selectedValues = source.getSelectedValues(); species.clear(); for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; + String specy = (String) selectedValue; if (maturitySpecies.contains(specy)) { species.add(specy); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java index b7f454a..48e7c80 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/OccurrenceDensitySpeciesListModel.java @@ -22,30 +22,24 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.ArrayList; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; +import org.nuiton.math.matrix.MatrixND; import javax.swing.AbstractListModel; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - -import org.nuiton.math.matrix.MatrixND; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.ArrayList; +import java.util.List; /** * Occurence and density filered specy list model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class OccurrenceDensitySpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<String> species = new ArrayList<String>(); @@ -72,14 +66,14 @@ public class OccurrenceDensitySpeciesListModel extends AbstractListModel impleme } public double getOccurrence(String specy) { - List<String> years = (List<String>)occurrence.getSemantic(1); + List<String> years = (List<String>) occurrence.getSemantic(1); // get(0) == mean value (meanOverDim(1)) double result = occurrence.getValue(specy, years.get(0)); return result; } - + public double getDensity(String specy) { - List<String> years = (List<String>)density.getSemantic(1); + List<String> years = (List<String>) density.getSemantic(1); // get(0) == mean value (meanOverDim(1)) double result = density.getValue(specy, years.get(0)); return result; @@ -105,7 +99,7 @@ public class OccurrenceDensitySpeciesListModel extends AbstractListModel impleme return species.get(index); } - + /* * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) */ @@ -121,11 +115,11 @@ public class OccurrenceDensitySpeciesListModel extends AbstractListModel impleme public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); + JList source = (JList) event.getSource(); Object[] selectedValues = source.getSelectedValues(); species.clear(); for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; + String specy = (String) selectedValue; species.add(specy); } fireContentsChanged(this, 0, species.size() - 1); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java index 92d7603..a8a13a5 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SizeAllYearSpeciesListModel.java @@ -22,29 +22,24 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; import javax.swing.AbstractListModel; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; /** * Specy list model with size all year. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SizeAllYearSpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<String> species = new ArrayList<String>(); @@ -85,7 +80,7 @@ public class SizeAllYearSpeciesListModel extends AbstractListModel implements Li return species.get(index); } - + /* * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) */ @@ -101,11 +96,11 @@ public class SizeAllYearSpeciesListModel extends AbstractListModel implements Li public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); + JList source = (JList) event.getSource(); Object[] selectedValues = source.getSelectedValues(); species.clear(); for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; + String specy = (String) selectedValue; if (sizeAllYearSpecies.contains(specy)) { species.add(specy); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java index e3b3135..8fb05c9 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesListModel.java @@ -22,28 +22,23 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.ArrayList; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; import javax.swing.AbstractListModel; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.ArrayList; +import java.util.List; /** * No filtered species model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesListModel extends AbstractListModel implements ListSelectionListener, CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<String> species = new ArrayList<String>(); @@ -77,7 +72,7 @@ public class SpeciesListModel extends AbstractListModel implements ListSelection return species.get(index); } - + /* * @see fr.ifremer.coser.ui.util.CoserListModel#indexOf(java.lang.Object) */ @@ -93,11 +88,11 @@ public class SpeciesListModel extends AbstractListModel implements ListSelection public void valueChanged(ListSelectionEvent event) { if (!event.getValueIsAdjusting()) { - JList source = (JList)event.getSource(); + JList source = (JList) event.getSource(); Object[] selectedValues = source.getSelectedValues(); species.clear(); for (Object selectedValue : selectedValues) { - String specy = (String)selectedValue; + String specy = (String) selectedValue; species.add(specy); } fireContentsChanged(this, 0, species.size() - 1); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java index 30c7ea1..b75a8fb 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/SpeciesTypesListModel.java @@ -22,35 +22,30 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.swing.AbstractListModel; - import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.ui.selection.SelectionDetailsView; import fr.ifremer.coser.ui.util.CoserListModel; +import javax.swing.AbstractListModel; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + /** * Affiche la liste des types d'especes définie dans le projet. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SpeciesTypesListModel extends AbstractListModel implements CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 441910182067909029L; protected SelectionDetailsView view; protected List<String> types; - + protected Map<String, String> typesComments; public SpeciesTypesListModel(SelectionDetailsView view) { @@ -69,7 +64,7 @@ public class SpeciesTypesListModel extends AbstractListModel implements CoserLis /** * Get species comment (used in renderer). - * + * * @param species species * @return species comment */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java index 81fafaa..d7f0a92 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/StrataListModel.java @@ -22,24 +22,19 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; import javax.swing.AbstractListModel; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.List; /** * Model contenant la liste des noms de strates (utilisé dans le detail de selection). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class StrataListModel extends AbstractListModel implements CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -8155676616312843132L; protected List<String> strata; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java index 886acba..c33908b 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/YearListModel.java @@ -22,25 +22,20 @@ package fr.ifremer.coser.ui.selection.model; -import java.util.List; +import fr.ifremer.coser.ui.util.CoserListModel; import javax.swing.AbstractListModel; - -import fr.ifremer.coser.ui.util.CoserListModel; +import java.util.List; /** * Model pour list contenant la liste des années définies dans le projet et * en selection la liste des années définie pour la selection. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class YearListModel extends AbstractListModel implements CoserListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = 9172638630862188715L; protected List<String> years; diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListModel.java index 493365f..22c7f0c 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListModel.java @@ -22,25 +22,20 @@ package fr.ifremer.coser.ui.selection.replay; -import java.util.ArrayList; -import java.util.List; +import fr.ifremer.coser.command.Command; import javax.swing.AbstractListModel; - -import fr.ifremer.coser.command.Command; +import java.util.ArrayList; +import java.util.List; /** * Command model. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CommandListModel extends AbstractListModel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4769109927915812519L; protected List<Command> commands = new ArrayList<Command>(); diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListRenderer.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListRenderer.java index 193ebc7..7062907 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListRenderer.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/CommandListRenderer.java @@ -22,26 +22,21 @@ package fr.ifremer.coser.ui.selection.replay; -import java.awt.Component; +import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.command.Command; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; - -import fr.ifremer.coser.bean.Project; -import fr.ifremer.coser.command.Command; +import java.awt.Component; /** * List cell renderer for command (display command description). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CommandListRenderer extends DefaultListCellRenderer { - /** serialVersionUID. */ + private static final long serialVersionUID = 6780656602646606040L; protected Project project; @@ -52,10 +47,10 @@ public class CommandListRenderer extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { + int index, boolean isSelected, boolean cellHasFocus) { + + Command command = (Command) value; - Command command = (Command)value; - // can be null here. Renderer is currently used only un selection // replay where merge command don't use container to get desc String commandDesc = command.getDescription(project, null); @@ -64,6 +59,6 @@ public class CommandListRenderer extends DefaultListCellRenderer { // command in replay selection as of coser version 1.2.x // may change in v 2.0 return super.getListCellRendererComponent(list, commandDesc, index, - true, cellHasFocus); + true, cellHasFocus); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionByProjectTreeModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionByProjectTreeModel.java index 7858450..fc3bea4 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionByProjectTreeModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionByProjectTreeModel.java @@ -22,26 +22,22 @@ package fr.ifremer.coser.ui.selection.replay; -import java.util.ArrayList; -import java.util.List; -import java.util.SortedMap; - import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.List; +import java.util.SortedMap; /** * TreeModel that display all selections in all projects. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SelectionByProjectTreeModel implements TreeModel { protected SortedMap<String, List<String>> selectionsByProject; + protected List<String> projects; public SelectionByProjectTreeModel(SortedMap<String, List<String>> selectionsByProject) { @@ -93,7 +89,7 @@ public class SelectionByProjectTreeModel implements TreeModel { @Override public void valueForPathChanged(TreePath path, Object newValue) { - + } @Override @@ -111,11 +107,11 @@ public class SelectionByProjectTreeModel implements TreeModel { @Override public void addTreeModelListener(TreeModelListener l) { - + } @Override public void removeTreeModelListener(TreeModelListener l) { - + } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayHandler.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayHandler.java index b20c4d8..52b6cf5 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayHandler.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayHandler.java @@ -22,24 +22,6 @@ package fr.ifremer.coser.ui.selection.replay; -import static org.nuiton.i18n.I18n.t; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.SortedMap; - -import javax.swing.JOptionPane; -import javax.swing.tree.TreePath; - -import jaxx.runtime.JAXXUtil; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserException; import fr.ifremer.coser.CoserUtils; @@ -52,15 +34,26 @@ import fr.ifremer.coser.ui.CoserFrame; import fr.ifremer.coser.ui.common.CommonHandler; import fr.ifremer.coser.ui.common.SpeciesListRenderer; import fr.ifremer.coser.ui.util.CoserListSelectionModel; +import jaxx.runtime.JAXXUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.SortedMap; + +import static org.nuiton.i18n.I18n.t; /** * Specific handler for selection replay view. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class SelectionReplayHandler extends CommonHandler { @@ -68,14 +61,14 @@ public class SelectionReplayHandler extends CommonHandler { /** * Init view by displaying all selection available in all project. - * + * * @param view view to init */ public void initReplayView(SelectionReplayView view) { ProjectService projectService = view.getContextValue(ProjectService.class); Project project = view.getContextValue(Project.class); SortedMap<String, List<String>> selectionsByProject = projectService.getSelectionByProject(); - + SelectionByProjectTreeModel treeModel = new SelectionByProjectTreeModel(selectionsByProject); view.getSelectionByProjectTree().setModel(treeModel); @@ -85,7 +78,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation de la selection a rejouer (etape 1). - * + * * @param view view */ public void validSelectionChoice(SelectionReplayView view) { @@ -96,8 +89,8 @@ public class SelectionReplayHandler extends CommonHandler { try { setWaitCursor(view); - String selectionName = (String)selectedSelection.getLastPathComponent(); - String projectName = (String)selectedSelection.getParentPath().getLastPathComponent(); + String selectionName = (String) selectedSelection.getLastPathComponent(); + String projectName = (String) selectedSelection.getParentPath().getLastPathComponent(); // load selection Selection replayedSelection = projectService.openSelection(projectName, selectionName); @@ -108,11 +101,11 @@ public class SelectionReplayHandler extends CommonHandler { view.setSelection(selection); // hack, binding won't work view.getValidatorSelection().setBean(selection); - + // init next step view.getYearsListModel().setYears(selection.getAllYears()); - ((CoserListSelectionModel)view.getYearsList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedYears()); - + ((CoserListSelectionModel) view.getYearsList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedYears()); + // affichage d'un message si la selection de liste n'est pas // cohérente Collection<String> remaindYear = CollectionUtils.subtract(replayedSelection.getSelectedYears(), selection.getAllYears()); @@ -132,7 +125,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des années sélectionnées (etape 2) - * + * * @param view view */ public void validSelectionYears(SelectionReplayView view) { @@ -148,7 +141,7 @@ public class SelectionReplayHandler extends CommonHandler { Object[] selectedDates = view.getYearsList().getSelectedValues(); List<String> years = new ArrayList<String>(selectedDates.length); for (Object selectedDate : selectedDates) { - years.add((String)selectedDate); + years.add((String) selectedDate); } if (log.isDebugEnabled()) { @@ -160,7 +153,7 @@ public class SelectionReplayHandler extends CommonHandler { List<String> strata = projectService.filterDataYearsAndGetStrata(project, selection, years); view.getStrataListModel().setStrata(strata); - ((CoserListSelectionModel)view.getStrataList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedStrata()); + ((CoserListSelectionModel) view.getStrataList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedStrata()); if (log.isDebugEnabled()) { log.debug("Strata list refreshed"); @@ -186,7 +179,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des strates (étape 3). - * + * * @param view view */ public void validSelectionStrata(SelectionReplayView view) { @@ -206,7 +199,7 @@ public class SelectionReplayHandler extends CommonHandler { Object[] selectedStrata = view.getStrataList().getSelectedValues(); List<String> strata = new ArrayList<String>(selectedStrata.length); for (Object selectedStratum : selectedStrata) { - strata.add((String)selectedStratum); + strata.add((String) selectedStratum); } // do selection.setSelectedStrata(strata); @@ -229,7 +222,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des commands (fusion, etc...). - * + * * @param view view */ public void validSelectionCommand(SelectionReplayView view) { @@ -260,7 +253,7 @@ public class SelectionReplayHandler extends CommonHandler { view.getSelectedSpeciesListModel().setSpecies(currentSpecies); view.getSelectedSpeciesList().setCellRenderer(new SpeciesListRenderer(reftaxSpecies)); - ((CoserListSelectionModel)view.getSelectedSpeciesList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedSpecies()); + ((CoserListSelectionModel) view.getSelectedSpeciesList().getSelectionModel()).setSelectedObjects(replayedSelection.getSelectedSpecies()); // affichage d'un message si la selection de liste n'est pas // cohérente @@ -288,7 +281,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des strates. - * + * * @param view view */ public void validSelectionSpecies(SelectionReplayView view) { @@ -305,15 +298,15 @@ public class SelectionReplayHandler extends CommonHandler { Object[] selectedSpeciesArr = view.getSelectedSpeciesList().getSelectedValues(); List<String> selectedSpecies = new ArrayList<String>(selectedSpeciesArr.length); for (Object selectedSingleSpecies : selectedSpeciesArr) { - selectedSpecies.add((String)selectedSingleSpecies); + selectedSpecies.add((String) selectedSingleSpecies); } projectService.filterDataSpecies(project, selection, selectedSpecies); // auto selection des listes L2 à L4 projectService.fillListsSelection(selection, - replayedSelection.getSelectedSpeciesOccDens(), - replayedSelection.getSelectedSpeciesSizeAllYear(), - replayedSelection.getSelectedSpeciesMaturity()); + replayedSelection.getSelectedSpeciesOccDens(), + replayedSelection.getSelectedSpeciesSizeAllYear(), + replayedSelection.getSelectedSpeciesMaturity()); // init next step view.getWizardLayout().show(view.getWizardPanel(), "step6"); @@ -325,7 +318,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation finale de la selection. - * + * * @param view view */ public void validSelectionInfos(SelectionReplayView view) { @@ -344,7 +337,7 @@ public class SelectionReplayHandler extends CommonHandler { parent.getHandler().showSelectionView(selection, 1); JOptionPane.showMessageDialog(view, t("coser.ui.selection.selectionCreated"), - t("coser.ui.selection.replay.replayTitle"), JOptionPane.INFORMATION_MESSAGE); + t("coser.ui.selection.replay.replayTitle"), JOptionPane.INFORMATION_MESSAGE); // hide current frame view.dispose(); @@ -354,7 +347,7 @@ public class SelectionReplayHandler extends CommonHandler { log.error("Can't save selection", ex); } JOptionPane.showMessageDialog(view, ex.getMessage(), t("coser.ui.selection.saveError"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.ERROR_MESSAGE); } finally { setDefaultCursor(view); } @@ -362,7 +355,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des étapes 1 a la dernière. - * + * * @param view view */ public void finishSelection1toFinal(SelectionReplayView view) { @@ -372,7 +365,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des étapes 2 a la dernière. - * + * * @param view view */ public void finishSelection2toFinal(SelectionReplayView view) { @@ -382,7 +375,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des étapes 3 a la dernière. - * + * * @param view view */ public void finishSelection3toFinal(SelectionReplayView view) { @@ -392,7 +385,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des étapes 4 a la dernière. - * + * * @param view view */ public void finishSelection4toFinal(SelectionReplayView view) { @@ -403,7 +396,7 @@ public class SelectionReplayHandler extends CommonHandler { /** * Validation des étapes 5 a la dernière. * (ne valide pas la dernière : infos de selection obligatoires) - * + * * @param view view */ public void finishSelection5toFinal(SelectionReplayView view) { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayView.jaxx b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayView.jaxx index d918ec1..a4c52bd 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayView.jaxx +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/replay/SelectionReplayView.jaxx @@ -22,149 +22,149 @@ <JDialog title="coser.ui.selection.replay.replayTitle" width="600" height="500"> <import> - fr.ifremer.coser.ui.selection.model.SpeciesListModel - fr.ifremer.coser.ui.selection.model.SpeciesTypesListModel - fr.ifremer.coser.ui.selection.model.StrataListModel - fr.ifremer.coser.ui.selection.model.YearListModel - fr.ifremer.coser.ui.util.CoserListSelectionModel + fr.ifremer.coser.ui.selection.model.SpeciesListModel + fr.ifremer.coser.ui.selection.model.SpeciesTypesListModel + fr.ifremer.coser.ui.selection.model.StrataListModel + fr.ifremer.coser.ui.selection.model.YearListModel + fr.ifremer.coser.ui.util.CoserListSelectionModel </import> <Table> - <SelectionReplayHandler id="handler" /> - <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> - <fr.ifremer.coser.bean.Selection id="replayedSelection" javaBean="null" /> + <SelectionReplayHandler id="handler"/> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null"/> + <fr.ifremer.coser.bean.Selection id="replayedSelection" javaBean="null"/> <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' - onTableChanged='validSelectionInfosButton.setEnabled(getErrorsTableModel().getRowCount() == 0)'/> + onTableChanged='validSelectionInfosButton.setEnabled(getErrorsTableModel().getRowCount() == 0)'/> <BeanValidator id='validatorSelection' bean='selection' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" - errorTableModel="errorsTableModel"> - <field name="name" component="detailsSelectionNameField" /> - <field name="description" component="detailsDescriptionSP" /> + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="detailsSelectionNameField"/> + <field name="description" component="detailsDescriptionSP"/> </BeanValidator> <row> <cell weightx="1" weighty="1" fill="both"> - <CardLayout id="wizardLayout" /> + <CardLayout id="wizardLayout"/> <JPanel id="wizardPanel" layout="{wizardLayout}"> - + <!-- Step 1 : selection choice --> <Table constraints='"step1"'> <row> <cell weightx="1" fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.replay.chooseselection" /> + <JLabel text="coser.ui.selection.replay.chooseselection"/> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both" columns="3"> <JScrollPane> <JTree id="selectionByProjectTree" rootVisible="false" showsRootHandles="true" - onValueChanged="validSelectionButton.setEnabled(selectionByProjectTree.getSelectionPath() != null && selectionByProjectTree.getSelectionPath().getPathCount() == 3);"/> + onValueChanged="validSelectionButton.setEnabled(selectionByProjectTree.getSelectionPath() != null && selectionByProjectTree.getSelectionPath().getPathCount() == 3);"/> </JScrollPane> </cell> </row> <row> <cell weightx="1" fill="horizontal" columns="3"> <JTextArea id="messageArea1" rows="3" editable="false" - text='{t("coser.ui.selection.replay.noerrordetected")}' /> + text='{t("coser.ui.selection.replay.noerrordetected")}'/> </cell> </row> <row> <cell weightx="1" anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell weightx="1" anchor="east"> <JButton id="validSelectionButton" text="coser.ui.selection.replay.nextstep" - enabled="false" - onActionPerformed="getHandler().validSelectionChoice(this)" /> + enabled="false" + onActionPerformed="getHandler().validSelectionChoice(this)"/> </cell> <cell> <JButton text="coser.ui.selection.replay.finishselection" - enabled="{validSelectionButton.isEnabled()}" - onActionPerformed="getHandler().finishSelection1toFinal(this)" /> + enabled="{validSelectionButton.isEnabled()}" + onActionPerformed="getHandler().finishSelection1toFinal(this)"/> </cell> </row> </Table> - + <!-- Step 2 : Year choice --> <Table constraints='"step2"'> <row> <cell weightx="1" fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.replay.chooseyears" /> + <JLabel text="coser.ui.selection.replay.chooseyears"/> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both" columns="3"> <JScrollPane> - <YearListModel id="yearsListModel" /> + <YearListModel id="yearsListModel"/> <JList id="yearsList" model="{yearsListModel}" - selectionModel="{new CoserListSelectionModel(yearsList.getSelectionModel(), yearsListModel)}" - onValueChanged="validYearsButton.setEnabled(yearsList.getSelectedIndex() != -1)"/> + selectionModel="{new CoserListSelectionModel(yearsList.getSelectionModel(), yearsListModel)}" + onValueChanged="validYearsButton.setEnabled(yearsList.getSelectedIndex() != -1)"/> </JScrollPane> </cell> </row> <row> <cell weightx="1" fill="horizontal" columns="3"> <JTextArea id="messageArea2" rows="3" editable="false" - text='{t("coser.ui.selection.replay.noerrordetected")}' /> + text='{t("coser.ui.selection.replay.noerrordetected")}'/> </cell> </row> <row> <cell weightx="1" anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell weightx="1" anchor="east"> <JButton id="validYearsButton" text="coser.ui.selection.replay.nextstep" - enabled="false" - onActionPerformed="getHandler().validSelectionYears(this)" /> + enabled="false" + onActionPerformed="getHandler().validSelectionYears(this)"/> </cell> <cell> <JButton text="coser.ui.selection.replay.finishselection" - enabled="{validYearsButton.isEnabled()}" - onActionPerformed="getHandler().finishSelection2toFinal(this)" /> + enabled="{validYearsButton.isEnabled()}" + onActionPerformed="getHandler().finishSelection2toFinal(this)"/> </cell> </row> </Table> - + <!-- Step 3 : Strata choice --> <Table constraints='"step3"'> <row> <cell weightx="1" fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.replay.choosestrata" /> + <JLabel text="coser.ui.selection.replay.choosestrata"/> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both" columns="3"> <JScrollPane> - <StrataListModel id="strataListModel" /> + <StrataListModel id="strataListModel"/> <JList id="strataList" model="{strataListModel}" - selectionModel="{new CoserListSelectionModel(strataList.getSelectionModel(), strataListModel)}" - onValueChanged='validStrataButton.setEnabled(strataList.getSelectedIndex() != -1)'/> + selectionModel="{new CoserListSelectionModel(strataList.getSelectionModel(), strataListModel)}" + onValueChanged='validStrataButton.setEnabled(strataList.getSelectedIndex() != -1)'/> </JScrollPane> </cell> </row> <row> <cell weightx="1" fill="horizontal" columns="3"> <JTextArea id="messageArea3" rows="3" editable="false" - text='{t("coser.ui.selection.replay.noerrordetected")}' /> + text='{t("coser.ui.selection.replay.noerrordetected")}'/> </cell> </row> <row> <cell weightx="1" anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell weightx="1" anchor="east"> <JButton id="validStrataButton" text="coser.ui.selection.replay.nextstep" - enabled="false" - onActionPerformed="getHandler().validSelectionStrata(this)" /> + enabled="false" + onActionPerformed="getHandler().validSelectionStrata(this)"/> </cell> <cell> <JButton text="coser.ui.selection.replay.finishselection" - enabled="{validStrataButton.isEnabled()}" - onActionPerformed="getHandler().finishSelection3toFinal(this)" /> + enabled="{validStrataButton.isEnabled()}" + onActionPerformed="getHandler().finishSelection3toFinal(this)"/> </cell> </row> </Table> @@ -173,36 +173,36 @@ <Table constraints='"step4"'> <row> <cell weightx="1" fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.replay.commands" /> + <JLabel text="coser.ui.selection.replay.commands"/> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both" columns="3"> <JScrollPane> - <fr.ifremer.coser.ui.selection.replay.CommandListModel id="commandListModel" /> - <JList id="commandList" model="{commandListModel}" /> + <fr.ifremer.coser.ui.selection.replay.CommandListModel id="commandListModel"/> + <JList id="commandList" model="{commandListModel}"/> </JScrollPane> </cell> </row> <row> <cell weightx="1" fill="horizontal" columns="3"> <JTextArea id="messageArea4" rows="3" editable="false" - text='{t("coser.ui.selection.replay.noerrordetected")}' /> + text='{t("coser.ui.selection.replay.noerrordetected")}'/> </cell> </row> <row> <cell weightx="1" anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell weightx="1" anchor="east"> <JButton id="validCommandButton" text="coser.ui.selection.replay.nextstep" - onActionPerformed="getHandler().validSelectionCommand(this)" /> + onActionPerformed="getHandler().validSelectionCommand(this)"/> </cell> <cell> <JButton text="coser.ui.selection.replay.finishselection" - enabled="{validCommandButton.isEnabled()}" - onActionPerformed="getHandler().finishSelection4toFinal(this)" /> + enabled="{validCommandButton.isEnabled()}" + onActionPerformed="getHandler().finishSelection4toFinal(this)"/> </cell> </row> </Table> @@ -211,39 +211,39 @@ <Table constraints='"step5"'> <row> <cell weightx="1" fill="horizontal" columns="3"> - <JLabel text="coser.ui.selection.replay.choosespecies" /> + <JLabel text="coser.ui.selection.replay.choosespecies"/> </cell> </row> <row> <cell weightx="1" weighty="1" fill="both" columns="3"> <JScrollPane> - <SpeciesListModel id="selectedSpeciesListModel" /> + <SpeciesListModel id="selectedSpeciesListModel"/> <JList id="selectedSpeciesList" model="{selectedSpeciesListModel}" - selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}" - onValueChanged='validSpeciesButton.setEnabled(selectedSpeciesList.getSelectedIndex() != -1)'/> + selectionModel="{new CoserListSelectionModel(selectedSpeciesList.getSelectionModel(), selectedSpeciesListModel)}" + onValueChanged='validSpeciesButton.setEnabled(selectedSpeciesList.getSelectedIndex() != -1)'/> </JScrollPane> </cell> </row> <row> <cell weightx="1" fill="horizontal" columns="3"> <JTextArea id="messageArea5" rows="3" editable="false" - text='{t("coser.ui.selection.replay.noerrordetected")}' /> + text='{t("coser.ui.selection.replay.noerrordetected")}'/> </cell> </row> <row> <cell weightx="1" anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell weightx="1" anchor="east"> <JButton id="validSpeciesButton" text="coser.ui.selection.replay.nextstep" - enabled="false" - onActionPerformed="getHandler().validSelectionSpecies(this)" /> + enabled="false" + onActionPerformed="getHandler().validSelectionSpecies(this)"/> </cell> <cell> <JButton text="coser.ui.selection.replay.finishselection" - enabled="{validSpeciesButton.isEnabled()}" - onActionPerformed="getHandler().finishSelection5toFinal(this)" /> + enabled="{validSpeciesButton.isEnabled()}" + onActionPerformed="getHandler().finishSelection5toFinal(this)"/> </cell> </row> </Table> @@ -251,54 +251,56 @@ <!-- Step 6 : Final name & description --> <Table constraints='"step6"'> <row weightx="1" fill="horizontal" columns="2"> - <cell><JLabel text="coser.ui.selection.replay.selectioninfos" /></cell> + <cell> + <JLabel text="coser.ui.selection.replay.selectioninfos"/> + </cell> </row> <row> <cell anchor="west"> - <JLabel text="coser.ui.selection.details.name" /> + <JLabel text="coser.ui.selection.details.name"/> </cell> <cell weightx="1" fill="horizontal"> - <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}" /> + <JTextField id="detailsSelectionNameField" text="{getSelection().getName()}"/> <javax.swing.text.Document javaBean="detailsSelectionNameField.getDocument()" - onInsertUpdate='getSelection().setName(detailsSelectionNameField.getText())' - onRemoveUpdate='getSelection().setName(detailsSelectionNameField.getText())' /> + onInsertUpdate='getSelection().setName(detailsSelectionNameField.getText())' + onRemoveUpdate='getSelection().setName(detailsSelectionNameField.getText())'/> </cell> </row> <row> - <cell anchor="west"> - <JLabel text="coser.ui.selection.details.description" /> - </cell> - <cell weightx="1" fill="horizontal"> - <JScrollPane id="detailsDescriptionSP"> - <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3" /> - </JScrollPane> - <javax.swing.text.Document javaBean="detailsDescription.getDocument()" - onInsertUpdate='getSelection().setDescription(detailsDescription.getText())' - onRemoveUpdate='getSelection().setDescription(detailsDescription.getText())' /> - </cell> + <cell anchor="west"> + <JLabel text="coser.ui.selection.details.description"/> + </cell> + <cell weightx="1" fill="horizontal"> + <JScrollPane id="detailsDescriptionSP"> + <JTextArea id="detailsDescription" text="{getSelection().getDescription()}" rows="3"/> + </JScrollPane> + <javax.swing.text.Document javaBean="detailsDescription.getDocument()" + onInsertUpdate='getSelection().setDescription(detailsDescription.getText())' + onRemoveUpdate='getSelection().setDescription(detailsDescription.getText())'/> + </cell> </row> <row> - <cell anchor="northwest"> - <JLabel text="coser.ui.selection.details.comment" /> - </cell> - <cell anchor="north" fill="horizontal" weighty="1"> - <JScrollPane> - <JTextArea id="detailsComment" text="{getSelection().getComment()}" rows="3" /> - <javax.swing.text.Document javaBean="detailsComment.getDocument()" - onInsertUpdate='getSelection().setComment(detailsComment.getText())' - onRemoveUpdate='getSelection().setComment(detailsComment.getText())' /> - </JScrollPane> - </cell> + <cell anchor="northwest"> + <JLabel text="coser.ui.selection.details.comment"/> + </cell> + <cell anchor="north" fill="horizontal" weighty="1"> + <JScrollPane> + <JTextArea id="detailsComment" text="{getSelection().getComment()}" rows="3"/> + <javax.swing.text.Document javaBean="detailsComment.getDocument()" + onInsertUpdate='getSelection().setComment(detailsComment.getText())' + onRemoveUpdate='getSelection().setComment(detailsComment.getText())'/> + </JScrollPane> + </cell> </row> <row> <cell anchor="west"> <JButton text="coser.ui.common.cancel" - onActionPerformed="dispose()" /> + onActionPerformed="dispose()"/> </cell> <cell anchor="east"> <JButton id="validSelectionInfosButton" text="coser.ui.selection.details.saveSelection" - enabled="false" - onActionPerformed="getHandler().validSelectionInfos(this)" /> + enabled="false" + onActionPerformed="getHandler().validSelectionInfos(this)"/> </cell> </row> </Table> diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java index 49a38da..b126654 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListModel.java @@ -27,18 +27,14 @@ import javax.swing.ListModel; /** * Interface que doivent implementer les modeles de List de coser. * (à ne pas confondre avec les modeles de selection des List). - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public interface CoserListModel extends ListModel { /** * Return index of element. - * + * * @param element element to get index * @return index of element */ diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java index 4680880..aaf501a 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserListSelectionModel.java @@ -22,35 +22,30 @@ package fr.ifremer.coser.ui.util; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; +import jaxx.runtime.swing.OneClicListSelectionModel; import javax.swing.ListSelectionModel; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; - -import jaxx.runtime.swing.OneClicListSelectionModel; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; /** * Model de selection fonctionnant avec les intances des objects selectionnée * et non par indices. * Etend {@link OneClicListSelectionModel} pour sélectionner par simple clic. - * + * * Implemente {@link ListDataListener} pour que la selection apres changement * des données reste la même au niveau des objets (sinon, les indices * ne correspondent pas au données précédent le changement. - * + * * ATTENTION : {@link #selectedObjects} ne reflete pas la selection * de la liste. Certains de ces élements peuvent être mémorisé selectionné, * mais non présente dans le modele de la liste, donc hors selection. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserListSelectionModel extends OneClicListSelectionModel implements ListDataListener { @@ -59,10 +54,10 @@ public class CoserListSelectionModel extends OneClicListSelectionModel implement /** List model. */ protected CoserListModel coserListModel; - + /** * Constuctor. - * + * * @param delegate * @param coserListModel */ @@ -74,7 +69,7 @@ public class CoserListSelectionModel extends OneClicListSelectionModel implement /** * Replace selection. - * + * * @param objects new selected objects */ public void setSelectedObjects(Collection<?> objects) { @@ -85,8 +80,7 @@ public class CoserListSelectionModel extends OneClicListSelectionModel implement setValueIsAdjusting(true); try { contentsChanged(null); - } - finally { + } finally { setValueIsAdjusting(false); } } @@ -145,13 +139,12 @@ public class CoserListSelectionModel extends OneClicListSelectionModel implement } protected void registerSelection(int index0, int index1) { - - for (int i = index0 ; i <= index1 ; ++i) { + + for (int i = index0; i <= index1; ++i) { Object o = coserListModel.getElementAt(i); if (isSelectedIndex(i)) { selectedObjects.add(o); - } - else { + } else { selectedObjects.remove(o); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserProgressBar.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserProgressBar.java index 6ce51d9..d7794c5 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserProgressBar.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/CoserProgressBar.java @@ -22,29 +22,25 @@ package fr.ifremer.coser.ui.util; -import static org.nuiton.i18n.I18n.t; +import fr.ifremer.coser.util.ProgressMonitor; import javax.swing.JProgressBar; -import fr.ifremer.coser.util.ProgressMonitor; +import static org.nuiton.i18n.I18n.t; /** * Control progress bar. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserProgressBar extends JProgressBar implements ProgressMonitor { - /** serialVersionUID. */ + private static final long serialVersionUID = 3383288562693714316L; /** Default to 1 (= no step). */ protected int stepCount = 1; - + protected int step; /* @@ -70,7 +66,7 @@ public class CoserProgressBar extends JProgressBar implements ProgressMonitor { public void nextStep() { step++; } - + /* * @see fr.ifremer.coser.control.ProgressMonitor#setCurrent(double) */ @@ -92,7 +88,7 @@ public class CoserProgressBar extends JProgressBar implements ProgressMonitor { if (stepCount <= 1) { setString(text); } else { - setString(t("coser.ui.control.progressStep", step +1, stepCount, text)); + setString(t("coser.ui.control.progressStep", step + 1, stepCount, text)); } } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/ErrorHelper.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/ErrorHelper.java index c60d780..cda9999 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/util/ErrorHelper.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/util/ErrorHelper.java @@ -22,18 +22,7 @@ package fr.ifremer.coser.ui.util; -import static org.nuiton.i18n.I18n.t; - -import java.awt.Component; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - +import fr.ifremer.coser.CoserConfig; import fr.ifremer.coser.CoserUIApplicationContext; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -44,18 +33,23 @@ import org.jdesktop.swingx.JXErrorPane; import org.jdesktop.swingx.error.ErrorInfo; import org.jdesktop.swingx.error.ErrorReporter; -import fr.ifremer.coser.CoserConfig; +import javax.swing.JOptionPane; +import java.awt.Component; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n.t; /** * Error helper. - * + * * Used to easily switch real exception interface. Currently used : swingx. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class ErrorHelper implements ErrorReporter { @@ -70,17 +64,17 @@ public class ErrorHelper implements ErrorReporter { /** * Display a user friendly error frame. - * - * @param parent parent component + * + * @param parent parent component * @param message message for user - * @param cause exception cause + * @param cause exception cause */ public void showErrorDialog(Component parent, String message, - Throwable cause) { + Throwable cause) { JXErrorPane pane = new JXErrorPane(); ErrorInfo info = new ErrorInfo(t("coser.ui.error.title"), - t("coser.ui.error.htmlmessage", message), null, null, - cause, null, null); + t("coser.ui.error.htmlmessage", message), null, null, + cause, null, null); pane.setErrorInfo(info); pane.setErrorReporter(this); JXErrorPane.showDialog(parent, pane); @@ -88,7 +82,7 @@ public class ErrorHelper implements ErrorReporter { /** * Display a user friendly error frame. - * + * * @param message message for user */ public void showErrorDialog(String message) { @@ -97,9 +91,9 @@ public class ErrorHelper implements ErrorReporter { /** * Display a user friendly error frame. - * + * * @param message message for user - * @param cause exception cause + * @param cause exception cause */ public void showErrorDialog(String message, Throwable cause) { showErrorDialog(null, message, cause); @@ -163,11 +157,11 @@ public class ErrorHelper implements ErrorReporter { JOptionPane.showMessageDialog(null, t("coser.ui.error.reportSendTo", emailTo)); } catch (EmailException ex) { if (log.isErrorEnabled()) { - log.error("Can't send report email" ,ex); + log.error("Can't send report email", ex); } } } - + protected String formatMessage(String category, String content) { String formatted = category + " :\n"; if (StringUtils.isNotEmpty(content)) { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionLayout.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionLayout.java index e5bb4ee..3780ee7 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionLayout.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionLayout.java @@ -31,7 +31,7 @@ public class AccordionLayout implements LayoutManager { /** * Constructs a AccordionLayout. - * + * * @param accordionPane accordionPane */ public AccordionLayout(AccordionPane accordionPane) { @@ -87,7 +87,7 @@ public class AccordionLayout implements LayoutManager { .getComponent(0); // Get height of title area int remainder = totalhei - - (firstSubPanel.titlePanel.getHeight() * numPanes); + - (firstSubPanel.titlePanel.getHeight() * numPanes); accordionPane.remainder = remainder; for (int i = 0; i < n; i++) { Component c = parent.getComponent(i); @@ -99,30 +99,30 @@ public class AccordionLayout implements LayoutManager { if (subPanel.index == selInd) { int hei = titleH + accordionPane.transitionStep; c.setBounds(x, y, - pd.width - insets.left - insets.right, hei); + pd.width - insets.left - insets.right, hei); y += hei; } else if (subPanel.index == accordionPane.previouslySelected) { int hei = titleH - + (remainder - accordionPane.transitionStep); + + (remainder - accordionPane.transitionStep); c.setBounds(x, y, - pd.width - insets.left - insets.right, hei); + pd.width - insets.left - insets.right, hei); y += hei; } else { int hei = titleH; c.setBounds(x, y, - pd.width - insets.left - insets.right, hei); + pd.width - insets.left - insets.right, hei); y += hei; } } else { if (subPanel.index == selInd) { int hei = titleH + remainder; c.setBounds(x, y, - pd.width - insets.left - insets.right, hei); + pd.width - insets.left - insets.right, hei); y += hei; } else { int hei = titleH; c.setBounds(x, y, - pd.width - insets.left - insets.right, hei); + pd.width - insets.left - insets.right, hei); y += hei; } } @@ -146,11 +146,11 @@ public class AccordionLayout implements LayoutManager { @Override public void addLayoutComponent(String name, Component comp) { - + } @Override public void removeLayoutComponent(Component comp) { - + } } \ No newline at end of file diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPane.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPane.java index 61f2f33..0b4cfa3 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPane.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPane.java @@ -19,6 +19,9 @@ package fr.ifremer.coser.ui.widgets; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.Timer; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; @@ -27,16 +30,12 @@ import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.Timer; - /** * The AccordionPane class implements a vertical accordion container, similar to * those seen in many AJAX/DHTML frameworks. Multiple child panels are added, * but only one of those will be visible at a time. The user can switch between * visible panels by clicking on the title area of one of the inactive panels. - * + * * @author Craig Knudsen, craig@k5n.us */ // TODO: add/remove ChangeListener support @@ -45,18 +44,25 @@ import javax.swing.Timer; // TODO: enable/disable panels public class AccordionPane extends JPanel { - /** serialVersionUID. */ + private static final long serialVersionUID = -4266521429712806753L; - + protected List<AccordionPaneSubPanel> children; + protected int selected = -1; + protected int previouslySelected = -1; // used in animation transition + // background color for pane title protected Color paneBackgroundColor; + // background color for current pane title protected Color activePaneBackgroundColor; + protected Timer timer; + protected int transitionStep = 0; + protected int remainder = -1; /** @@ -73,11 +79,9 @@ public class AccordionPane extends JPanel { /** * Set the background color for the active and inactive pane title areas. - * - * @param normalColor - * The color to use for the non-active panels - * @param activeColor - * The color to use for the currently selected panel + * + * @param normalColor The color to use for the non-active panels + * @param activeColor The color to use for the currently selected panel */ public void setTitleBackgroundColors(Color normalColor, Color activeColor) { this.paneBackgroundColor = normalColor; @@ -98,7 +102,7 @@ public class AccordionPane extends JPanel { this.setSelected(0, false); } if (this.transitionStep >= this.remainder && this.remainder > 0 - && timer != null) { + && timer != null) { this.timer.stop(); this.timer = null; System.out.println("Killed timer."); @@ -108,9 +112,8 @@ public class AccordionPane extends JPanel { /** * Set the currently active/selected pane. - * - * @param num - * The pane number to select (0 is first) + * + * @param num The pane number to select (0 is first) */ public void setSelected(int num) { setSelected(num, false); @@ -118,20 +121,17 @@ public class AccordionPane extends JPanel { /** * Set the currently active/selected pane. - * - * @param num - * The pane number to select (0 is first) - * @param showAnimation - * Show the animation transition from the previously selected pane to - * the newly selected pane. + * + * @param num The pane number to select (0 is first) + * @param showAnimation Show the animation transition from the previously selected pane to + * the newly selected pane. */ public void setSelected(int num, boolean showAnimation) { if (num == selected) return; if (!showAnimation) { this.previouslySelected = -1; - } - else { + } else { this.previouslySelected = selected; } this.selected = num; @@ -142,10 +142,11 @@ public class AccordionPane extends JPanel { // || ( i == this.previouslySelected && showAnimation ) ); subPanel.titlePanel .setBackground(i == num ? this.activePaneBackgroundColor - : this.paneBackgroundColor); + : this.paneBackgroundColor); } if (this.previouslySelected >= 0 && showAnimation) { ActionListener a = new ActionListener() { + public void actionPerformed(ActionEvent e) { // Add another step in the animation transition if (remainder - transitionStep < 10) { @@ -187,7 +188,7 @@ public class AccordionPane extends JPanel { /** * Get the index of the currently selected pane. - * + * * @return the index of the currently selected pane */ public int getSelectedIndex() { @@ -196,7 +197,7 @@ public class AccordionPane extends JPanel { /** * Get the number of panes in the AccordionPane. - * + * * @return the number of panes */ public int getPaneCount() { @@ -205,11 +206,9 @@ public class AccordionPane extends JPanel { /** * Set the text title at the specified location - * - * @param index - * the index number of the pane - * @param newTitle - * the new title for the specified pane. + * + * @param index the index number of the pane + * @param newTitle the new title for the specified pane. */ public void setTitleAt(int index, String newTitle) { AccordionPaneSubPanel subPanel = this.children @@ -219,9 +218,8 @@ public class AccordionPane extends JPanel { /** * Get the text title at the specified location - * - * @param index - * the index number of the pane + * + * @param index the index number of the pane * @return the text title of the specified pane */ public String getTitleAt(int index) { @@ -232,7 +230,7 @@ public class AccordionPane extends JPanel { /** * Set the icon for the specified location. - * + * * @param index * @param icon */ @@ -244,9 +242,8 @@ public class AccordionPane extends JPanel { /** * Returns the component at index. - * - * @param index - * the index of the item being queried + * + * @param index the index of the item being queried * @return component */ public Component getComponentAt(int index) { @@ -257,7 +254,7 @@ public class AccordionPane extends JPanel { /** * Returns the currently selected component for this AccordionPane. - * + * * @return the currently selected component */ public Component getSelectedComponent() { diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPaneSubPanel.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPaneSubPanel.java index 3b56644..f1500d0 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPaneSubPanel.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/AccordionPaneSubPanel.java @@ -19,29 +19,33 @@ package fr.ifremer.coser.ui.widgets; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Cursor; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; - public class AccordionPaneSubPanel extends JPanel { - /** serialVersionUID. */ + private static final long serialVersionUID = 4836598811061630517L; protected AccordionPane accordionPane; protected JPanel titlePanel; + protected JLabel titleLabel; + protected JComponent child; + protected int index; + protected Cursor handCursor = null; + protected int mousePressedInd = -1; public AccordionPaneSubPanel() { @@ -90,6 +94,7 @@ public class AccordionPaneSubPanel extends JPanel { // Add mouse listener for titlePanel so we can change the cursor and also // listen for mouse click. this.titlePanel.addMouseListener(new MouseListener() { + public void mouseEntered(MouseEvent me) { } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/ComponentTitledBorder.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/ComponentTitledBorder.java index fe52e50..508c633 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/ComponentTitledBorder.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/ComponentTitledBorder.java @@ -1,12 +1,12 @@ /* %%Ignore-License * MySwing: Advanced Swing Utilites * Copyright (C) 2005 Santhosh Kumar T - * <p/> + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. - * <p/> + * * This library 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 @@ -15,6 +15,10 @@ package fr.ifremer.coser.ui.widgets; +import javax.swing.JComponent; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.border.Border; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -25,17 +29,16 @@ import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import javax.swing.JComponent; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.border.Border; - public class ComponentTitledBorder implements Border, MouseListener, SwingConstants { + protected int offset = 5; protected Component titleComponent; + protected JComponent container; + protected Rectangle rect; + protected Border border; public ComponentTitledBorder(Component titleComponent, JComponent container, Border border) { @@ -45,13 +48,13 @@ public class ComponentTitledBorder implements Border, MouseListener, SwingConsta this.border = border; container.addMouseListener(this); } - + public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics g, int x, int y, int width, - int height) { + int height) { Insets borderInsets = border.getBorderInsets(c); Insets insets = getBorderInsets(c); int temp = (insets.top - borderInsets.top) / 2; @@ -74,8 +77,8 @@ public class ComponentTitledBorder implements Border, MouseListener, SwingConsta pt.translate(-offset, 0); titleComponent.setBounds(rect); titleComponent.dispatchEvent(new MouseEvent(titleComponent, me.getID(), me.getWhen(), - me.getModifiers(), pt.x, pt.y, me.getClickCount(), me - .isPopupTrigger(), me.getButton())); + me.getModifiers(), pt.x, pt.y, me.getClickCount(), me + .isPopupTrigger(), me.getButton())); if (!titleComponent.isValid()) { container.repaint(); } diff --git a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/LookAndFeelViewMenuItem.java b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/LookAndFeelViewMenuItem.java index 891dea8..4be2d19 100644 --- a/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/LookAndFeelViewMenuItem.java +++ b/coser-ui/src/main/java/fr/ifremer/coser/ui/widgets/LookAndFeelViewMenuItem.java @@ -22,34 +22,29 @@ package fr.ifremer.coser.ui.widgets; -import java.awt.Frame; -import java.awt.Window; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - import javax.swing.ButtonGroup; import javax.swing.JMenu; import javax.swing.JRadioButtonMenuItem; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import java.awt.Frame; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Look and feel {@link JMenu}. - * + * * External listener can listen for {@link #PROPERTY_LOOK_AND_FEEL} property * modification. - * + * * Code copied form SwingSet3. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class LookAndFeelViewMenuItem extends JMenu implements ActionListener { - /** serialVersionUID. */ + private static final long serialVersionUID = 2462162272156484217L; public static final String PROPERTY_LOOK_AND_FEEL = "lookAndFeel"; @@ -99,7 +94,7 @@ public class LookAndFeelViewMenuItem extends JMenu implements ActionListener { protected void updateLookAndFeel() { Window windows[] = Frame.getWindows(); - for(Window window : windows) { + for (Window window : windows) { SwingUtilities.updateComponentTreeUI(window); } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/CoserApplicationListener.java b/coser-web/src/main/java/fr/ifremer/coser/web/CoserApplicationListener.java index cb38bca..07967a7 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/CoserApplicationListener.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/CoserApplicationListener.java @@ -33,12 +33,12 @@ import java.util.Map; /** * To listen start and end of the application. - * <p/> + * * On start we will init the application context ({@link CoserWebApplicationContext#init()}). - * <p/> + * * On stop, just release close the application context ({@link CoserWebApplicationContext#close()}). * - * @author tchemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserApplicationListener implements ServletContextListener { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebApplicationContext.java b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebApplicationContext.java index ef658fb..e947b0b 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebApplicationContext.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebApplicationContext.java @@ -29,7 +29,7 @@ import org.nuiton.i18n.init.DefaultI18nInitializer; /** * Created on 3/11/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserWebApplicationContext extends DefaultCoserApplicationContext { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java index 75d87c2..267f05c 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfig.java @@ -31,10 +31,6 @@ import static org.nuiton.i18n.I18n.n; * Coser web configuration. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class CoserWebConfig extends CoserBusinessConfig { @@ -109,7 +105,7 @@ public class CoserWebConfig extends CoserBusinessConfig { private final Class<?> type; - private CoserWebOption(String key, String description, Class<?> type, String defaultValue) { + CoserWebOption(String key, String description, Class<?> type, String defaultValue) { this.key = key; this.description = description; this.defaultValue = defaultValue; diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfigProvider.java b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfigProvider.java index cfaae83..e71efb3 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfigProvider.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConfigProvider.java @@ -35,7 +35,7 @@ import static org.nuiton.i18n.I18n.l; /** * To generate configuration report. * - * @author tchemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class CoserWebConfigProvider implements ApplicationConfigProvider { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebException.java b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebException.java index 8452162..7b2848c 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebException.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebException.java @@ -25,21 +25,17 @@ import fr.ifremer.coser.CoserTechnicalException; /** * Coser web runtime exception. - * + * * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class CoserWebException extends CoserTechnicalException { - /** serialVersionUID. */ + private static final long serialVersionUID = -1002725698959514244L; /** * Constructs a new exception with the specified detail message. - * + * * @param message the detail message */ public CoserWebException(String message) { @@ -47,10 +43,10 @@ public class CoserWebException extends CoserTechnicalException { } /** - * Constructs a new exception with the specified detail message and cause. - * + * Constructs a new exception with the specified detail message and cause. + * * @param message the detail message - * @param cause the cause + * @param cause the cause */ public CoserWebException(String message, Throwable cause) { super(message, cause); diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/ServiceHelper.java b/coser-web/src/main/java/fr/ifremer/coser/web/ServiceHelper.java index 7fdf352..6f8dd5d 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/ServiceHelper.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/ServiceHelper.java @@ -44,10 +44,10 @@ import java.util.Set; /** * Wrap any call to business layer. - * <p/> + * * Created on 3/6/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ //TODO Inject this in action diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/DocumentsAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/DocumentsAction.java index 74b87a4..7c2b26f 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/DocumentsAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/DocumentsAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; * Documents action. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class DocumentsAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java index f56a92a..ae059e9 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java @@ -31,14 +31,9 @@ import java.util.Date; * Action index, recupere la date de derniere mise à jour. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class IndexAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; protected Date dataUpdateDate; @@ -68,21 +63,8 @@ public class IndexAction extends AbstractCoserJspAction { public String execute() { dataUpdateDate = getService().getConfig().getLastDataUpdateDate(); - return SUCCESS; + } - // @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// -// try { -// dataUpdateDate = webService.getLastDataUpdateDate(); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get last update date", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/LocaleAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/LocaleAction.java index d42f219..36f1867 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/LocaleAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/LocaleAction.java @@ -29,14 +29,9 @@ import org.apache.struts2.convention.annotation.Result; * Action index, recupere la liste des resultats. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class LocaleAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; @Override diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/QualityAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/QualityAction.java index 753c1f8..cfb8ac2 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/QualityAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/QualityAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; * Quality action. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class QualityAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/SurveyAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/SurveyAction.java index 4e52b5a..92d39cc 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/SurveyAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/SurveyAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; * Survey description action. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SurveyAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = -7450643911834502103L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java index 2caf42d..0b2f4f5 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java @@ -33,18 +33,14 @@ import java.io.File; /** * Upload results action. - * <p/> + * * Cette action est appelée par l'interface swing cliente. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class UploadResultAction extends AbstractCoserJspAction { - /** serialVersionUID. */ + private static final long serialVersionUID = 3887268253160622587L; private static final Log log = LogFactory.getLog(UploadResultAction.class); @@ -117,7 +113,7 @@ public class UploadResultAction extends AbstractCoserJspAction { /** * Check if sha1 password equals to config password. - * <p/> + * * Config password can be plain or sha1 encoded. * * @param config config diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/DeleteProjectsAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/DeleteProjectsAction.java index b4d59ae..ebd7d61 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/DeleteProjectsAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/DeleteProjectsAction.java @@ -32,18 +32,13 @@ import java.util.List; /** * Project list action. - * <p/> - * Last update : $Date$ - * By : $Author$ * * @author chatellier - * @version $Revision$ */ @Result(type = "redirect", location = "list-projects", params = {"selectedRepositoryType", "${repositoryType}"}) public class DeleteProjectsAction extends AbstractCoserAction { - /** serialVersionUID. */ - private static final long serialVersionUID = 6024588562104111883L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(DeleteProjectsAction.class); @@ -99,48 +94,4 @@ public class DeleteProjectsAction extends AbstractCoserAction { return repositoryType; } - // /** -// * Contient les identifiants des zones dont on souhaite supprimer le -// * resultat conrespondant dans le stockage indicateur. -// */ -// protected List<String> indicatorsZonesId; -// -// /** -// * Contient les identifiants des zones dont on souhaites supprimer le -// * resultat conrespondant dans le stockage cartes. -// */ -// protected List<String> mapsZonesId; -// -// public void setIndicatorsZonesId(List<String> indicatorsZonesId) { -// this.indicatorsZonesId = indicatorsZonesId; -// } -// -// public void setMapsZonesId(List<String> mapsZonesId) { -// this.mapsZonesId = mapsZonesId; -// } -// -// public String execute() { -// WebService webService = ServiceFactory.getWebService(); -// -// try { -// if (log.isDebugEnabled()) { -// log.debug("Delete indicators zone : " + indicatorsZonesId); -// } -// if (CollectionUtils.isNotEmpty(indicatorsZonesId)) { -// webService.deleteIndicatorsResult(indicatorsZonesId); -// } -// -// if (log.isDebugEnabled()) { -// log.debug("Delete maps zone : " + mapsZonesId); -// } -// if (CollectionUtils.isNotEmpty(mapsZonesId)) { -// webService.deleteMapsResult(mapsZonesId); -// } -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get data from web service", ex); -// } -// -// return SUCCESS; -// } - } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/IndexAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/IndexAction.java index c42fc88..8c79983 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/IndexAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/IndexAction.java @@ -26,15 +26,10 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserAction; /** * Admin index action. * - * Last update : $Date$ - * By : $Author$ - * * @author chatellier - * @version $Revision$ */ public class IndexAction extends AbstractCoserAction { - /** serialVersionUID. */ - private static final long serialVersionUID = 6024588562104111883L; + private static final long serialVersionUID = 1L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ListProjectsAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ListProjectsAction.java index 640b7b7..78ed4b1 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ListProjectsAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ListProjectsAction.java @@ -37,16 +37,11 @@ import java.util.Set; /** * Project list action. * - * Last update : $Date$ - * By : $Author$ - * * @author chatellier - * @version $Revision$ */ public class ListProjectsAction extends AbstractCoserAction { - /** serialVersionUID. */ - private static final long serialVersionUID = 6024588562104111883L; + private static final long serialVersionUID = 1L; // All types of result repository protected Map<String, ResultRepositoryType> repositoryTypes; @@ -60,10 +55,6 @@ public class ListProjectsAction extends AbstractCoserAction { protected Map<ResultType, Map<String, String>> results; - protected Map<String, String> indicatorsResults; - - protected Map<String, String> mapsResults; - public Map<String, ResultRepositoryType> getRepositoryTypes() { return repositoryTypes; } @@ -130,37 +121,4 @@ public class ListProjectsAction extends AbstractCoserAction { return SUCCESS; } -// public Map<String, String> getIndicatorsResults() { -// return indicatorsResults; -// } -// -// public Map<String, String> getMapsResults() { -// return mapsResults; -// } -// -// public String getZoneDisplayName(String zoneId) { -// WebService webService = ServiceFactory.getWebService(); -// String zoneDisplayName = null; -// try { -// zoneDisplayName = webService.getZoneFullName(zoneId); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone name", ex); -// } -// return zoneDisplayName; -// } -// -// public String execute() { -// WebService webService = ServiceFactory.getWebService(); -// -// try { -// facades = webService.getFacades(); -// zonesByFacades = webService.getZoneByFacade(); -// indicatorsResults = webService.getIndicatorsResultsPerZone(); -// mapsResults = webService.getMapsResultsPerZone(); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get data from web service", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ReloadProjectsAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ReloadProjectsAction.java index de9426b..50fde01 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ReloadProjectsAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/ReloadProjectsAction.java @@ -26,13 +26,8 @@ import org.apache.struts2.convention.annotation.Result; /** * To reload all projects from disk configuration. - * <p/> - * Created on 3/12/14. - * <p/> - * Last update : $Date$ - * By : $Author$ * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ @Result(type = "redirect", location = "list-projects") diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/package-info.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/package-info.java index b268656..0fb29d3 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/package-info.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/admin/package-info.java @@ -1,8 +1,7 @@ /** * Pakage for admin actions (need to be loggued in). */ -@ParentPackage("admin") -package fr.ifremer.coser.web.actions.admin; +@ParentPackage("admin") package fr.ifremer.coser.web.actions.admin; /* * #%L diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginAction.java index f3aa1aa..1f38ec6 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginAction.java @@ -25,12 +25,8 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserAction; /** * Login action. - * <p/> - * Last update : $Date$ - * By : $Author$ * * @author chatellier - * @version $Revision$ */ public class LoginAction extends AbstractCoserAction { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginInterceptor.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginInterceptor.java index bc5d949..1d18e34 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginInterceptor.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LoginInterceptor.java @@ -29,12 +29,8 @@ import java.util.Map; /** * Authentication interceptor. - * <p/> - * Last update : $Date$ - * By : $Author$ * * @author chatellier - * @version $Revision$ */ public class LoginInterceptor extends AbstractInterceptor { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LogoutAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LogoutAction.java index 6730c4f..58953ad 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LogoutAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/LogoutAction.java @@ -31,12 +31,8 @@ import java.util.Map; /** * Logout action. - * <p/> - * Last update : $Date$ - * By : $Author$ * - * @author tchemit - * @version $Revision$ + * @author tony chemit - chemit@codelutin.com */ @Result(type = "redirect", location = "/index") public class LogoutAction extends AbstractCoserAction implements SessionAware { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/PerformLoginAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/PerformLoginAction.java index 3de8dcb..ff78db7 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/PerformLoginAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/auth/PerformLoginAction.java @@ -33,12 +33,8 @@ import java.util.Map; /** * Perform login action. - * <p/> - * Last update : $Date$ - * By : $Author$ * * @author chatellier - * @version $Revision$ */ @Result(type = "redirect", location = "/admin/index") public class PerformLoginAction extends AbstractCoserAction implements SessionAware { @@ -73,7 +69,7 @@ public class PerformLoginAction extends AbstractCoserAction implements SessionAw String result; if (config.getAdminLogin().equals(login) && equalsSHA1Password(config, password)) { if (log.isInfoEnabled()) { - log.info("Successfull login: "+login); + log.info("Successfull login: " + login); } session.put(LoginInterceptor.SESSION_PARAMETER_LOGIN, login); @@ -87,7 +83,7 @@ public class PerformLoginAction extends AbstractCoserAction implements SessionAw /** * Check if sha1 password equals to config password. - * <p/> + * * Config password can be plain or sha1 encoded. * * @param config config diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/FacadeAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/FacadeAction.java index 6eed742..ab07b9d 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/FacadeAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/FacadeAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.CommonFacade; * Action index, affiche la liste des facades majeures. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class FacadeAction extends CommonFacade { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java index 51c69bb..cfe4d73 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java @@ -30,18 +30,13 @@ import java.util.Map; /** * Affiche le graphique demandé. - * <p/> + * * Parametre : zone, species, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -125,53 +120,4 @@ public class GraphAction extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facade display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, false).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// public String getIndicatorDisplayName() { -// -// Locale locale = getLocale(); -// -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getIndicators(zone, null, locale).get(indicator); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// -// @Override -// public String execute() { -// -// Locale locale = getLocale(); -// -// WebService webService = ServiceFactory.getWebService(); -// try { -// lists = webService.getIndicatorLists(zone, indicator, locale); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get indicator's list names", ex); -// } -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java index 9344625..1e4437c 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java @@ -21,9 +21,9 @@ package fr.ifremer.coser.web.actions.com; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetCommunityIndicatorResultGraphRequest; import fr.ifremer.coser.result.request.GetSpeciesListForCommunityIndicatorResultRequest; +import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -35,18 +35,13 @@ import java.util.Map; /** * Affiche le graphique demandé. - * <p/> + * * Parametre : zone, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphDataAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -126,21 +121,4 @@ public class GraphDataAction extends AbstractCoserJspAction { return input; } -// public InputStream getInputStream() { -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// InputStream input = null; -// try { -// File mapImage = webService.getChart(zone, null, indicator, list, locale); -// input = new FileInputStream(mapImage); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get map file", ex); -// } catch (FileNotFoundException ex) { -// throw new CoserWebException("Can't get map file", ex); -// } -// -// return input; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDownloadAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDownloadAction.java index 0e9ea6b..8fea0b9 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDownloadAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDownloadAction.java @@ -21,9 +21,9 @@ package fr.ifremer.coser.web.actions.com; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetCommunityIndicatorResultDataRequest; import fr.ifremer.coser.result.request.GetSpeciesListForCommunityIndicatorResultRequest; +import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -35,18 +35,13 @@ import java.util.Map; /** * Télécharge les données qui ont servi a généré le graph au format CSV. - * <p/> + * * Parametre : zone, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphDownloadAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -131,22 +126,4 @@ public class GraphDownloadAction extends AbstractCoserJspAction { return input; } -// public InputStream getInputStream() { -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// InputStream input = null; -// try { -// File mapImage = webService.getChartData(zone, null, indicator, list, locale); -// input = new FileInputStream(mapImage); -// } catch (Exception ex) { -// if (log.isErrorEnabled()) { -// log.error("Can't get file data", ex); -// } -// throw new CoserWebException("Can't get map file", ex); -// } -// -// return input; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java index d09e820..193511e 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java @@ -29,14 +29,9 @@ import fr.ifremer.coser.web.actions.common.CommonIndicator; * Action index, recupere la liste des indicateurs. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class IndicatorAction extends CommonIndicator { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; @Override diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java index fb2cb2a..1446e90 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java @@ -28,14 +28,9 @@ import fr.ifremer.coser.web.actions.common.CommonZone; * Affiche la liste des sous zones (zone). * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class ZoneAction extends CommonZone { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; @Override diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserAction.java index b848f4b..5ee5d5f 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserAction.java @@ -30,7 +30,7 @@ import java.util.Locale; /** * Created on 3/21/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public abstract class AbstractCoserAction extends BaseAction { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserJspAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserJspAction.java index 6272c54..268c23b 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserJspAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/AbstractCoserJspAction.java @@ -29,14 +29,9 @@ import fr.ifremer.coser.web.CoserWebConfig; * être presentes sur toutes les pages. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public abstract class AbstractCoserJspAction extends AbstractCoserAction { - /** serialVersionUID. */ private static final long serialVersionUID = 311574866032741326L; /** @@ -44,6 +39,7 @@ public abstract class AbstractCoserJspAction extends AbstractCoserAction { * * @return admin email */ + @SuppressWarnings("unused") public String getAdminEmail() { CoserWebConfig config = getService().getConfig(); String email = config.getAdminEmail(); @@ -55,6 +51,7 @@ public abstract class AbstractCoserJspAction extends AbstractCoserAction { * * @return admin email */ + @SuppressWarnings("unused") public String getApplicationVersion() { CoserWebConfig config = getService().getConfig(); String email = config.getApplicationVersion(); @@ -66,6 +63,7 @@ public abstract class AbstractCoserJspAction extends AbstractCoserAction { * * @return analytics id */ + @SuppressWarnings("unused") public String getAnalyticsId() { CoserWebConfig config = getService().getConfig(); String id = config.getAnalyticsId(); diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonFacade.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonFacade.java index cb16b23..52f5d81 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonFacade.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonFacade.java @@ -27,14 +27,9 @@ import java.util.Map; * Facade list action. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public abstract class CommonFacade extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected Map<String, String> facades; @@ -50,18 +45,4 @@ public abstract class CommonFacade extends AbstractCoserJspAction { return SUCCESS; } -// @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// try { -// // renvoi la liste des facadeid et leur label associé -// facades = webService.getFacades(); -// -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facades", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonIndicator.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonIndicator.java index 5a1f6f3..7229760 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonIndicator.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonIndicator.java @@ -30,14 +30,10 @@ import java.util.Map; * être null dans le cas des communautés). * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public abstract class CommonIndicator extends AbstractCoserJspAction { - /** serialVersionUID. */ + private static final long serialVersionUID = 1663244944108703571L; protected String facade; @@ -78,6 +74,7 @@ public abstract class CommonIndicator extends AbstractCoserJspAction { return indicators; } + @SuppressWarnings("unused") public String getZonePicture() { return zonePicture; } @@ -101,57 +98,4 @@ public abstract class CommonIndicator extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facade display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, false).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// public String getSpeciesDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getSpecies(zone, false).get(species); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// @Override -// public String execute() { -// -// if (log.isInfoEnabled()) { -// log.info(String.format("Looking for indicator for zone %s and species %s", zone, species)); -// } -// -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// try { -// indicators = webService.getIndicators(zone, species, locale); -// -// zonePicture = webService.getZonePictures().get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get indicators", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonZone.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonZone.java index 8026ef3..e64810b 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonZone.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/common/CommonZone.java @@ -30,14 +30,9 @@ import java.util.Map; * et commentaires associés. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public abstract class CommonZone extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -49,7 +44,6 @@ public abstract class CommonZone extends AbstractCoserJspAction { protected Map<String, String> zonesMetaInfo; /** - * * @return the request to get zones */ protected abstract CoserRequest createZonesRequest(); @@ -89,33 +83,4 @@ public abstract class CommonZone extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// -// @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// try { -// // renvoi la liste des id subzone-survey et leurs label associé -// zones = webService.getZoneForFacade(facade, false, false); -// zonesPictures = webService.getZonePictures(); -// zonesMetaInfo = webService.getZoneMetaInfo(locale); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone map", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/AbstractCoserJsonAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/AbstractCoserJsonAction.java index 537b694..019afcd 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/AbstractCoserJsonAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/AbstractCoserJsonAction.java @@ -27,12 +27,12 @@ import org.apache.struts2.convention.annotation.Results; /** * Json abstract action. - * <p/> + * * Just define in your implementation the getter to expose. - * <p/> + * * Created on 3/21/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ @ParentPackage("json-default") diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetFacadesAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetFacadesAction.java index 74a16f0..9b2c9cd 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetFacadesAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetFacadesAction.java @@ -25,10 +25,10 @@ import java.util.Map; /** * Get universe of facades. - * <p/> + * * Created on 3/21/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetFacadesAction extends AbstractCoserJsonAction { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetIndicatorsAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetIndicatorsAction.java index eb64b0e..a88db76 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetIndicatorsAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetIndicatorsAction.java @@ -25,10 +25,10 @@ import java.util.Set; /** * Get all indicator ids. - * <p/> + * * Created on 3/21/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetIndicatorsAction extends AbstractCoserJsonAction { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetZonesForFacadeAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetZonesForFacadeAction.java index 9c197d3..db1d510 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetZonesForFacadeAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/json/GetZonesForFacadeAction.java @@ -25,10 +25,10 @@ import java.util.Map; /** * Get all zones for a given facade. - * <p/> + * * Created on 3/21/14. * - * @author Tony Chemit <chemit@codelutin.com> + * @author Tony Chemit - chemit@codelutin.com * @since 1.5 */ public class GetZonesForFacadeAction extends AbstractCoserJsonAction { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/FacadeAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/FacadeAction.java index 94cc1f1..4df0d55 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/FacadeAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/FacadeAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.CommonFacade; * Action index, affiche la liste des facades majeures. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class FacadeAction extends CommonFacade { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java index 35be947..67dabfb 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java @@ -32,14 +32,9 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; * Action index, recupere la liste des resultats. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class MapAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; protected String facade; @@ -116,36 +111,4 @@ public class MapAction extends AbstractCoserJspAction { return matchingrepositoryType; } - // public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) {sm -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, true).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// public String getSpeciesDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getSpecies(zone, true).get(species); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java index 3a2b3f9..cc50dbc 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java @@ -21,8 +21,8 @@ package fr.ifremer.coser.web.actions.map; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetMapResultRequest; +import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,17 +35,12 @@ import java.io.InputStream; * Appelé par le navigateur pour récuperer le contenu de l'image. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class MapDataAction extends AbstractCoserJspAction { /** Logger. */ private static final Log log = LogFactory.getLog(MapDataAction.class); - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; protected String facade; @@ -80,7 +75,6 @@ public class MapDataAction extends AbstractCoserJspAction { return result.getSource(); } - // @Action(results = {@Result(type = "stream", params = {"contentType", "image/png", "inputName", "inputStream"})}) @Action(results = {@Result(type = "stream", params = {"contentType", "image/png"})}) public String execute() { // work with null species (get Repartition-stations map) @@ -102,17 +96,4 @@ public class MapDataAction extends AbstractCoserJspAction { return input; } -// InputStream input = null; -// try { -// // work with null species (get Repartition-stations map) -// File mapImage = webService.getMapFile(zone, species); -// input = new FileInputStream(mapImage); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get map file", ex); -// } catch (FileNotFoundException ex) { -// throw new CoserWebException("Can't get map file", ex); -// } -// -// return input; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java index 15c41bc..9f23629 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java @@ -33,14 +33,9 @@ import java.util.Map; * Recupere la liste des especes correspondant a une campagne. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SpeciesAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; private static final Log log = LogFactory.getLog(SpeciesAction.class); @@ -105,47 +100,4 @@ public class SpeciesAction extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, true).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// @Override -// public String execute() { -// -// if (log.isInfoEnabled()) { -// log.info("Looking for species for zone " + zone); -// } -// -// WebService webService = ServiceFactory.getWebService(); -// -// try { -// species = webService.getSpecies(zone, true); -// -// if (log.isDebugEnabled()) { -// log.debug("Species are : " + species); -// } -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone species", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java index 656d2cf..e82c2d2 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java @@ -28,14 +28,9 @@ import fr.ifremer.coser.web.actions.common.CommonZone; * Affiche la liste des sous zones (zone). * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class ZoneAction extends CommonZone { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; @Override @@ -47,22 +42,4 @@ public class ZoneAction extends CommonZone { return request; } -// @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// try { -// // renvoi la liste des id subzone-survey et leurs label associé -// zones = webService.getZoneForFacade(facade, false, true); -// zonesPictures = webService.getZonePictures(); -// zonesMetaInfo = webService.getZoneMetaInfo(locale); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone map", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/FacadeAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/FacadeAction.java index 23f279a..cfbaf1a 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/FacadeAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/FacadeAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.CommonFacade; * Action index, affiche la liste des facades majeures. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class FacadeAction extends CommonFacade { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java index 970d46a..519cddb 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java @@ -28,18 +28,13 @@ import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; /** * Affiche le graphique demandé. - * <p/> + * * Parametre : zone, species, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -113,50 +108,4 @@ public class GraphAction extends AbstractCoserJspAction { return getService().getIndicatorDisplayName(request, indicator); } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facade display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, false).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// public String getSpeciesDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getSpecies(zone, false).get(species); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } -// -// public String getIndicatorDisplayName() { -// -// Locale locale = getLocale(); -// -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getIndicators(zone, species, locale).get(indicator); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get species display name", ex); -// } -// return displayName; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java index e2ce5ec..bbadc3d 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java @@ -21,8 +21,8 @@ package fr.ifremer.coser.web.actions.pop; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetPopulationIndicatorResultGraphRequest; +import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Result; @@ -31,18 +31,13 @@ import java.io.InputStream; /** * Affiche le graphique demandé. - * <p/> + * * Parametre : zone, species, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphDataAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -53,8 +48,6 @@ public class GraphDataAction extends AbstractCoserJspAction { protected String indicator; - protected String chartUrl; - protected FileResult result; public void setFacade(String facade) { diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDownloadAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDownloadAction.java index 7085e50..3710df5 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDownloadAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDownloadAction.java @@ -21,8 +21,8 @@ package fr.ifremer.coser.web.actions.pop; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.GetPopulationIndicatorResultDataRequest; +import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Result; @@ -31,18 +31,13 @@ import java.io.InputStream; /** * Télécharge les données qui ont servi a généré le graph au format CSV. - * <p/> + * * Parametre : zone, species, indicator. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class GraphDownloadAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java index 8b962e4..29a7d20 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java @@ -31,14 +31,9 @@ import fr.ifremer.coser.web.actions.common.CommonIndicator; * Action index, recupere la liste des resultats. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class IndicatorAction extends CommonIndicator { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; protected String species; diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java index 4e0dd5c..ebdea97 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java @@ -33,14 +33,9 @@ import java.util.Map; * Action index, recupere la liste des resultats. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SpeciesAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 1663244944108703571L; private static final Log log = LogFactory.getLog(SpeciesAction.class); @@ -112,49 +107,4 @@ public class SpeciesAction extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facade display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, false).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// @Override -// public String execute() { -// -// if (log.isInfoEnabled()) { -// log.info("Looking for species for zone " + zone); -// } -// -// WebService webService = ServiceFactory.getWebService(); -// -// try { -// species = webService.getSpecies(zone, false); -// -// zonePicture = webService.getZonePictures().get(zone); -// -// if (log.isDebugEnabled()) { -// log.debug("Species are : " + species); -// } -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone species", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java index 7c454d0..71f59d0 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java @@ -28,14 +28,9 @@ import fr.ifremer.coser.web.actions.common.CommonZone; * Affiche la liste des sous zones (zone). * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class ZoneAction extends CommonZone { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; @Override diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/search/ExtractAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/search/ExtractAction.java index 61fb4fa..cbe61f7 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/search/ExtractAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/search/ExtractAction.java @@ -58,7 +58,6 @@ import java.util.Map; }) public class ExtractAction extends AbstractCoserJspAction implements ServletRequestAware { - /** serialVersionUID. */ private static final long serialVersionUID = 8497086194191374797L; public static final String DOWNLOAD = "download"; diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java index 7436143..8fdb6bd 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/FacadeAction.java @@ -27,14 +27,9 @@ import fr.ifremer.coser.web.actions.common.CommonFacade; * Action index, affiche la liste des facades majeures. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class FacadeAction extends CommonFacade { - /** serialVersionUID. */ private static final long serialVersionUID = 4252429273272803414L; } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java index 8307bdf..d64bd5a 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceAction.java @@ -30,14 +30,9 @@ import java.util.Map; * Affiche les liens de téléchargement du zip pour le projet choisit. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SourceAction extends AbstractCoserJspAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected String facade; @@ -86,41 +81,4 @@ public class SourceAction extends AbstractCoserJspAction { return SUCCESS; } -// public String getFacadeDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -//// displayName = webService.getFacades().get(facade); -// displayName = webService.getZoneMap().getFacades().get(facade); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get facade display name", ex); -// } -// return displayName; -// } -// -// public String getZoneDisplayName() { -// WebService webService = ServiceFactory.getWebService(); -// String displayName = null; -// try { -// displayName = webService.getZoneForFacade(facade, false, false).get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone display name", ex); -// } -// return displayName; -// } -// -// @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// -// try { -//// zonePicture = webService.getZonePictures().get(zone); -// zonePicture = webService.getZoneMap().getZonePictures().get(zone); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone picture", ex); -// } -// -// return SUCCESS; -// } } diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java index ef34f07..a288ace 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceDataAction.java @@ -21,8 +21,8 @@ package fr.ifremer.coser.web.actions.source; -import fr.ifremer.coser.result.result.FileResult; import fr.ifremer.coser.result.request.ExtractRawDataRequest; +import fr.ifremer.coser.result.result.FileResult; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Result; @@ -32,14 +32,9 @@ import java.io.InputStream; * Force le téléchargement du zip. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SourceDataAction extends SourceAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; protected boolean accepted; diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceQualityAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceQualityAction.java index ca6cd87..231cbb1 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceQualityAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/SourceQualityAction.java @@ -25,14 +25,9 @@ package fr.ifremer.coser.web.actions.source; * Affiche l'avertissement qualité avant le téléchargement du zip. * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class SourceQualityAction extends SourceAction { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; @Override diff --git a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java index 041930b..b91b414 100644 --- a/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java +++ b/coser-web/src/main/java/fr/ifremer/coser/web/actions/source/ZoneAction.java @@ -28,14 +28,9 @@ import fr.ifremer.coser.web.actions.common.CommonZone; * Affiche la liste des sous zones (zone). * * @author chatellier - * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class ZoneAction extends CommonZone { - /** serialVersionUID. */ private static final long serialVersionUID = 3385467755357775199L; @Override @@ -47,22 +42,4 @@ public class ZoneAction extends CommonZone { return request; } -// @Override -// public String execute() { -// -// WebService webService = ServiceFactory.getWebService(); -// -// Locale locale = getLocale(); -// -// try { -// // renvoi la liste des id subzone-survey et leurs label associé -// zones = webService.getZoneForFacade(facade, true, false); -// zonesPictures = webService.getZonePictures(); -// zonesMetaInfo = webService.getZoneMetaInfo(locale); -// } catch (CoserBusinessException ex) { -// throw new CoserWebException("Can't get zone map", ex); -// } -// -// return SUCCESS; -// } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.