branch develop updated (bf0a1c4 -> e4c7528)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git from bf0a1c4 optimize dependencies new 853fe15 No more create validation context on service validation new 1f8ea21 Use lambda \o/ new e538764 Update libraries to none snapshot + up codelutinpom to 10.2 new a733157 Improve code new b3c4333 fix test build new c36671c Introduction nouveau module pour les migrations new 01d87d9 Meilleur découpage de la migration new e4c7528 Revue du code relatif au gps et suppression du code en double (entités vs service model) The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit e4c75280980321b0a9e7981cc4fe7bf9f95ac828 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 17:15:45 2016 +0200 Revue du code relatif au gps et suppression du code en double (entités vs service model) commit 01d87d9d4d71cf4ae7fd052dbe2d52ad71cae029 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 16:39:23 2016 +0200 Meilleur découpage de la migration commit c36671cd436724e2ab007ae34613c97a45a13658 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 15:33:26 2016 +0200 Introduction nouveau module pour les migrations commit b3c43334618e8226ab22502d9560f734d80db396 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 14:23:23 2016 +0200 fix test build commit a7331576566ba504f99692cba31deae4f1f44743 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 13:52:13 2016 +0200 Improve code commit e538764c98a8998b645cd2897820579d72e8b165 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 13:51:51 2016 +0200 Update libraries to none snapshot + up codelutinpom to 10.2 commit 1f8ea21506c2895fbc618b28f3846ccdc2043542 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 10:31:33 2016 +0200 Use lambda \o/ commit 853fe15975d3dfdc8934305abbf8e724097ca2e5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 10:31:17 2016 +0200 No more create validation context on service validation Summary of changes: .../swing/decoration/DecoratorService.java | 6 +- .../AbstractSpeciesFieldDtoValidator.java | 4 +- .../ActivitySimpleSpeedDtoValidator.java | 9 +- .../validators/ActivitySpeedDtoValidator.java | 9 +- .../validation/BeanValidatorDetectorTest.java | 2 +- .../main/java/fr/ird/observe/ObserveAdminCLI.java | 2 +- .../main/java/fr/ird/observe/ObserveCLAction.java | 12 +- .../fr/ird/observe/ObserveResourceManager.java | 2 +- .../main/java/fr/ird/observe/ObserveRunner.java | 6 +- .../observe/ObserveSwingApplicationContext.java | 9 +- .../ObserveSwingApplicationConfig.java | 4 +- .../ObserveSwingApplicationConfigOption.java | 11 +- .../fr/ird/observe/db/ObserveSwingDataSource.java | 4 +- .../observe/entities/tripMap/TripMapPointType.java | 2 +- .../fr/ird/observe/ui/ObserveMainUIHandler.java | 44 +- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 16 +- .../observe/ui/actions/ChangeDbLanguageAction.java | 4 +- .../fr/ird/observe/ui/actions/ShowAboutAction.java | 13 +- .../ird/observe/ui/actions/ShowConfigAction.java | 8 +- .../observe/ui/actions/StopH2WebServerAction.java | 1 - .../observe/ui/actions/StopServerModeAction.java | 1 - .../ui/actions/shared/CancelCreateUIAction.java | 26 +- .../ui/actions/shared/CloseAndCreateUIAction.java | 128 +++-- .../ui/actions/shared/CloseOpenUIAction.java | 146 +++--- .../ui/actions/shared/DeleteDataUIAction.java | 33 +- .../ui/actions/shared/DeleteReferenceUIAction.java | 29 +- .../observe/ui/actions/shared/GoDownUIAction.java | 22 +- .../observe/ui/actions/shared/GoUpUIAction.java | 20 +- .../shared/MoveActivityLonglinesUIAction.java | 62 ++- .../actions/shared/MoveActivitySeinesUIAction.java | 60 ++- .../ui/actions/shared/MoveRoutesUIAction.java | 62 ++- .../ui/actions/shared/MoveTripsUIAction.java | 56 +-- .../observe/ui/actions/shared/ReOpenUIAction.java | 58 +-- .../ui/actions/shared/ResetEditUIAction.java | 23 +- .../ui/actions/shared/SaveEditUIAction.java | 23 +- .../fr/ird/observe/ui/admin/AdminActionWorker.java | 2 +- .../fr/ird/observe/ui/admin/AdminUILauncher.java | 7 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 246 ++++----- .../ui/admin/consolidate/ConsolidateUIHandler.java | 37 +- .../ui/admin/export/TripToExportTableModel.java | 2 +- .../ird/observe/ui/admin/report/ReportModel.java | 2 +- .../observe/ui/admin/report/ReportUIHandler.java | 130 ++--- .../observe/ui/admin/save/SaveLocalUIHandler.java | 2 +- .../validate/ValidateEntityListCellRenderer.java | 7 +- .../ui/admin/validate/ValidateUIHandler.java | 102 ++-- .../validate/ValidationMessageTableModel.java | 5 +- .../java/fr/ird/observe/ui/content/ContentUI.jaxx | 6 +- .../ird/observe/ui/content/ContentUIHandler.java | 27 +- .../observe/ui/content/ContentUIInitializer.java | 15 +- .../ird/observe/ui/content/ObserveContentUI.java | 7 +- .../content/impl/longline/BranchlineUIHandler.java | 23 +- .../LonglineDetailCompositionUIHandler.java | 264 ++++------ .../LonglineDetailCompositionUIInitializer.java | 4 +- ...onglineDetailCompositionUIValidationHelper.java | 18 +- .../LonglineGlobalCompositionUIHandler.java | 6 +- .../impl/longline/SetLonglineUIHandler.java | 53 +- .../ActivitySeineObservedSystemUIHandler.java | 4 +- .../seine/ActivitySeineObservedSystemUIModel.java | 2 - ...ngObjectTransmittingBuoyOperationUIHandler.java | 15 +- .../impl/seine/FloatingObjectUIHandler.java | 6 +- .../ui/content/impl/seine/SetSeineUIHandler.java | 38 +- .../ui/content/list/ContentListUIHandler.java | 17 +- .../impl/longline/ActivityLonglinesUIHandler.java | 2 +- .../list/impl/seine/ActivitySeinesUIHandler.java | 2 +- .../content/list/impl/seine/RoutesUIHandler.java | 2 +- .../impl/longline/ActivityLonglineUIHandler.java | 8 +- .../impl/longline/ActivityLonglineUIModel.java | 13 +- .../open/impl/longline/TripLonglineUIHandler.java | 50 +- .../open/impl/seine/ActivitySeineUIHandler.java | 26 +- .../open/impl/seine/ActivitySeineUIModel.java | 29 +- .../ui/content/open/impl/seine/RouteUIHandler.java | 6 +- .../open/impl/seine/TripSeineUIHandler.java | 50 +- .../ui/content/ref/ContentReferenceUIHandler.java | 50 +- .../ui/content/ref/UniqueKeyTableModel.java | 6 +- .../observe/ui/content/ref/impl/GearUIHandler.java | 17 +- .../ref/impl/LengthWeightParameterUIHandler.java | 17 +- .../ui/content/ref/impl/ProgramUIHandler.java | 17 +- .../ui/content/ref/impl/SpeciesListUIHandler.java | 17 +- .../ui/content/ref/impl/SpeciesUIHandler.java | 17 +- .../ui/content/ref/impl/VesselUIHandler.java | 17 +- .../observe/ui/content/table/ContentTableMeta.java | 23 +- .../ui/content/table/ContentTableModel.java | 2 +- .../ui/content/table/ContentTableUIHandler.java | 29 +- .../content/table/ContentTableUIInitializer.java | 99 ++-- .../ui/content/table/ContentTableUIModel.java | 11 +- .../impl/longline/BaitsCompositionUIHandler.java | 14 +- .../impl/longline/BaitsCompositionUIModel.java | 2 + .../longline/BranchlinesCompositionUIHandler.java | 13 +- .../longline/BranchlinesCompositionUIModel.java | 2 + .../impl/longline/CatchAcquisitionModeEnum.java | 2 +- .../CatchLonglineContentTableUIInitializer.java | 11 +- .../impl/longline/CatchLonglineTableModel.java | 5 + .../impl/longline/CatchLonglineUIHandler.java | 120 ++--- .../table/impl/longline/EncounterUIHandler.java | 2 +- .../table/impl/longline/EncounterUIModel.java | 2 + .../longline/FloatlinesCompositionUIHandler.java | 14 +- .../longline/FloatlinesCompositionUIModel.java | 1 + .../GearUseFeaturesLonglineTableModel.java | 7 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 65 +-- .../impl/longline/HooksCompositionUIHandler.java | 13 +- .../impl/longline/HooksCompositionUIModel.java | 1 + .../impl/longline/LonglinePositionHelper.java | 23 +- .../table/impl/longline/SensorUsedUIHandler.java | 2 +- .../table/impl/longline/SensorUsedUIModel.java | 1 + .../content/table/impl/longline/TdrUIHandler.java | 40 +- .../ui/content/table/impl/longline/TdrUIModel.java | 1 + .../seine/GearUseFeatureMeasurementCellEditor.java | 4 +- .../impl/seine/GearUseFeaturesSeineTableModel.java | 7 +- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 65 +-- .../impl/seine/ModeSaisieEchantillonEnum.java | 2 +- .../table/impl/seine/NonTargetCatchUIHandler.java | 57 +-- .../table/impl/seine/NonTargetCatchUIModel.java | 1 + .../table/impl/seine/NonTargetSampleUIHandler.java | 29 +- .../table/impl/seine/NonTargetSampleUIModel.java | 1 + .../impl/seine/ObjectObservedSpeciesUIHandler.java | 3 +- .../impl/seine/ObjectObservedSpeciesUIModel.java | 1 + .../impl/seine/ObjectSchoolEstimateUIHandler.java | 2 +- .../impl/seine/ObjectSchoolEstimateUIModel.java | 1 + .../table/impl/seine/SchoolEstimateUIHandler.java | 2 +- .../table/impl/seine/SchoolEstimateUIModel.java | 1 + .../table/impl/seine/TargetCatchUIHandler.java | 20 +- .../table/impl/seine/TargetCatchUIModel.java | 1 + .../impl/seine/TargetDiscardCatchUIHandler.java | 44 +- .../impl/seine/TargetDiscardCatchUIModel.java | 1 + .../table/impl/seine/TargetSampleUIHandler.java | 29 +- .../table/impl/seine/TargetSampleUIModel.java | 1 + .../ird/observe/ui/storage/ObstunaAdminAction.java | 8 +- .../ird/observe/ui/storage/RemoteUILauncher.java | 4 +- .../ui/storage/StorageBackupUILauncher.java | 2 +- .../ird/observe/ui/storage/StorageUIHandler.java | 99 ++-- .../ird/observe/ui/storage/StorageUILauncher.java | 2 +- .../fr/ird/observe/ui/storage/StorageUIModel.java | 114 ++--- .../ui/storage/tabs/DataSelectionModel.java | 17 +- .../ird/observe/ui/storage/tabs/SecurityModel.java | 12 +- .../ui/storage/tabs/StorageTabUIHandler.java | 92 ++-- .../ui/tree/DataSelectionTreeCellRenderer.java | 9 +- .../ui/tree/DataSelectionTreeSelectionModel.java | 4 +- .../fr/ird/observe/ui/tree/ObserveTreeBridge.java | 2 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 2 +- .../ui/tree/loadors/RootNodeChildLoador.java | 3 - .../ObserveSwingValidatorMessageTableModel.java | 4 +- .../ui/util/table/AbstractSelectTableAction.java | 3 +- .../fr/ird/observe/ui/util/table/EditableList.java | 2 +- .../ui/util/table/EditableTableModelSupport.java | 30 +- .../table/ObserveBooleanTableCellRenderer.java | 13 +- .../observe/ui/util/tripMap/ObserveMapPane.java | 9 +- .../util/tripMap/ObserverMapPanLegendDrawer.java | 24 +- .../ui/util/tripMap/TripMapContentBuilder.java | 12 +- .../observe/ui/util/tripMap/TripMapUIHandler.java | 2 +- .../validation/ValidationMessageDetector.java | 560 --------------------- ...glineDetailCompositionValidatorServiceTest.java | 2 +- .../application/web/ObserveWebMotionRender.java | 2 +- .../ObserveWebApplicationConfigurationOption.java | 9 +- .../web/configuration/db/ObserveWebDatabase.java | 3 +- .../web/configuration/db/ObserveWebDatabases.java | 3 +- .../db/impl/ObserveWebDatabaseBean.java | 11 +- .../db/impl/ObserveWebDatabaseImmutable.java | 21 +- .../db/impl/ObserveWebDatabasesBean.java | 11 +- .../db/impl/ObserveWebDatabasesImmutable.java | 21 +- .../web/configuration/user/ObserveWebUser.java | 3 +- .../web/configuration/user/ObserveWebUsers.java | 3 +- .../configuration/user/ObserveWebUsersHelper.java | 4 +- .../user/impl/ObserveWebUserBean.java | 11 +- .../user/impl/ObserveWebUserImmutable.java | 21 +- .../user/impl/ObserveWebUsersBean.java | 11 +- .../user/impl/ObserveWebUsersImmutable.java | 21 +- .../controller/v1/DataSourceServiceController.java | 2 +- .../web/converter/ObserveDtoConverter.java | 2 +- .../application/web/injector/DateInjector.java | 2 +- .../web/injector/ObserveDtoInjector.java | 2 +- .../web/request/ObserveWebRequestContext.java | 12 +- .../ObserveWebSecurityApplicationContext.java | 2 +- ...ObserveWebSecurityAuthenticationTokenCache.java | 11 +- .../db/ObserveWebDatabasesHelperTest.java | 4 +- .../user/ObserveWebUsersHelperTest.java | 2 +- .../fr/ird/observe/ObserveApplicationContext.java | 2 +- .../java/fr/ird/observe/ObserveServiceHelper.java | 2 +- .../java/fr/ird/observe/db/impl/PGDataSource.java | 2 +- .../fr/ird/observe/db/impl/PGDataSourceConfig.java | 2 +- .../LICENSE.txt | 0 .../README.md | 0 .../pom.xml | 50 +- .../src/license/THIRD-PARTY.properties | 0 .../migration/AbstractDataSourceMigration.java | 57 +++ .../AbstractObserveMigrationCallBack.java | 47 +- .../entities/migration/H2DataSourceMigration.java | 283 +++++++++++ ...ObserveMigrationCallBackForVersionResolver.java | 2 +- .../ObserveMigrationConfigurationProviderImpl.java | 121 +++++ .../entities/migration/PGDataSourceMigration.java | 369 ++++++++++++++ .../DataSourceMigrationForVersion_3_1.java | 3 +- .../DataSourceMigrationForVersion_3_10.java | 3 +- .../DataSourceMigrationForVersion_3_11.java | 3 +- .../DataSourceMigrationForVersion_3_12.java | 3 +- .../DataSourceMigrationForVersion_3_14.java | 3 +- .../DataSourceMigrationForVersion_3_15.java | 3 +- .../DataSourceMigrationForVersion_3_16.java | 41 +- .../DataSourceMigrationForVersion_3_5.java | 5 +- .../DataSourceMigrationForVersion_3_7.java | 3 +- .../DataSourceMigrationForVersion_3_8.java | 3 +- .../DataSourceMigrationForVersion_3_9.java | 3 +- .../DataSourceMigrationForVersion_4_0.java | 3 +- .../DataSourceMigrationForVersion_4_0_1.java | 71 ++- .../DataSourceMigrationForVersion_4_0_2.java | 3 +- .../DataSourceMigrationForVersion_4_0_4.java | 3 +- .../DataSourceMigrationForVersion_4_0_RC2.java | 41 +- .../DataSourceMigrationForVersion_4_0_RC3.java | 27 +- .../DataSourceMigrationForVersion_4_0_RC4.java | 3 +- .../DataSourceMigrationForVersion_4_0_RC6.java | 3 +- .../DataSourceMigrationForVersion_4_0_RC7.java | 3 +- .../DataSourceMigrationForVersion_4_900.java | 3 +- .../DataSourceMigrationForVersion_4_901.java | 3 +- .../DataSourceMigrationForVersion_4_902.java | 3 +- .../DataSourceMigrationForVersion_4_903.java | 3 +- .../DataSourceMigrationForVersion_4_904.java | 3 +- .../DataSourceMigrationForVersion_5_0.java | 3 +- .../main/java/fr/ird/type/CoordinateHelper.java | 0 ...migration.ObserveMigrationConfigurationProvider | 1 + .../src/main/resources/db/3.5/constrainsts.csv | 0 .../resources/db/3.5/traduction_attributes.csv | 0 .../main/resources/db/3.5/traduction_tables.csv | 0 .../main/resources/db/3.5/traduction_tables2.csv | 0 .../db/migration/V3_10_01_remove-person-H2.sql | 0 .../db/migration/V3_10_01_remove-person-PG.sql | 0 .../db/migration/V3_10_02_add-missing-fk-H2.sql | 0 .../db/migration/V3_10_02_add-missing-fk-PG.sql | 0 .../V3_10_03_increase-comment-field-H2.sql | 0 .../V3_10_03_increase-comment-field-PG.sql | 0 .../migration/V3_10_04_fix-sensorDataFormat-H2.sql | 0 .../migration/V3_10_04_fix-sensorDataFormat-PG.sql | 0 .../migration/V3_10_05_normalize-sections-H2.sql | 0 .../migration/V3_10_05_normalize-sections-PG.sql | 0 ...1_01_remove-speciesGroup-obsolete-fields-H2.sql | 0 ...1_01_remove-speciesGroup-obsolete-fields-PG.sql | 0 ...3_11_02_add-country-on-transmitting-buoy-H2.sql | 0 ...3_11_02_add-country-on-transmitting-buoy-PG.sql | 0 .../db/migration/V3_11_03_add-fpaZones-H2.sql | 0 .../db/migration/V3_11_03_add-fpaZones-PG.sql | 0 .../migration/V3_11_04_add-activity-ersId-H2.sql | 0 .../migration/V3_11_04_add-activity-ersId-PG.sql | 0 .../migration/V3_11_05_add-person-country-H2.sql | 0 .../migration/V3_11_05_add-person-country-PG.sql | 0 .../db/migration/V3_11_06_add-harbours-H2.sql | 0 .../db/migration/V3_11_06_add-harbours-PG.sql | 0 .../db/migration/V3_12_01_add-missing-boat-H2.sql | 0 .../db/migration/V3_12_01_add-missing-boat-PG.sql | 0 ...3_14_01_remove-hooksPerBasketCount-field-H2.sql | 0 ...3_14_01_remove-hooksPerBasketCount-field-PG.sql | 0 ...3_14_02_fix-targetsample-discarded-value-H2.sql | 0 ...3_14_02_fix-targetsample-discarded-value-PG.sql | 0 .../V3_14_03_remove-orphan-seine-sample-H2.sql | 0 .../V3_14_03_remove-orphan-seine-sample-PG.sql | 0 ...4_04_remove-targetlength-discarded-field-H2.sql | 0 ...4_04_remove-targetlength-discarded-field-PG.sql | 0 ..._15_01_change-tdr-integer-field-to-float-H2.sql | 0 ..._15_01_change-tdr-integer-field-to-float-PG.sql | 0 ..._15_02_remove-set-longline-length-fields-H2.sql | 0 ..._15_02_remove-set-longline-length-fields-PG.sql | 0 .../V3_15_03_remove-brancheline-fields-H2.sql | 0 .../V3_15_03_remove-brancheline-fields-PG.sql | 0 .../migration/V3_16_01_add-gear-referential-H2.sql | 0 .../migration/V3_16_01_add-gear-referential-PG.sql | 0 .../db/migration/V3_16_02_add-gear-data-H2.sql | 0 .../db/migration/V3_16_02_add-gear-data-PG.sql | 0 .../V3_16_03_remove-tripSeine-seine-H2.sql | 0 .../V3_16_03_remove-tripSeine-seine-PG.sql | 0 .../db/migration/V3_5_01_migration-H2.sql | 0 .../db/migration/V3_5_01_migration-PG.sql | 0 .../migration/V3_5_02_add-longline-schema-H2.sql | 0 .../migration/V3_5_02_add-longline-schema-PG.sql | 0 .../V3_5_03_update-common-references-H2.sql | 0 .../V3_5_03_update-common-references-PG.sql | 0 .../V3_5_04_add-longline-references-H2.sql | 0 .../V3_5_04_add-longline-references-PG.sql | 0 .../db/migration/V3_7_01_rename-seine-model-H2.sql | 0 .../db/migration/V3_7_01_rename-seine-model-PG.sql | 0 .../migration/V3_7_02_remove-trip-organism-H2.sql | 0 .../migration/V3_7_02_remove-trip-organism-PG.sql | 0 .../V3_7_03_add-referential-needComment-H2.sql | 0 .../V3_7_03_add-referential-needComment-PG.sql | 0 .../V3_7_04_normalize-triplongline-H2.sql | 0 .../V3_7_04_normalize-triplongline-PG.sql | 0 .../V3_7_05_normalize-activitylongline-H2.sql | 0 .../V3_7_05_normalize-activitylongline-PG.sql | 0 .../migration/V3_7_06_normalize-setlongline-H2.sql | 0 .../migration/V3_7_06_normalize-setlongline-PG.sql | 0 .../V3_7_07_normalize-catchlongline-H2.sql | 0 .../V3_7_07_normalize-catchlongline-PG.sql | 0 .../db/migration/V3_7_08_normalize-tdr-H2.sql | 0 .../db/migration/V3_7_08_normalize-tdr-PG.sql | 0 .../db/migration/V3_7_09_add-species-list-H2.sql | 0 .../db/migration/V3_7_09_add-species-list-PG.sql | 0 .../V3_7_10_increase-comment-field-H2.sql | 0 .../V3_7_10_increase-comment-field-PG.sql | 0 .../db/migration/V3_8_01_fix-person-H2.sql | 0 .../db/migration/V3_8_01_fix-person-PG.sql | 0 .../V3_8_02_fix-branchelinecomposition-H2.sql | 0 .../V3_8_02_fix-branchelinecomposition-PG.sql | 0 .../migration/V3_8_03_normalize-sensorused-H2.sql | 0 .../migration/V3_8_03_normalize-sensorused-PG.sql | 0 .../db/migration/V3_8_04_normalize-tdr-H2.sql | 0 .../db/migration/V3_8_04_normalize-tdr-PG.sql | 0 .../V3_9_01_add-dataFilename-attribute-H2.sql | 0 .../V3_9_01_add-dataFilename-attribute-PG.sql | 0 .../migration/V3_9_02_fill-sensorDataFormat-H2.sql | 0 .../migration/V3_9_02_fill-sensorDataFormat-PG.sql | 0 .../resources/db/migration/V4_0_01_empty-H2.sql | 0 .../resources/db/migration/V4_0_01_empty-PG.sql | 0 .../V4_0_1_01_remove-gender-column-H2.sql | 0 .../db/migration/V4_0_1_02_add-missing-fk-H2.sql | 0 .../db/migration/V4_0_1_02_add-missing-fk-PG.sql | 0 .../V4_0_2_01_remove-gender-column-PG.sql | 0 ...0_4_01_remove-trip-datearriveeport-field-H2.sql | 0 ...0_4_01_remove-trip-datearriveeport-field-PG.sql | 0 .../V4_0_RC_2_01_add-foreign-key-indexes-PG.sql | 0 .../V4_0_RC_2_01_clean-program-gear-type-H2.sql | 0 .../V4_0_RC_2_01_clean-program-gear-type-PG.sql | 0 ...4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql | 0 ...4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql | 0 .../V4_0_RC_2_03_rename-unknown-longliner-H2.sql | 0 .../V4_0_RC_2_03_rename-unknown-longliner-PG.sql | 0 .../db/migration/V4_0_RC_4_01_add-gear-data-H2.sql | 0 .../db/migration/V4_0_RC_4_01_add-gear-data-PG.sql | 0 ...4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql | 0 ...4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql | 0 ...4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql | 0 ...4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql | 0 .../V4_0_RC_7_02_rename-unknown-longliner-H2.sql | 0 .../V4_0_RC_7_02_rename-unknown-longliner-PG.sql | 0 .../migration/V4_900_01_remove_open_field-H2.sql | 0 .../migration/V4_900_01_remove_open_field-PG.sql | 0 .../V4_901_01_add_lastUpdateDate_field-H2.sql | 0 .../V4_901_01_add_lastUpdateDate_field-PG.sql | 0 .../V4_902_01_add_lastUpdateDate_table-H2.sql | 0 .../V4_902_01_add_lastUpdateDate_table-PG.sql | 0 .../migration/V4_903_01_remove_unit_field-H2.sql | 0 .../migration/V4_903_01_remove_unit_field-PG.sql | 0 .../migration/V4_903_02_remove_gender_field-H2.sql | 0 .../migration/V4_903_02_remove_gender_field-PG.sql | 0 .../V4_903_03_remove_duplicate_rows-H2.sql | 0 .../V4_903_03_remove_duplicate_rows-PG.sql | 0 ...drop_not_null_constraint_gearUseFeatures-H2.sql | 0 ...drop_not_null_constraint_gearUseFeatures-PG.sql | 0 ...rveMigrationCallBackForVersionResolverTest.java | 6 +- .../src/test/resources/log4j.properties | 0 observe-entities/pom.xml | 9 - .../observe/ObserveTopiaApplicationContext.java | 13 +- .../observe/ObserveTopiaConfigurationFactory.java | 75 ++- .../java/fr/ird/observe/entities/Entities.java | 16 +- .../constants/TripMapPointTypePersist.java | 2 +- .../NonTargetCatchComputedValueSourcePersist.java | 2 +- .../entities/constants/seine/OwnershipPersist.java | 2 +- .../constants/seine/SchoolTypePersist.java | 2 +- .../TypeTransmittingBuoyOperationPersist.java | 2 +- .../observe/entities}/gps/CoordinateHelper.java | 2 +- .../java/fr/ird/observe/entities/gps/GPSPoint.java | 120 ----- .../fr/ird/observe/entities/gps/GPSPointImpl.java | 79 --- .../ird/observe/entities/gps/GPSPointInterval.java | 155 ------ .../observe/entities/gps/GPSPointIntervalImpl.java | 84 ---- .../java/fr/ird/observe/entities/gps/GPSRoute.java | 276 ---------- .../fr/ird/observe/entities/gps/GPSRouteImpl.java | 144 ------ .../fr/ird/observe/entities/gps/GpsPoints.java | 177 ------- .../entities/longline/ActivityLonglineImpl.java | 2 +- .../entities/longline/ActivityLonglines.java | 15 +- .../observe/entities/longline/SetLonglineImpl.java | 2 +- .../entities/longline/TripLonglineTopiaDao.java | 4 +- .../migration/AbstractDataSourceMigration.java | 138 ----- .../entities/migration/H2DataSourceMigration.java | 309 ------------ .../ObserveMigrationConfigurationProvider.java | 40 ++ .../entities/migration/ObserveMigrationEngine.java | 13 +- .../entities/migration/PGDataSourceMigration.java | 394 --------------- .../observe/entities/referentiel/HarbourImpl.java | 2 +- .../referentiel/ObserveReferentialEntities.java | 20 +- .../ird/observe/entities/referentiel/Persons.java | 21 +- .../ird/observe/entities/referentiel/Programs.java | 9 +- .../ird/observe/entities/referentiel/Species2.java | 16 +- .../observe/entities/seine/ActivitySeineImpl.java | 5 +- .../ird/observe/entities/seine/ActivitySeines.java | 17 +- .../observe/entities/seine/NonTargetCatchImpl.java | 2 +- .../observe/entities/seine/NonTargetCatchs.java | 7 +- .../observe/entities/seine/NonTargetLenghts.java | 7 +- .../ird/observe/entities/seine/RouteTopiaDao.java | 40 +- .../java/fr/ird/observe/entities/seine/Routes.java | 15 +- .../fr/ird/observe/entities/seine/SetSeines.java | 9 +- .../ird/observe/entities/seine/TargetCatchs.java | 18 +- .../ird/observe/entities/seine/TargetLenghts.java | 10 +- .../observe/entities/seine/TripSeineTopiaDao.java | 4 +- .../ObserveTopiaApplicationContextTest.java | 109 ---- .../validation => }/RelationRegexTest.java | 2 +- .../services/ObserveServiceInitializer.java | 6 +- .../service/actions/report/ReportBuilder.java | 2 +- .../actions/validate/ValidateResultForDtoType.java | 8 +- .../actions/validate/ValidateResultForDtos.java | 30 +- .../actions/validate/ValidationMessage.java | 6 +- .../service/actions/validate/ValidatorDtos.java | 15 +- .../ObserveDataSourceConfigurationRest.java | 4 +- .../observe/services/dto/AbstractReference.java | 26 +- .../fr/ird/observe/services/dto/DataReference.java | 28 +- .../java/fr/ird/observe/services/dto/IdDtos.java | 26 +- .../observe/services/dto/ObserveDbUserDtos.java | 2 +- .../services/dto/actions/report/Report.java | 8 +- .../dto/actions/report/ReportOperation.java | 2 +- .../dto/actions/report/ReportVariable.java | 6 +- .../services/dto/constants/ObserveDbRole.java | 2 +- .../services/dto/constants/ReferenceStatus.java | 2 +- .../services/dto/constants/TripMapPointType.java | 4 +- .../seine/NonTargetCatchComputedValueSource.java | 2 +- .../services/dto/constants/seine/SchoolType.java | 2 +- .../seine/TypeTransmittingBuoyOperation.java | 4 +- .../services/dto/gson/ObserveDtoGsonSupplier.java | 8 +- .../services/dto/longline/SectionWithTemplate.java | 4 - .../dto/longline/SectionWithTemplates.java | 11 +- .../services/dto/referential/PersonDtos.java | 30 +- .../services/dto/referential/ReferentialDtos.java | 2 +- .../dto/referential/ReferentialReferences.java | 21 +- .../util/{gps/GpsPoints.java => GPSPoint.java} | 137 +++-- .../main/java/fr/ird/observe/util/gps/GPSAble.java | 59 --- .../fr/ird/observe/util/gps/GPSFileReader.java | 356 ------------- .../java/fr/ird/observe/util/gps/GPSPoint.java | 118 ----- .../java/fr/ird/observe/util/gps/GPSPointImpl.java | 76 --- .../fr/ird/observe/util/gps/GPSPointInterval.java | 155 ------ .../ird/observe/util/gps/GPSPointIntervalImpl.java | 86 ---- .../java/fr/ird/observe/util/gps/GPSRoute.java | 276 ---------- .../java/fr/ird/observe/util/gps/GPSRouteImpl.java | 144 ------ .../java/fr/ird/observe/util/gps/GPSService.java | 115 ----- .../services/http/ObserveRequestBuilder.java | 2 +- .../ird/observe/services/http/ObserveResponse.java | 6 +- .../services/http/ObserveResponseBuilder.java | 4 +- .../services/service/AbstractServiceRestTest.java | 2 +- .../service/ReferenceValuesSetServiceRestTest.java | 4 +- .../report/AbstractReportServiceRestTest.java | 5 - .../report/ReportAccessoryCatchRestTest.java | 2 +- .../actions/validate/ValidateServiceRestTest.java | 251 +++++---- observe-services-topia-validation/pom.xml | 5 + .../validators/AbstractSpeciesFieldValidator.java | 4 +- .../validators/ActivitySimpleSpeedValidator.java | 9 +- .../validators/ActivitySpeedValidator.java | 9 +- ...erve-services-topia-validation_en_GB.properties | 2 +- ...erve-services-topia-validation_es_ES.properties | 2 +- ...erve-services-topia-validation_fr_FR.properties | 2 +- .../validation/BeanValidatorDetectorTest.java | 2 +- observe-services-topia/pom.xml | 6 + .../observe/services/ObserveSecurityHelper.java | 11 +- .../ird/observe/services/ObserveServiceTopia.java | 4 +- .../ObserveTopiaApplicationContextFactory.java | 4 +- .../ird/observe/services/binder/BinderEngine.java | 12 +- .../ird/observe/services/binder/BinderSupport.java | 104 +--- .../observe/services/entity/EntitiesExtractor.java | 12 +- .../services/entity/EntitiesSetFactory.java | 12 +- .../entity/SpeciesListEntitiesExtractor.java | 2 +- .../entity/SpeciesListOceanEntitiesExtractor.java | 7 +- .../observe/services/entity/TripMapDtoFactory.java | 21 +- .../services/service/DataSourceServiceTopia.java | 15 +- .../services/service/ReferentialServiceTopia.java | 4 +- .../service/SqlScriptProducerServiceTopia.java | 4 +- .../ConsolidateActivitySeineDataResultBuilder.java | 12 +- .../consolidate/ConsolidateDataServiceTopia.java | 4 +- .../service/actions/report/ReportServiceTopia.java | 4 +- ...alReferentialSynchronizeRemoteServiceTopia.java | 5 +- .../validate/ValidationMessageDetector.java | 9 +- .../longline/ActivityLonglineServiceTopia.java | 4 +- .../service/seine/ActivitySeineServiceTopia.java | 4 +- .../services/service/seine/RouteServiceTopia.java | 10 +- .../referentiel/LengthWeightParemetersTest.java | 2 +- .../ird/observe/services/DataSourceResource.java | 4 +- .../services/binder/BinderEngineMetadataTest.java | 2 +- .../observe/services/binder/BinderEngineTest.java | 9 +- .../service/DataSourceServiceTopiaTest.java | 9 +- .../services/service/MigrateTestsDatabases.java | 2 +- .../fr/ird/observe/services/service/RigthTest.java | 6 +- .../report/AbstractReportServiceTopiaTest.java | 5 - .../actions/report/ReportAccessoryCatch2Test.java | 2 +- .../report/ReportAccessoryCatchByGroup2Test.java | 2 +- .../report/ReportAccessoryCatchByGroupTest.java | 2 +- .../actions/report/ReportAccessoryCatchTest.java | 2 +- .../report/ReportActivityWithCommentTest.java | 2 +- .../actions/report/ReportAllActivitysTest.java | 2 +- .../actions/report/ReportDailySetAndCatchTest.java | 2 +- .../service/actions/report/ReportDcpUsageTest.java | 2 +- .../actions/report/ReportSetByAssociationTest.java | 2 +- .../report/ReportTargetCatchByAssociationTest.java | 2 +- .../ReportTargetDiscardedByAssociationTest.java | 2 +- .../actions/validate/ValidateServiceTopiaTest.java | 229 +++++---- .../java/fr/ird/observe/test/ObserveFixtures.java | 3 + .../sql/batch/actions/AbstractSqlAction.java | 26 +- .../sql/batch/actions/AbstractTablesAction.java | 2 +- .../sql/batch/actions/DeleteTablesAction.java | 6 +- .../sql/batch/actions/ReplicateTablesAction.java | 2 +- .../sql/batch/actions/UpdateTablesAction.java | 2 +- .../service/sql/batch/tables/TopiaSqlTables.java | 2 +- pom.xml | 7 +- 490 files changed, 3297 insertions(+), 7301 deletions(-) delete mode 100644 observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationMessageDetector.java copy {observe-topia-templates-extension => observe-entities-migration}/LICENSE.txt (100%) copy {observe-topia-templates-extension => observe-entities-migration}/README.md (100%) copy {observe-topia-extension => observe-entities-migration}/pom.xml (69%) copy {observe-topia-templates-extension => observe-entities-migration}/src/license/THIRD-PARTY.properties (100%) create mode 100644 observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java (65%) create mode 100644 observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java (99%) create mode 100644 observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProviderImpl.java create mode 100644 observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java (95%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java (82%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java (97%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java (93%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java (78%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java (73%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java (93%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java (93%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java (92%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java (91%) rename {observe-entities => observe-entities-migration}/src/main/java/fr/ird/type/CoordinateHelper.java (100%) create mode 100644 observe-entities-migration/src/main/resources/META-INF/services/fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider rename {observe-entities => observe-entities-migration}/src/main/resources/db/3.5/constrainsts.csv (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/3.5/traduction_attributes.csv (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/3.5/traduction_tables.csv (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/3.5/traduction_tables2.csv (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_01_remove-person-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_01_remove-person-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_02_add-missing-fk-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_02_add-missing-fk-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_03_increase-comment-field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_03_increase-comment-field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_05_normalize-sections-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_10_05_normalize-sections-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_03_add-fpaZones-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_03_add-fpaZones-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_04_add-activity-ersId-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_04_add-activity-ersId-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_05_add-person-country-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_05_add-person-country-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_06_add-harbours-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_11_06_add-harbours-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_12_01_add-missing-boat-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_12_01_add-missing-boat-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_01_add-gear-referential-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_01_add-gear-referential-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_02_add-gear-data-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_02_add-gear-data-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_01_migration-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_01_migration-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_02_add-longline-schema-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_02_add-longline-schema-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_03_update-common-references-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_03_update-common-references-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_04_add-longline-references-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_5_04_add-longline-references-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_01_rename-seine-model-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_01_rename-seine-model-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_02_remove-trip-organism-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_02_remove-trip-organism-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_03_add-referential-needComment-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_03_add-referential-needComment-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_04_normalize-triplongline-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_04_normalize-triplongline-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_06_normalize-setlongline-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_06_normalize-setlongline-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_08_normalize-tdr-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_08_normalize-tdr-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_09_add-species-list-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_09_add-species-list-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_10_increase-comment-field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_7_10_increase-comment-field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_01_fix-person-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_01_fix-person-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_03_normalize-sensorused-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_03_normalize-sensorused-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_04_normalize-tdr-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_8_04_normalize-tdr-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_01_empty-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_01_empty-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_1_01_remove-gender-column-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_2_01_remove-gender-column-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_01_add-foreign-key-indexes-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_900_01_remove_open_field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_900_01_remove_open_field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_01_remove_unit_field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_01_remove_unit_field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_02_remove_gender_field-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_02_remove_gender_field-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-H2.sql (100%) rename {observe-entities => observe-entities-migration}/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-PG.sql (100%) rename {observe-entities => observe-entities-migration}/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java (89%) copy {observe-services-topia-validation => observe-entities-migration}/src/test/resources/log4j.properties (100%) rename {observe-services-model/src/main/java/fr/ird/observe/util => observe-entities/src/main/java/fr/ird/observe/entities}/gps/CoordinateHelper.java (97%) delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPoint.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointImpl.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointInterval.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointIntervalImpl.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRoute.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRouteImpl.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/gps/GpsPoints.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java create mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProvider.java delete mode 100644 observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java delete mode 100644 observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java rename observe-entities/src/test/java/fr/ird/observe/{business/validation => }/RelationRegexTest.java (98%) rename observe-services-model/src/main/java/fr/ird/observe/util/{gps/GpsPoints.java => GPSPoint.java} (60%) delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSAble.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSFileReader.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPoint.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointImpl.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointInterval.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointIntervalImpl.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRoute.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRouteImpl.java delete mode 100644 observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSService.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 853fe15975d3dfdc8934305abbf8e724097ca2e5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 10:31:17 2016 +0200 No more create validation context on service validation --- .../actions/validate/ValidateServiceTopiaTest.java | 27 ---------------------- 1 file changed, 27 deletions(-) diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java index 71fa720..713e9bd 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java @@ -133,33 +133,6 @@ public class ValidateServiceTopiaTest extends AbstractServiceTopiaTest { } @Test - public void testValidateTripSeinesCreate() throws Exception { - - ValidateDataRequest request = new ValidateDataRequest(); - - request.setValidationContext(ValidateService.N1_CREATE_CONTEXT); - request.setScopes(ImmutableSet.copyOf(NuitonValidatorScope.values())); - request.setDataIds(ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1, ObserveFixtures.TRIP_SEINE_ID_2)); - - ValidateDataResult result = service.validateData(request); - Assert.assertNotNull(result); - ImmutableMap<Class<? extends IdDto>, ValidateResultForDtoType> resultByType = result.getResultByType(); - Assert.assertNotNull(resultByType); - Assert.assertEquals(5, resultByType.size()); - -// for (Map.Entry<Class<? extends IdDto>, ValidateResultForDtoType> entry : resultByType.entrySet()) { -// System.out.println("assertValidateResultForDtoType(resultByType, " + entry.getKey().getName() + ".class, " + entry.getValue().getValidationResultForDto().size() + ");"); -// } - - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TripSeineDto.class, 2); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.RouteDto.class, 80); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.ActivitySeineDto.class, 1519); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.FloatingObjectDto.class, 99); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.SetSeineDto.class, 77); - - } - - @Test public void testValidateTripSeinesUdpate() throws Exception { ValidateDataRequest request = new ValidateDataRequest(); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 1f8ea21506c2895fbc618b28f3846ccdc2043542 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 10:31:33 2016 +0200 Use lambda \o/ --- .../ObserveSwingApplicationConfigOption.java | 9 +- .../fr/ird/observe/ui/ObserveMainUIHandler.java | 42 ++-- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 8 +- .../fr/ird/observe/ui/actions/ShowAboutAction.java | 13 +- .../ird/observe/ui/actions/ShowConfigAction.java | 8 +- .../ui/actions/shared/CancelCreateUIAction.java | 26 +-- .../ui/actions/shared/CloseAndCreateUIAction.java | 128 ++++++----- .../ui/actions/shared/CloseOpenUIAction.java | 146 ++++++------- .../ui/actions/shared/DeleteDataUIAction.java | 33 ++- .../ui/actions/shared/DeleteReferenceUIAction.java | 29 ++- .../observe/ui/actions/shared/GoDownUIAction.java | 22 +- .../observe/ui/actions/shared/GoUpUIAction.java | 20 +- .../shared/MoveActivityLonglinesUIAction.java | 62 +++--- .../actions/shared/MoveActivitySeinesUIAction.java | 60 +++--- .../ui/actions/shared/MoveRoutesUIAction.java | 62 +++--- .../ui/actions/shared/MoveTripsUIAction.java | 52 +++-- .../observe/ui/actions/shared/ReOpenUIAction.java | 58 +++-- .../ui/actions/shared/ResetEditUIAction.java | 23 +- .../ui/actions/shared/SaveEditUIAction.java | 23 +- .../fr/ird/observe/ui/admin/AdminUILauncher.java | 7 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 238 +++++++++------------ .../ui/admin/consolidate/ConsolidateUIHandler.java | 37 +--- .../observe/ui/admin/report/ReportUIHandler.java | 121 ++++------- .../ui/admin/validate/ValidateUIHandler.java | 96 ++++----- .../ird/observe/ui/content/ContentUIHandler.java | 16 +- .../content/impl/longline/BranchlineUIHandler.java | 17 +- .../LonglineDetailCompositionUIHandler.java | 222 +++++++------------ ...onglineDetailCompositionUIValidationHelper.java | 16 +- .../impl/longline/SetLonglineUIHandler.java | 45 ++-- ...ngObjectTransmittingBuoyOperationUIHandler.java | 9 +- .../ui/content/impl/seine/SetSeineUIHandler.java | 30 ++- .../impl/longline/ActivityLonglineUIModel.java | 13 +- .../open/impl/longline/TripLonglineUIHandler.java | 44 ++-- .../open/impl/seine/ActivitySeineUIHandler.java | 18 +- .../open/impl/seine/ActivitySeineUIModel.java | 29 ++- .../open/impl/seine/TripSeineUIHandler.java | 44 ++-- .../ui/content/ref/ContentReferenceUIHandler.java | 44 ++-- .../observe/ui/content/ref/impl/GearUIHandler.java | 15 +- .../ref/impl/LengthWeightParameterUIHandler.java | 15 +- .../ui/content/ref/impl/ProgramUIHandler.java | 15 +- .../ui/content/ref/impl/SpeciesListUIHandler.java | 15 +- .../ui/content/ref/impl/SpeciesUIHandler.java | 15 +- .../ui/content/ref/impl/VesselUIHandler.java | 15 +- .../observe/ui/content/table/ContentTableMeta.java | 7 +- .../ui/content/table/ContentTableUIHandler.java | 23 +- .../content/table/ContentTableUIInitializer.java | 97 ++++----- .../impl/longline/BaitsCompositionUIHandler.java | 12 +- .../longline/BranchlinesCompositionUIHandler.java | 11 +- .../CatchLonglineContentTableUIInitializer.java | 11 +- .../impl/longline/CatchLonglineUIHandler.java | 108 +++------- .../longline/FloatlinesCompositionUIHandler.java | 12 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 57 ++--- .../impl/longline/HooksCompositionUIHandler.java | 11 +- .../impl/longline/LonglinePositionHelper.java | 17 +- .../content/table/impl/longline/TdrUIHandler.java | 32 ++- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 57 ++--- .../table/impl/seine/NonTargetCatchUIHandler.java | 55 ++--- .../table/impl/seine/NonTargetSampleUIHandler.java | 27 +-- .../table/impl/seine/TargetCatchUIHandler.java | 18 +- .../impl/seine/TargetDiscardCatchUIHandler.java | 40 ++-- .../table/impl/seine/TargetSampleUIHandler.java | 27 +-- .../ird/observe/ui/storage/StorageUIHandler.java | 97 ++++----- .../fr/ird/observe/ui/storage/StorageUIModel.java | 104 ++++----- .../ui/storage/tabs/StorageTabUIHandler.java | 92 ++++---- .../ui/tree/DataSelectionTreeCellRenderer.java | 9 +- .../ui/util/table/EditableTableModelSupport.java | 24 +-- .../ui/util/tripMap/TripMapContentBuilder.java | 8 +- pom.xml | 2 +- 68 files changed, 1156 insertions(+), 1762 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java index 356dcd2..ba3fdc8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java @@ -34,7 +34,6 @@ import java.awt.Color; import java.io.File; import java.net.URL; import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Locale; @@ -937,13 +936,7 @@ public enum ObserveSwingApplicationConfigOption implements ConfigOptionDef { public static ImmutableList<ObserveSwingApplicationConfigOption> orderedByNameValues() { List<ObserveSwingApplicationConfigOption> values = Lists.newArrayList(values()); - Collections.sort(values, new Comparator<ObserveSwingApplicationConfigOption>() { - - @Override - public int compare(ObserveSwingApplicationConfigOption o1, ObserveSwingApplicationConfigOption o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }); + Collections.sort(values, (o1, o2) -> o1.getKey().compareTo(o2.getKey())); return ImmutableList.copyOf(values); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java index e7e4215..3c06af7 100755 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java @@ -23,8 +23,8 @@ package fr.ird.observe.ui; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.application.swing.decoration.DecoratorService; -import fr.ird.observe.db.DataContext; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; +import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.AbstractObserveDto; import fr.ird.observe.services.dto.constants.ReferentialLocale; @@ -48,16 +48,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.i18n.I18n; -import javax.swing.*; +import javax.swing.Icon; +import javax.swing.SwingUtilities; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeWillExpandListener; import javax.swing.tree.ExpandVetoException; import javax.swing.tree.TreePath; -import java.awt.*; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; +import java.awt.Cursor; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -389,7 +388,7 @@ public class ObserveMainUIHandler { if (service.isLocal()) { icon = (Icon) ui.storageStatus.getClientProperty("localIcon"); - } else if (service.isRemote()){ + } else if (service.isRemote()) { icon = (Icon) ui.storageStatus.getClientProperty("remoteIcon"); } else { icon = (Icon) ui.storageStatus.getClientProperty("serverIcon"); @@ -475,20 +474,13 @@ public class ObserveMainUIHandler { // ajout d'un ecouteur sur la navigation pour toujours mettre la scrollbar // tout à droite a chaque selection - TreeSelectionListener listener = new TreeSelectionListener() { - - @Override - public void valueChanged(TreeSelectionEvent e) { - changeNavigationNode(ui, e); - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - ui.getNavigationScrollPane().getHorizontalScrollBar().setValue(0); - ui.getSplitpane2().resetToPreferredSizes(); - } - }); - } + TreeSelectionListener listener; + listener = e -> { + changeNavigationNode(ui, e); + SwingUtilities.invokeLater(() -> { + ui.getNavigationScrollPane().getHorizontalScrollBar().setValue(0); + ui.getSplitpane2().resetToPreferredSizes(); + }); }; TreeWillExpandListener veteobableTreeWillExpand = new TreeWillExpandListener() { @Override @@ -525,13 +517,9 @@ public class ObserveMainUIHandler { UIHelper.setLayerUI(ui.getBody(), ui.getBusyBlockLayerUI()); // ecoute des changements de l'état busy - ui.addPropertyChangeListener(ObserveMainUI.PROPERTY_BUSY, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newvalue = (Boolean) evt.getNewValue(); - updateBusyState(ui, newvalue != null && newvalue); - } + ui.addPropertyChangeListener(ObserveMainUI.PROPERTY_BUSY, evt -> { + Boolean newvalue = (Boolean) evt.getNewValue(); + updateBusyState(ui, newvalue != null && newvalue); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java index 4469d90..d510064 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java @@ -427,13 +427,7 @@ public class UIHelper extends SwingUtil { ui.getSplitpane2().revalidate(); // affichage de l'interface graphique - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - ui.setVisible(true); - } - }); + SwingUtilities.invokeLater(() -> ui.setVisible(true)); } public static <E extends IdDto> E getEntity(List<E> list, E entity) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java index 539315e..a2b63f3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java @@ -23,6 +23,8 @@ package fr.ird.observe.ui.actions; */ import fr.ird.observe.ObserveRunner; +import fr.ird.observe.ui.ObserveMainUI; +import fr.ird.observe.ui.UIHelper; import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.AboutPanel; import org.nuiton.util.Resource; @@ -32,14 +34,12 @@ import javax.swing.Icon; import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JScrollPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.io.File; import java.net.MalformedURLException; -import static org.nuiton.i18n.I18n.t;import fr.ird.observe.ui.*; +import static org.nuiton.i18n.I18n.t; /** * Created on 1/17/15. @@ -115,12 +115,7 @@ public class ShowAboutAction extends AbstractAction { } translateArea.setText(translateText); translatePane.getViewport().add(translateArea); - translateArea.addHyperlinkListener(new HyperlinkListener() { - @Override - public void hyperlinkUpdate(HyperlinkEvent e) { - UIHelper.openLink(e); - } - }); + translateArea.addHyperlinkListener(e -> UIHelper.openLink(e)); about.getTabs().add(t("observe.about.translate.title"), translatePane); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java index f5ae63e..a43774d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java @@ -139,13 +139,7 @@ public class ShowConfigAction extends AbstractAction { helper.setFinalizer(new MainCallBackFinalizer(ObserveUICallback.application.name())); - helper.setCloseAction(new Runnable() { - - @Override - public void run() { - ObserveMainUIHandler.restartEdit(); - } - }); + helper.setCloseAction(() -> ObserveMainUIHandler.restartEdit()); // categorie repertoires addDirectoriesOptions(helper); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CancelCreateUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CancelCreateUIAction.java index 79d0b7e..79b6d18 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CancelCreateUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CancelCreateUIAction.java @@ -55,22 +55,18 @@ public class CancelCreateUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - ui.stopEdit(); - ObserveNode parentNode = ui.getTreeHelper().removeNode(ui.getTreeHelper().getSelectedNode()); - ui.getTreeHelper().selectNode(parentNode); + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); } + ui.stopEdit(); + ObserveNode parentNode = ui.getTreeHelper().removeNode(ui.getTreeHelper().getSelectedNode()); + ui.getTreeHelper().selectNode(parentNode); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseAndCreateUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseAndCreateUIAction.java index 0a9f397..912c66b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseAndCreateUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseAndCreateUIAction.java @@ -65,97 +65,93 @@ public class CloseAndCreateUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - if (ui instanceof ContentOpenableUI) { - ((ContentOpenableUI<?>) ui).closeAndCreateData(); - return; - } - - if (ui instanceof ActivitySeinesUI) { + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } + if (ui instanceof ContentOpenableUI) { + ((ContentOpenableUI<?>) ui).closeAndCreateData(); + return; + } - // cas particulier pour l'écran des activitys + if (ui instanceof ActivitySeinesUI) { - JTree tree = getMainUI().getNavigation(); - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + // cas particulier pour l'écran des activitys - boolean wasCollapsed = isOpenActivityNodeCollapsed( - tree, - treeHelper, - getMainUI().getDataContext() - ); + JTree tree = getMainUI().getNavigation(); + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - // selection du noeud de l'activity ouverte - treeHelper.selectOpenNode(getMainUI(), ActivitySeineDto.class); + boolean wasCollapsed = isOpenActivityNodeCollapsed( + tree, + treeHelper, + getMainUI().getDataContext() + ); - // on conserve le path de l'activity - TreePath path = tree.getSelectionPath(); + // selection du noeud de l'activity ouverte + treeHelper.selectOpenNode(getMainUI(), ActivitySeineDto.class); - // recuperation de l'écran associé - ActivitySeineUI selectedUI = (ActivitySeineUI) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + // on conserve le path de l'activity + TreePath path = tree.getSelectionPath(); - // fermeture de l'activity et création d'une nouvelle - selectedUI.closeAndCreateData(); + // recuperation de l'écran associé + ActivitySeineUI selectedUI = (ActivitySeineUI) + ObserveSwingApplicationContext.get().getSelectedContentUI(); - if (wasCollapsed) { + // fermeture de l'activity et création d'une nouvelle + selectedUI.closeAndCreateData(); - // on ferme le noeud de l'activity (qui a ete ouvert - // lors de la selection de celle-ci) - tree.collapsePath(path); - } + if (wasCollapsed) { - return; + // on ferme le noeud de l'activity (qui a ete ouvert + // lors de la selection de celle-ci) + tree.collapsePath(path); } - if (ui instanceof ActivityLonglinesUI) { + return; + } - // cas particulier pour l'écran des activitys + if (ui instanceof ActivityLonglinesUI) { - JTree tree = getMainUI().getNavigation(); - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + // cas particulier pour l'écran des activitys - boolean wasCollapsed = isOpenActivityNodeCollapsed( - tree, - treeHelper, - getMainUI().getDataContext() - ); + JTree tree = getMainUI().getNavigation(); + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - // selection du noeud de l'activity ouverte - treeHelper.selectOpenNode(getMainUI(), ActivityLonglineDto.class); + boolean wasCollapsed = isOpenActivityNodeCollapsed( + tree, + treeHelper, + getMainUI().getDataContext() + ); - // on conserve le path de l'activity - TreePath path = tree.getSelectionPath(); + // selection du noeud de l'activity ouverte + treeHelper.selectOpenNode(getMainUI(), ActivityLonglineDto.class); - // recuperation de l'écran associé - ActivityLonglineUI selectedUI = (ActivityLonglineUI) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + // on conserve le path de l'activity + TreePath path = tree.getSelectionPath(); - // fermeture de l'activity et création d'une nouvelle - selectedUI.closeAndCreateData(); + // recuperation de l'écran associé + ActivityLonglineUI selectedUI = (ActivityLonglineUI) + ObserveSwingApplicationContext.get().getSelectedContentUI(); - if (wasCollapsed) { + // fermeture de l'activity et création d'une nouvelle + selectedUI.closeAndCreateData(); - // on ferme le noeud de l'activity (qui a ete ouvert - // lors de la selection de celle-ci) - tree.collapsePath(path); - } + if (wasCollapsed) { - return; + // on ferme le noeud de l'activity (qui a ete ouvert + // lors de la selection de celle-ci) + tree.collapsePath(path); } - throw new IllegalStateException("Can not come here!"); + return; } + + throw new IllegalStateException("Can not come here!"); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseOpenUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseOpenUIAction.java index 5855416..28c6e02 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseOpenUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/CloseOpenUIAction.java @@ -66,110 +66,106 @@ public class CloseOpenUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (ui instanceof ContentOpenableUI) { - ((ContentOpenableUI<?>) ui).closeData(); - return; - } - - if (ui instanceof ActivitySeinesUI) { + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } - // cas particulier pour l'écran des activités + if (ui instanceof ContentOpenableUI) { + ((ContentOpenableUI<?>) ui).closeData(); + return; + } - JTree tree = getMainUI().getNavigation(); - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + if (ui instanceof ActivitySeinesUI) { - // recuperation du noeud courant (activitys) - ObserveNode node = treeHelper.getSelectedNode(); + // cas particulier pour l'écran des activités - boolean wasCollapsed = isOpenActivityNodeCollapsed( - tree, - treeHelper, - getMainUI().getDataContext() - ); + JTree tree = getMainUI().getNavigation(); + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - // selection du noeud de l'activity ouverte - treeHelper.selectOpenNode(getMainUI(), ActivitySeineDto.class); + // recuperation du noeud courant (activitys) + ObserveNode node = treeHelper.getSelectedNode(); - // on conserve le path de l'activity - TreePath path = tree.getSelectionPath(); + boolean wasCollapsed = isOpenActivityNodeCollapsed( + tree, + treeHelper, + getMainUI().getDataContext() + ); - // recuperation de l'écran associé - ActivitySeineUI selectedUI = (ActivitySeineUI) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + // selection du noeud de l'activity ouverte + treeHelper.selectOpenNode(getMainUI(), ActivitySeineDto.class); - // fermeture de l'activity - selectedUI.closeData(); + // on conserve le path de l'activity + TreePath path = tree.getSelectionPath(); - if (wasCollapsed) { + // recuperation de l'écran associé + ActivitySeineUI selectedUI = (ActivitySeineUI) + ObserveSwingApplicationContext.get().getSelectedContentUI(); - // on ferme le noeud de l'activity (qui a ete ouvert - // lors de la selection de celle-ci) - tree.collapsePath(path); - } + // fermeture de l'activity + selectedUI.closeData(); - // retour sur le noeud des activitys - treeHelper.selectNode(node); + if (wasCollapsed) { - return; + // on ferme le noeud de l'activity (qui a ete ouvert + // lors de la selection de celle-ci) + tree.collapsePath(path); } - if (ui instanceof ActivityLonglinesUI) { + // retour sur le noeud des activitys + treeHelper.selectNode(node); - // cas particulier pour l'écran des activités + return; + } - JTree tree = getMainUI().getNavigation(); - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + if (ui instanceof ActivityLonglinesUI) { - // recuperation du noeud courant (activitys) - ObserveNode node = treeHelper.getSelectedNode(); + // cas particulier pour l'écran des activités - boolean wasCollapsed = isOpenActivityNodeCollapsed( - tree, - treeHelper, - getMainUI().getDataContext() - ); + JTree tree = getMainUI().getNavigation(); + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - // selection du noeud de l'activity ouverte - treeHelper.selectOpenNode(getMainUI(), ActivityLonglineDto.class); + // recuperation du noeud courant (activitys) + ObserveNode node = treeHelper.getSelectedNode(); - // on conserve le path de l'activity - TreePath path = tree.getSelectionPath(); + boolean wasCollapsed = isOpenActivityNodeCollapsed( + tree, + treeHelper, + getMainUI().getDataContext() + ); - // recuperation de l'écran associé - ActivityLonglineUI selectedUI = (ActivityLonglineUI) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + // selection du noeud de l'activity ouverte + treeHelper.selectOpenNode(getMainUI(), ActivityLonglineDto.class); - // fermeture de l'activity - selectedUI.closeData(); + // on conserve le path de l'activity + TreePath path = tree.getSelectionPath(); - if (wasCollapsed) { + // recuperation de l'écran associé + ActivityLonglineUI selectedUI = (ActivityLonglineUI) + ObserveSwingApplicationContext.get().getSelectedContentUI(); - // on ferme le noeud de l'activity (qui a ete ouvert - // lors de la selection de celle-ci) - tree.collapsePath(path); - } + // fermeture de l'activity + selectedUI.closeData(); - // retour sur le noeud des activitys - treeHelper.selectNode(node); + if (wasCollapsed) { - return; + // on ferme le noeud de l'activity (qui a ete ouvert + // lors de la selection de celle-ci) + tree.collapsePath(path); } - throw new IllegalStateException("Can not come here!"); + // retour sur le noeud des activitys + treeHelper.selectNode(node); + + return; } + + throw new IllegalStateException("Can not come here!"); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteDataUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteDataUIAction.java index 7957f2a..68188c7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteDataUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteDataUIAction.java @@ -57,29 +57,24 @@ public class DeleteDataUIAction extends AbstractUIAction { getMainUI().setBusy(true); - SwingUtilities.invokeLater(new Runnable() { + SwingUtilities.invokeLater(() -> { + try { - @Override - @SuppressWarnings("unchecked") - public void run() { - try { - - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - - ui.delete(); - } finally { - getMainUI().setBusy(false); + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); } + + ui.delete(); + } finally { + getMainUI().setBusy(false); } + }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteReferenceUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteReferenceUIAction.java index 044a45b..744da68 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteReferenceUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/DeleteReferenceUIAction.java @@ -54,25 +54,20 @@ public class DeleteReferenceUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { + SwingUtilities.invokeLater(() -> { + try { + JComponent c = (JComponent) e.getSource(); - @Override - @SuppressWarnings("unchecked") - public void run() { - try { - JComponent c = (JComponent) e.getSource(); - - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - ui.delete(); - } finally { - getMainUI().setBusy(false); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); } + ui.delete(); + } finally { + getMainUI().setBusy(false); } }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoDownUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoDownUIAction.java index 9fbf6bb..24a0124 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoDownUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoDownUIAction.java @@ -65,20 +65,16 @@ public class GoDownUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - JPopupMenu p = (JPopupMenu) - c.getClientProperty("popup"); - if (p == null) { - throw new IllegalStateException( - "could not find client property " + - "popup on component" + c); - } - p.show(c, 2, c.getHeight()); + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + JPopupMenu p = (JPopupMenu) + c.getClientProperty("popup"); + if (p == null) { + throw new IllegalStateException( + "could not find client property " + + "popup on component" + c); } + p.show(c, 2, c.getHeight()); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoUpUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoUpUIAction.java index 33ec231..880fde6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoUpUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/GoUpUIAction.java @@ -66,19 +66,15 @@ public class GoUpUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - JPopupMenu p = (JPopupMenu) c.getClientProperty("popup"); - if (p == null) { - throw new IllegalStateException( - "could not find client property " + - "popup on component" + c); - } - p.show(c, 2, c.getHeight()); + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + JPopupMenu p = (JPopupMenu) c.getClientProperty("popup"); + if (p == null) { + throw new IllegalStateException( + "could not find client property " + + "popup on component" + c); } + p.show(c, 2, c.getHeight()); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java index 35c42cc..513cc93 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivityLonglinesUIAction.java @@ -78,46 +78,42 @@ public class MoveActivityLonglinesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof ActivityLonglinesUI)) { - throw new IllegalStateException("Can not come here!"); - } - ActivityLonglinesUI activityLonglinesUI = (ActivityLonglinesUI) ui; + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } + if (!(ui instanceof ActivityLonglinesUI)) { + throw new IllegalStateException("Can not come here!"); + } + ActivityLonglinesUI activityLonglinesUI = (ActivityLonglinesUI) ui; - // get current triplongline id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); - ObserveNode oldTripLonglineNode = oldActivitiesNode.getParent(); - String oldTripLonglineId = oldTripLonglineNode.getId(); - // choose the new tripLongline - String tripLonglineId = chooseNewTripLongline(ui, oldTripLonglineNode); + // get current triplongline id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); + ObserveNode oldTripLonglineNode = oldActivitiesNode.getParent(); + String oldTripLonglineId = oldTripLonglineNode.getId(); - if (tripLonglineId != null) { - // change the tripLongline of the selected activities - List<DataReference<ActivityLonglineDto>> selectedDatas = activityLonglinesUI.getModel().getSelectedDatas(); - List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - ActivityLonglineService service = ObserveSwingApplicationContext.get().newService(ActivityLonglineService.class); - List<Integer> positions = service.moveActivityLonglinesToTripLongline(activityIds, tripLonglineId); + // choose the new tripLongline + String tripLonglineId = chooseNewTripLongline(ui, oldTripLonglineNode); - // update the tree - updateTree(oldActivitiesNode, oldTripLonglineId, tripLonglineId, activityIds, positions); - } + if (tripLonglineId != null) { + // change the tripLongline of the selected activities + List<DataReference<ActivityLonglineDto>> selectedDatas = activityLonglinesUI.getModel().getSelectedDatas(); + List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + ActivityLonglineService service = ObserveSwingApplicationContext.get().newService(ActivityLonglineService.class); + List<Integer> positions = service.moveActivityLonglinesToTripLongline(activityIds, tripLonglineId); + // update the tree + updateTree(oldActivitiesNode, oldTripLonglineId, tripLonglineId, activityIds, positions); } + }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java index 7879784..3effde9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveActivitySeinesUIAction.java @@ -79,44 +79,40 @@ public class MoveActivitySeinesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof ActivitySeinesUI)) { - throw new IllegalStateException("Can not come here!"); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } - // get current route id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); - ObserveNode oldRouteNode = oldActivitiesNode.getParent(); - String oldRouteId = oldRouteNode.getId(); + if (!(ui instanceof ActivitySeinesUI)) { + throw new IllegalStateException("Can not come here!"); + } - // choose the new route - String routeId = chooseNewRoute(ui, oldRouteNode); + // get current route id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldActivitiesNode = treeHelper.getSelectedNode(); + ObserveNode oldRouteNode = oldActivitiesNode.getParent(); + String oldRouteId = oldRouteNode.getId(); - if (routeId != null) { - // change the route of the selected activities - List<DataReference<ActivitySeineDto>> selectedDatas = ((ActivitySeinesUIModel) ui.getModel()).getSelectedDatas(); - List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - ActivitySeineService service = ObserveSwingApplicationContext.get().newService(ActivitySeineService.class); - List<Integer> positions = service.moveActivitySeinesToRoute(activityIds, routeId); + // choose the new route + String routeId = chooseNewRoute(ui, oldRouteNode); - // update the tree - updateTree(oldActivitiesNode, oldRouteId, routeId, activityIds, positions); - } + if (routeId != null) { + // change the route of the selected activities + List<DataReference<ActivitySeineDto>> selectedDatas = ((ActivitySeinesUIModel) ui.getModel()).getSelectedDatas(); + List<String> activityIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + ActivitySeineService service = ObserveSwingApplicationContext.get().newService(ActivitySeineService.class); + List<Integer> positions = service.moveActivitySeinesToRoute(activityIds, routeId); + // update the tree + updateTree(oldActivitiesNode, oldRouteId, routeId, activityIds, positions); } + }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java index 550af9c..c435d91 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveRoutesUIAction.java @@ -78,46 +78,42 @@ public class MoveRoutesUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - - if (!(ui instanceof RoutesUI)) { - throw new IllegalStateException("Can not come here!"); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } - RoutesUI theUi = (RoutesUI) ui; + if (!(ui instanceof RoutesUI)) { + throw new IllegalStateException("Can not come here!"); + } - // get current tripseine id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldRoutesNode = treeHelper.getSelectedNode(); - ObserveNode oldTripSeineNode = oldRoutesNode.getParent(); - String oldTripSeineId = oldTripSeineNode.getId(); + RoutesUI theUi = (RoutesUI) ui; - // choose the new tripseine - String tripSeineId = chooseNewTripSeine(theUi, oldTripSeineNode); + // get current tripseine id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldRoutesNode = treeHelper.getSelectedNode(); + ObserveNode oldTripSeineNode = oldRoutesNode.getParent(); + String oldTripSeineId = oldTripSeineNode.getId(); - if (tripSeineId != null) { - // change the tripseine of the selected routes - List<DataReference<RouteDto>> selectedDatas = theUi.getModel().getSelectedDatas(); - List<String> routeIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - RouteService service = ObserveSwingApplicationContext.get().newService(RouteService.class); - List<Integer> positions = service.moveRoutesToTripSeine(routeIds, tripSeineId); + // choose the new tripseine + String tripSeineId = chooseNewTripSeine(theUi, oldTripSeineNode); - // update the tree - updateTree(oldRoutesNode, oldTripSeineId, tripSeineId, routeIds, positions); - } + if (tripSeineId != null) { + // change the tripseine of the selected routes + List<DataReference<RouteDto>> selectedDatas = theUi.getModel().getSelectedDatas(); + List<String> routeIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + RouteService service = ObserveSwingApplicationContext.get().newService(RouteService.class); + List<Integer> positions = service.moveRoutesToTripSeine(routeIds, tripSeineId); + // update the tree + updateTree(oldRoutesNode, oldTripSeineId, tripSeineId, routeIds, positions); } + }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java index 9cc6e93..b4e3eff 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java @@ -78,41 +78,37 @@ public abstract class MoveTripsUIAction<T extends DataDto> extends AbstractUIAct @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); + } - checkUIClass(ui); + checkUIClass(ui); - // get current program id - ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); - ObserveNode oldProgramNode = treeHelper.getSelectedNode(); - String oldProgramId = oldProgramNode.getId(); + // get current program id + ObserveTreeHelper treeHelper = getMainUI().getTreeHelper(); + ObserveNode oldProgramNode = treeHelper.getSelectedNode(); + String oldProgramId = oldProgramNode.getId(); - // choose the new program - String programId = chooseNewProgram(ui, oldProgramId); + // choose the new program + String programId = chooseNewProgram(ui, oldProgramId); - if (programId != null) { + if (programId != null) { - // change the program of the selected trips - List<DataReference<T>> selectedDatas = ((ContentListUIModel) ui.getModel()).getSelectedDatas(); - List<String> tripIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); - List<Integer> positions = getPositions(tripIds, programId); - - // update the tree - updateTree(ui, oldProgramNode, oldProgramId, programId, tripIds, positions); - } + // change the program of the selected trips + List<DataReference<T>> selectedDatas = ((ContentListUIModel) ui.getModel()).getSelectedDatas(); + List<String> tripIds = Lists.transform(selectedDatas, DataReference.getIdFunction()); + List<Integer> positions = getPositions(tripIds, programId); + // update the tree + updateTree(ui, oldProgramNode, oldProgramId, programId, tripIds, positions); } + }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ReOpenUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ReOpenUIAction.java index e427021..1466597 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ReOpenUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ReOpenUIAction.java @@ -60,47 +60,43 @@ public class ReOpenUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - - if (ui == null) { - throw new IllegalStateException( - "could not find client property ui " + - "on component" + c); - } + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + + if (ui == null) { + throw new IllegalStateException( + "could not find client property ui " + + "on component" + c); + } - ContentOpenableUI<?> openUI; + ContentOpenableUI<?> openUI; - if (ui instanceof ContentOpenableUI<?>) { + if (ui instanceof ContentOpenableUI<?>) { - openUI = (ContentOpenableUI<?>) ui; - } else if (ui instanceof ContentListUI<?, ?>) { + openUI = (ContentOpenableUI<?>) ui; + } else if (ui instanceof ContentListUI<?, ?>) { - DataReference<?> selectedData = ((ContentListUI<?, ?>) ui).getSelectedData(); + DataReference<?> selectedData = ((ContentListUI<?, ?>) ui).getSelectedData(); - String id = selectedData.getId(); + String id = selectedData.getId(); - ObserveTreeHelper treeHelper = ui.getTreeHelper(); - ObserveNode selectedNode = treeHelper.getSelectedNode(); - ObserveNode node = treeHelper.findNode(selectedNode, id); + ObserveTreeHelper treeHelper = ui.getTreeHelper(); + ObserveNode selectedNode = treeHelper.getSelectedNode(); + ObserveNode node = treeHelper.findNode(selectedNode, id); - treeHelper.selectNode(node); + treeHelper.selectNode(node); - openUI = (ContentOpenableUI<?>) - ObserveSwingApplicationContext.get().getSelectedContentUI(); + openUI = (ContentOpenableUI<?>) + ObserveSwingApplicationContext.get().getSelectedContentUI(); - } else { - throw new IllegalStateException("The action " + ACTION_NAME + " can not be executed from ui " + ui); - } + } else { + throw new IllegalStateException("The action " + ACTION_NAME + " can not be executed from ui " + ui); + } - if (openUI != null) { - openUI.openData(); - } + if (openUI != null) { + openUI.openData(); } }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ResetEditUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ResetEditUIAction.java index 7c31625..dc7bee7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ResetEditUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/ResetEditUIAction.java @@ -54,21 +54,16 @@ public class ResetEditUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - @SuppressWarnings("unchecked") - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - ui.resetEdit(); + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); } + ui.resetEdit(); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/SaveEditUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/SaveEditUIAction.java index 706d5c1..f103fb8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/SaveEditUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/SaveEditUIAction.java @@ -54,21 +54,16 @@ public class SaveEditUIAction extends AbstractUIAction { @Override public void actionPerformed(final ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - @SuppressWarnings("unchecked") - public void run() { - JComponent c = (JComponent) e.getSource(); - ContentUI<?> ui = (ContentUI<?>) - c.getClientProperty("ui"); - if (ui == null) { - throw new IllegalStateException( - "could not find client property " + - "ui on component" + c); - } - ui.save(true); + SwingUtilities.invokeLater(() -> { + JComponent c = (JComponent) e.getSource(); + ContentUI<?> ui = (ContentUI<?>) + c.getClientProperty("ui"); + if (ui == null) { + throw new IllegalStateException( + "could not find client property " + + "ui on component" + c); } + ui.save(true); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java index c02d2bd..1630f7d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUILauncher.java @@ -206,12 +206,7 @@ public class AdminUILauncher extends WizardUILancher<AdminStep, AdminUIModel, Ad mainUI.setMode(ObserveUIMode.SYNCHRO); // refresh selected tab (otherwise it does NOT display (white screen...) - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - ui.getTabs().getSelectedComponent().validate(); - } - }); + SwingUtilities.invokeLater(() -> ui.getTabs().getSelectedComponent().validate()); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index a31455a..4f474a1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -60,7 +60,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.util.ArrayList; @@ -125,10 +124,85 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { /** la liste des modes disponibles en entrée */ protected EnumSet<DbMode> availableIncomingModes; - PropertyChangeListener listenStepChanged = new PropertyChangeListener() { + private final PropertyChangeListener listenStepChanged; - @Override - public void propertyChange(PropertyChangeEvent evt) { + private final PropertyChangeListener listenSelectModified; + + private final PropertyChangeListener listenValidationModified; + + private final PropertyChangeListener listenReportModified; + + private final PropertyChangeListener listenerSelectedDataForReport; + + private final PropertyChangeListener listenConsolidateModified; + + private final PropertyChangeListener listenSaveLocalChanged; + + + public AdminUIModel() { + super(AdminStep.class); + + localSourceModel = new StorageUIModel() { + + @Override + public String getLabel() { + String txt = n("observe.storage.label.synchro.incoming"); + String params; + + if (getDbMode() == DbMode.USE_SERVER) { + params = t("observe.storage.server.db") + " " + getRemoteUrl(); + } else if (getDbMode() == DbMode.USE_REMOTE) { + params = t("observe.storage.remote.db") + " " + getRemoteUrl(); + } else { + params = t("observe.storage.locale.db") + " " + getH2Config().getDirectory().getAbsolutePath(); + } + txt = t(txt, params); + return txt; + } + + @Override + public void validate() { + super.validate(); + + // on declanche la revalidation du modèle + firePropertyChange(VALID_PROPERTY_NAME, isValid()); + } + + }; + + centralSourceModel = new StorageUIModel() { + + @Override + public String getLabel() { + String txt; + String params; + txt = n("observe.storage.label.synchro.referentiel"); + if (getDbMode() == DbMode.CREATE_LOCAL) { + params = getH2Config().getDirectory().getAbsolutePath(); + } else { + params = getRemoteUrl(); + } + txt = t(txt, params); + return txt; + } + + @Override + public void validate() { + super.validate(); + + // on declanche la revalidation du modèle + firePropertyChange(VALID_PROPERTY_NAME, isValid()); + } + }; + + selectionDataModel = new DataSelectionModel(); + + availableIncomingModes = EnumSet.noneOf(DbMode.class); + + if (log.isDebugEnabled()) { + log.debug("model [" + this + "] is instanciate."); + } + listenStepChanged = evt -> { if (isWasStarted()) { @@ -198,13 +272,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { // } ObserveSwingDataSource dataSource = getSafeLocalSource(true); populateSelectionModel(dataSource); - } - }; - - PropertyChangeListener listenSelectModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenSelectModified = evt -> { DataSelectionModel source = (DataSelectionModel) evt.getSource(); if (log.isDebugEnabled()) { log.debug("selection data model [" + source + "] changed on " + @@ -219,13 +288,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { // on declanche la revalidation du modèle firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); - } - }; - - PropertyChangeListener listenValidationModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenValidationModified = evt -> { ValidateModel source = (ValidateModel) evt.getSource(); if (log.isDebugEnabled()) { log.debug("validation model [" + source + "] changed on " + @@ -239,13 +303,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { ); } firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); - } - }; - - PropertyChangeListener listenReportModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenReportModified = evt -> { ReportModel source = (ReportModel) evt.getSource(); if (log.isDebugEnabled()) { log.debug("report model [" + source + "] changed on " + @@ -254,13 +313,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } validate(); firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); - } - }; - - PropertyChangeListener listenerSelectedDataForReport = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenerSelectedDataForReport = evt -> { // la modification de la sélection entraine la suppression d'un report sélectionné getReportModel().setSelectedReport(null); @@ -268,13 +322,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { // cela entraine aussi la modification de la marée sélectionnée firePropertyChange(SELECTED_TRIP_PROPERTY_NAME, getSelectedTrip()); - } - }; - - PropertyChangeListener listenConsolidateModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenConsolidateModified = evt -> { ConsolidateModel source = (ConsolidateModel) evt.getSource(); if (log.isDebugEnabled()) { log.debug("consolidate model [" + source + "] changed on " + @@ -283,13 +332,8 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { } validate(); firePropertyChange(VALID_STEP_PROPERTY_NAME, validStep); - } - }; - - PropertyChangeListener listenSaveLocalChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + listenSaveLocalChanged = evt -> { String propertyName = evt.getPropertyName(); @@ -312,73 +356,7 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { if (log.isDebugEnabled()) { log.debug("Skip property " + propertyName); } - } - }; - - - public AdminUIModel() { - super(AdminStep.class); - - localSourceModel = new StorageUIModel() { - - @Override - public String getLabel() { - String txt = n("observe.storage.label.synchro.incoming"); - String params; - - if (getDbMode() == DbMode.USE_SERVER) { - params = t("observe.storage.server.db") + " " + getRemoteUrl(); - } else if (getDbMode() == DbMode.USE_REMOTE) { - params = t("observe.storage.remote.db") + " " + getRemoteUrl(); - } else { - params = t("observe.storage.locale.db") + " " + getH2Config().getDirectory().getAbsolutePath(); - } - txt = t(txt, params); - return txt; - } - - @Override - public void validate() { - super.validate(); - - // on declanche la revalidation du modèle - firePropertyChange(VALID_PROPERTY_NAME, isValid()); - } - }; - - centralSourceModel = new StorageUIModel() { - - @Override - public String getLabel() { - String txt; - String params; - txt = n("observe.storage.label.synchro.referentiel"); - if (getDbMode() == DbMode.CREATE_LOCAL) { - params = getH2Config().getDirectory().getAbsolutePath(); - } else { - params = getRemoteUrl(); - } - txt = t(txt, params); - return txt; - } - - @Override - public void validate() { - super.validate(); - - // on declanche la revalidation du modèle - firePropertyChange(VALID_PROPERTY_NAME, isValid()); - } - }; - - selectionDataModel = new DataSelectionModel(); - - availableIncomingModes = EnumSet.noneOf(DbMode.class); - - if (log.isDebugEnabled()) { - log.debug("model [" + this + "] is instanciate."); - } } public DataSelectionModel getSelectionDataModel() { @@ -621,18 +599,14 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { centralSourceModel.start(DbMode.USE_REMOTE); if (log.isDebugEnabled()) { - centralSourceModel.addPropertyChangeListener(new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - Object oldValue = evt.getOldValue(); - Object newValue = evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); - } - + centralSourceModel.addPropertyChangeListener(evt -> { + String name = evt.getPropertyName(); + Object oldValue = evt.getOldValue(); + Object newValue = evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); } + }); } @@ -744,18 +718,14 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { localSourceModel.start(dbMode); if (log.isDebugEnabled()) { - localSourceModel.addPropertyChangeListener(new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - Object oldValue = evt.getOldValue(); - Object newValue = evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); - } - + localSourceModel.addPropertyChangeListener(evt -> { + String name = evt.getPropertyName(); + Object oldValue = evt.getOldValue(); + Object newValue = evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); } + }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java index 92d26de..bc5ad7c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java @@ -40,11 +40,9 @@ import jaxx.runtime.swing.wizard.ext.WizardState; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Date; import java.util.Set; -import java.util.concurrent.Callable; import static org.nuiton.i18n.I18n.t; @@ -84,21 +82,17 @@ public class ConsolidateUIHandler extends AdminTabUIHandler { final SelectDataUI selectTabUI = (SelectDataUI) ui.getStepUI(AdminStep.SELECT_DATA); - PropertyChangeListener listener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - AdminUIModel model = (AdminUIModel) evt.getSource(); - if (!model.containsStep(selectTabUI.getStep())) { - // avoid multi-cast - return; - } - DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug("selection model changed to " + value); - } - updateSelectionModel(selectTabUI); + PropertyChangeListener listener = evt -> { + AdminUIModel model1 = (AdminUIModel) evt.getSource(); + if (!model1.containsStep(selectTabUI.getStep())) { + // avoid multi-cast + return; + } + DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("selection model changed to " + value); } + updateSelectionModel(selectTabUI); }; tabUI.getModel().addPropertyChangeListener( AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, @@ -108,16 +102,7 @@ public class ConsolidateUIHandler extends AdminTabUIHandler { public void startAction() { - addAdminWorker( - ((ConsolidateUI) ui).getStartButton().getToolTipText(), - new Callable<WizardState>() { - - @Override - public WizardState call() throws Exception { - return doAction(); - } - } - ); + addAdminWorker(((ConsolidateUI) ui).getStartButton().getToolTipText(), () -> doAction()); } public WizardState doAction() throws Exception { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java index 6e6b40b..704b093 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java @@ -59,9 +59,6 @@ import javax.swing.table.DefaultTableCellRenderer; import java.awt.Component; import java.awt.Font; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.io.File; import java.util.List; import java.util.Map; @@ -84,16 +81,11 @@ public class ReportUIHandler extends AdminTabUIHandler { private static final TimeLog timeLog = new TimeLog(ReportUIHandler.class, 0, 1000); - final Runnable revalidateTabUI = new Runnable() { - - @Override - public void run() { - getUi().revalidate(); - } - }; + private final Runnable revalidateTabUI; public ReportUIHandler(AdminTabUI ui) { super(ui); + revalidateTabUI = () -> getUi().revalidate(); } public void initTabUI(AdminUI ui, final ReportUI tabUI) { @@ -109,44 +101,33 @@ public class ReportUIHandler extends AdminTabUIHandler { UIHelper.setLayerUI(tabUI.getContent(), ui.getConfigBlockLayerUI()); ReportModel stepModel = getStepModel(); - stepModel.addPropertyChangeListener(new PropertyChangeListener() { + stepModel.addPropertyChangeListener(evt -> { - @SuppressWarnings({"unchecked"}) - @Override - public void propertyChange(PropertyChangeEvent evt) { + if (getModel().getModelState() == WizardState.CANCELED) { - if (getModel().getModelState() == WizardState.CANCELED) { - - // action annulée, on ne declanche plus rien - return; - } - String propertyName = evt.getPropertyName(); - Object newValue = evt.getNewValue(); - - final ReportModel source = (ReportModel) evt.getSource(); - - if (ReportModel.REPORTS_PROPERTY_NAME.equals(propertyName)) { - List<?> reports = (List<?>) newValue; - onReportsChanged(tabUI, reports); - } else if (ReportModel.SELECTED_REPORT_PROPERTY_NAME.equals(propertyName)) { - Report report = (Report) newValue; - onSelectedReportChanged(tabUI, source, report); - } else if (ReportModel.VARIABLES_PROPERTY_NAME.equals(propertyName)) { - Map<String, Object> variables = - (Map<String, Object>) newValue; - onVariablesChanges(source, variables); - } else if (ReportModel.VALID_PROPERTY_NAME.equals(propertyName)) { - final Boolean valid = (Boolean) newValue; - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - onValidChanged(source, valid != null && valid); - } - }); + // action annulée, on ne declanche plus rien + return; + } + String propertyName = evt.getPropertyName(); + Object newValue = evt.getNewValue(); + + final ReportModel source = (ReportModel) evt.getSource(); + + if (ReportModel.REPORTS_PROPERTY_NAME.equals(propertyName)) { + List<?> reports = (List<?>) newValue; + onReportsChanged(tabUI, reports); + } else if (ReportModel.SELECTED_REPORT_PROPERTY_NAME.equals(propertyName)) { + Report report = (Report) newValue; + onSelectedReportChanged(tabUI, source, report); + } else if (ReportModel.VARIABLES_PROPERTY_NAME.equals(propertyName)) { + Map<String, Object> variables = + (Map<String, Object>) newValue; + onVariablesChanges(source, variables); + } else if (ReportModel.VALID_PROPERTY_NAME.equals(propertyName)) { + final Boolean valid = (Boolean) newValue; + SwingUtilities.invokeLater(() -> onValidChanged(source, valid != null && valid)); - } } }); @@ -217,24 +198,20 @@ public class ReportUIHandler extends AdminTabUIHandler { configUI.getExtraConfig().add(extraConfig); final SelectDataUI selectTabUI = (SelectDataUI) ui.getStepUI(AdminStep.SELECT_DATA); - ui.getModel().addPropertyChangeListener(AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, new PropertyChangeListener() { + ui.getModel().addPropertyChangeListener(AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, evt -> { + AdminUIModel model1 = (AdminUIModel) evt.getSource(); + if (!model1.containsStep(selectTabUI.getStep())) { - @Override - public void propertyChange(PropertyChangeEvent evt) { - AdminUIModel model = (AdminUIModel) evt.getSource(); - if (!model.containsStep(selectTabUI.getStep())) { - - // avoid multi-cast - return; - } + // avoid multi-cast + return; + } - DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug("selection model changed to " + value.getDatas()); - log.debug("IS USE DATA ? : " + value.isUseData()); - } - updateSelectionModel(selectTabUI); + DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("selection model changed to " + value.getDatas()); + log.debug("IS USE DATA ? : " + value.isUseData()); } + updateSelectionModel(selectTabUI); }); } @@ -374,27 +351,23 @@ public class ReportUIHandler extends AdminTabUIHandler { combo.init((JXPathDecorator<Object>) decorator, universe); JComboBox jComboBox = combo.getCombobox(); jComboBox.putClientProperty(VARIABLE_NAME, variableName); - jComboBox.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { + jComboBox.addItemListener(e -> { - JComboBox comboBox = (JComboBox) e.getSource(); + JComboBox comboBox = (JComboBox) e.getSource(); - if (e.getStateChange() == ItemEvent.DESELECTED) { + if (e.getStateChange() == ItemEvent.DESELECTED) { - // ne rien faire de l'évènement de déselection - // sauf si le modèle devient vide + // ne rien faire de l'évènement de déselection + // sauf si le modèle devient vide - if (comboBox.getSelectedItem() == null) { - updateVariable(comboBox, null); - } - return; + if (comboBox.getSelectedItem() == null) { + updateVariable(comboBox, null); } - - Object o = e.getItem(); - updateVariable(comboBox, o); + return; } + + Object o = e.getItem(); + updateVariable(comboBox, o); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java index 48bdea7..a8818f4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java @@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.AbstractReference; import fr.ird.observe.services.dto.DataReference; @@ -42,7 +43,6 @@ import fr.ird.observe.services.service.actions.validate.ValidateResultForDtos; import fr.ird.observe.services.service.actions.validate.ValidateService; import fr.ird.observe.services.service.actions.validate.ValidationMessage; import fr.ird.observe.services.service.actions.validate.ValidatorDto; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.admin.AdminStep; import fr.ird.observe.ui.admin.AdminTabUI; @@ -70,8 +70,6 @@ import javax.swing.JCheckBox; import javax.swing.JTable; import javax.swing.RowSorter; import javax.swing.SortOrder; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -80,7 +78,6 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.Callable; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -155,54 +152,46 @@ public class ValidateUIHandler extends AdminTabUIHandler { final SelectDataUI selectTabUI = (SelectDataUI) ui.getStepUI(AdminStep.SELECT_DATA); - getModel().getValidateModel().addPropertyChangeListener(ValidateModel.PROPERTY_MODEL_MODE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - ValidationModelMode value = (ValidationModelMode) evt.getNewValue(); - if (value == null) { - // rien a faire pour le moment... - return; - } - DataSelectionModel selectDataModel; - selectDataModel = selectTabUI.getSelectDataModel(); - if (log.isDebugEnabled()) { - log.debug("validation model changed to " + value); - } - switch (value) { - case REFERENTIEL: - - selectDataModel.setUseData(false); - selectDataModel.setUseReferentiel(true); - break; - case DATA: - selectDataModel.setUseData(true); - selectDataModel.setUseReferentiel(false); - break; - case ALL: - selectDataModel.setUseData(true); - selectDataModel.setUseReferentiel(true); - break; - } - //updateModel(); + getModel().getValidateModel().addPropertyChangeListener(ValidateModel.PROPERTY_MODEL_MODE, evt -> { + ValidationModelMode value = (ValidationModelMode) evt.getNewValue(); + if (value == null) { + // rien a faire pour le moment... + return; + } + DataSelectionModel selectDataModel; + selectDataModel = selectTabUI.getSelectDataModel(); + if (log.isDebugEnabled()) { + log.debug("validation model changed to " + value); + } + switch (value) { + case REFERENTIEL: + + selectDataModel.setUseData(false); + selectDataModel.setUseReferentiel(true); + break; + case DATA: + selectDataModel.setUseData(true); + selectDataModel.setUseReferentiel(false); + break; + case ALL: + selectDataModel.setUseData(true); + selectDataModel.setUseReferentiel(true); + break; } + //updateModel(); }); - selectTabUI.getModel().addPropertyChangeListener(AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - AdminUIModel model = (AdminUIModel) evt.getSource(); - if (!model.containsStep(selectTabUI.getStep())) { - // avoid multi-cast - return; - } - DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); - if (log.isInfoEnabled()) { - log.info("selection model changed to " + value); - } - updateSelectionModel(selectTabUI); + selectTabUI.getModel().addPropertyChangeListener(AdminUIModel.SELECTION_MODEL_CHANGED_PROPERTY_NAME, evt -> { + AdminUIModel model1 = (AdminUIModel) evt.getSource(); + if (!model1.containsStep(selectTabUI.getStep())) { + // avoid multi-cast + return; + } + DataSelectionModel value = (DataSelectionModel) evt.getNewValue(); + if (log.isInfoEnabled()) { + log.info("selection model changed to " + value); } + updateSelectionModel(selectTabUI); }); ImmutableSet<ValidatorDto> validators = ObserveSwingApplicationContext.get().getValidators(); @@ -332,16 +321,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { public void startAction() { - addAdminWorker( - ((ValidateUI) ui).getStartButton().getToolTipText(), - new Callable<WizardState>() { - - @Override - public WizardState call() throws Exception { - return doAction(); - } - } - ); + addAdminWorker(((ValidateUI) ui).getStartButton().getToolTipText(), this::doAction); } public WizardState doAction() throws Exception { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index 4084704..3c657ee 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -27,6 +27,9 @@ import com.google.common.collect.Lists; import fr.ird.observe.ObserveOpenDataManager; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.ObserveSwingTechnicalException; +import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; +import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constants.DataContextType; @@ -42,15 +45,12 @@ import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.dto.referential.ReferentialReferenceSet; import fr.ird.observe.services.dto.referential.ReferentialReferences; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.actions.shared.AbstractUIAction; import fr.ird.observe.ui.content.ref.ContentReferenceUIHandler; import fr.ird.observe.ui.tree.AbstractObserveTreeCellRenderer; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; -import fr.ird.observe.application.swing.decoration.decorators.DataReferenceDecorator; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXContext; import jaxx.runtime.swing.JAXXButtonGroup; @@ -77,8 +77,6 @@ import javax.swing.JOptionPane; import javax.swing.JToolBar; import javax.swing.UIManager; import java.awt.Component; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -290,13 +288,7 @@ public abstract class ContentUIHandler<E extends IdDto> { final ContentUIInitializer<E, ObserveContentUI<E>> uiInitializer = new ContentUIInitializer<>(ui); uiInitializer.initUI(); - getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateUiWithReferenceSetsFromModel(); - } - }); + getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, evt -> updateUiWithReferenceSetsFromModel()); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java index c88ac61..b695eb1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java @@ -40,7 +40,6 @@ import org.nuiton.i18n.I18n; import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JOptionPane; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -57,20 +56,18 @@ public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { static private Log log = LogFactory.getLog(BranchlineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + protected final TableModelListener computeTabValidStateListener; private Decorator<BranchlineDto> branchlineDecorator; public BranchlineUIHandler(BranchlineUI ui) { super(ui, DataContextType.SetLongline, null); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; } public void edit(BranchlineDto branchline) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java index c03c0f8..b422328 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java @@ -28,14 +28,14 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constants.DataContextType; -import fr.ird.observe.services.dto.longline.SectionTemplate; -import fr.ird.observe.services.dto.longline.SectionWithTemplate; -import fr.ird.observe.services.dto.longline.SectionWithTemplates; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; import fr.ird.observe.services.dto.longline.BasketDto; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.SectionDto; +import fr.ird.observe.services.dto.longline.SectionTemplate; +import fr.ird.observe.services.dto.longline.SectionWithTemplate; +import fr.ird.observe.services.dto.longline.SectionWithTemplates; import fr.ird.observe.services.dto.longline.SetLonglineDetailCompositionDto; import fr.ird.observe.services.dto.longline.SetLonglineDetailCompositionDtos; import fr.ird.observe.services.dto.result.SaveResultDto; @@ -54,11 +54,8 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComboBox; import javax.swing.JOptionPane; -import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -81,107 +78,27 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong /** Logger */ static private Log log = LogFactory.getLog(LonglineDetailCompositionUIHandler.class); - private final PropertyChangeListener sectionTemplatesTableModelModified = new PropertyChangeListener() { + private final PropertyChangeListener sectionTemplatesTableModelModified; - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onSectionTemplatesTableModelModified(newValue); - } - }; + private final PropertyChangeListener sectionsTableModelModified; - private final PropertyChangeListener sectionsTableModelModified = new PropertyChangeListener() { + private final TableModelListener sectionsTableModelChanged; - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onSectionsTableModelModified(newValue); - } - }; + private final PropertyChangeListener branchlineDetailChanged; - private final TableModelListener sectionsTableModelChanged = new TableModelListener() { + private final PropertyChangeListener selectedSectionTemplateChanged; - @Override - public void tableChanged(TableModelEvent e) { - SectionsTableModel source = (SectionsTableModel) e.getSource(); - onSectionsTableModelChanged(source.getData()); - } - }; + private final PropertyChangeListener basketsTableModelModified; - private final PropertyChangeListener branchlineDetailChanged = new PropertyChangeListener() { + private final TableModelListener basketsTableModelChanged; - @Override - public void propertyChange(PropertyChangeEvent evt) { + private final PropertyChangeListener branchinesTableModelModified; - getUi().getValidator().setChanged(true); + private final TableModelListener branchinesTableModelChanged; - } - }; - - private final PropertyChangeListener selectedSectionTemplateChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - SectionTemplate newValue = (SectionTemplate) evt.getNewValue(); - onSelectedSectionTemplateChanged(newValue); - } - }; - - private final PropertyChangeListener basketsTableModelModified = new PropertyChangeListener() { + private final PropertyChangeListener selectedBranchlineChanged; - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onBasketsTableModelModified(newValue); - } - }; - - private final TableModelListener basketsTableModelChanged = new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - BasketsTableModel source = (BasketsTableModel) e.getSource(); - onBasketsTableModelChanged(source.getData()); - } - }; - - private final PropertyChangeListener branchinesTableModelModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onBranchlinesTableModelModified((Boolean) evt.getNewValue()); - } - }; - - private final TableModelListener branchinesTableModelChanged = new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - BranchlinesTableModel source = (BranchlinesTableModel) e.getSource(); - onBranchlinesTableModelChanged(source.getData()); - } - }; - - private final PropertyChangeListener selectedBranchlineChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - BranchlineDto previousValue = (BranchlineDto) evt.getOldValue(); - BranchlineDto newValue = (BranchlineDto) evt.getNewValue(); - onSelectedBranchlineChanged(previousValue, newValue); - } - }; - - private final ChangeListener tabbedPaneChanged = new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - JVetoableTabbedPane source = (JVetoableTabbedPane) e.getSource(); - int previousIndex = source.getPreviousIndex(); - int selectedIndex = source.getSelectedIndex(); - onTabChanged(previousIndex, selectedIndex); - } - }; + private final ChangeListener tabbedPaneChanged; private Decorator<SectionDto> sectionDecorator; @@ -209,10 +126,70 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong */ private boolean sectionAdjusting; - private final PropertyChangeListener modelCanGenerateChanged = new PropertyChangeListener() { + private final PropertyChangeListener modelCanGenerateChanged; + + private final PropertyChangeListener selectedSectionChanged; + + /** + * To avoid branchline flush when basket is adjusting (used when changing selected basket). + */ + private boolean basketAdjusting; + + private final PropertyChangeListener selectedBasketChanged; + + private LonglineDetailCompositionUIValidationHelper validationHelper; + + /** + * To avoid some checks while opening ui. + */ + private boolean onOpen; - @Override - public void propertyChange(PropertyChangeEvent evt) { + private JVetoableTabbedPane.ChangeSelectedIndex tabbedPaneWillChanged; + + public LonglineDetailCompositionUIHandler(LonglineDetailCompositionUI ui) { + super(ui, DataContextType.ActivityLongline, DataContextType.SetLongline); + sectionTemplatesTableModelModified = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onSectionTemplatesTableModelModified(newValue); + }; + sectionsTableModelModified = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onSectionsTableModelModified(newValue); + }; + sectionsTableModelChanged = e -> { + SectionsTableModel source = (SectionsTableModel) e.getSource(); + onSectionsTableModelChanged(source.getData()); + }; + branchlineDetailChanged = evt -> getUi().getValidator().setChanged(true); + selectedSectionTemplateChanged = evt -> { + SectionTemplate newValue = (SectionTemplate) evt.getNewValue(); + onSelectedSectionTemplateChanged(newValue); + }; + basketsTableModelModified = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onBasketsTableModelModified(newValue); + }; + basketsTableModelChanged = e -> { + BasketsTableModel source = (BasketsTableModel) e.getSource(); + onBasketsTableModelChanged(source.getData()); + }; + branchinesTableModelModified = evt -> onBranchlinesTableModelModified((Boolean) evt.getNewValue()); + branchinesTableModelChanged = e -> { + BranchlinesTableModel source = (BranchlinesTableModel) e.getSource(); + onBranchlinesTableModelChanged(source.getData()); + }; + selectedBranchlineChanged = evt -> { + BranchlineDto previousValue = (BranchlineDto) evt.getOldValue(); + BranchlineDto newValue = (BranchlineDto) evt.getNewValue(); + onSelectedBranchlineChanged(previousValue, newValue); + }; + tabbedPaneChanged = e -> { + JVetoableTabbedPane source = (JVetoableTabbedPane) e.getSource(); + int previousIndex = source.getPreviousIndex(); + int selectedIndex = source.getSelectedIndex(); + onTabChanged(previousIndex, selectedIndex); + }; + modelCanGenerateChanged = evt -> { sectionAdjusting = true; @@ -223,13 +200,8 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong sectionAdjusting = false; } - } - }; - - private final PropertyChangeListener selectedSectionChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + selectedSectionChanged = evt -> { sectionAdjusting = true; @@ -241,18 +213,8 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong sectionAdjusting = false; } - } - }; - - /** - * To avoid branchline flush when basket is adjusting (used when changing selected basket). - */ - private boolean basketAdjusting; - - private final PropertyChangeListener selectedBasketChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { + }; + selectedBasketChanged = evt -> { basketAdjusting = true; @@ -264,26 +226,8 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong basketAdjusting = false; } - } - }; - - private LonglineDetailCompositionUIValidationHelper validationHelper; - - /** - * To avoid some checks while opening ui. - */ - private boolean onOpen; - - private JVetoableTabbedPane.ChangeSelectedIndex tabbedPaneWillChanged = new JVetoableTabbedPane.ChangeSelectedIndex() { - - @Override - public boolean canChangeTab(int currentSelectedIndex, int newSelectedIndex) { - return onTabWillChanged(currentSelectedIndex, newSelectedIndex); - } - }; - - public LonglineDetailCompositionUIHandler(LonglineDetailCompositionUI ui) { - super(ui, DataContextType.ActivityLongline, DataContextType.SetLongline); + }; + tabbedPaneWillChanged = this::onTabWillChanged; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java index 6a4e926..ef26032 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java @@ -22,14 +22,13 @@ package fr.ird.observe.ui.content.impl.longline; * #L% */ -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import fr.ird.observe.services.dto.longline.SectionWithTemplate; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.services.dto.longline.BasketDto; import fr.ird.observe.services.dto.longline.BranchlineDto; import fr.ird.observe.services.dto.longline.SectionDto; -import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.services.dto.longline.SectionWithTemplate; import fr.ird.observe.ui.util.ObserveSwingValidatorMessageTableModel; import jaxx.runtime.validator.swing.SwingValidator; import jaxx.runtime.validator.swing.SwingValidatorMessage; @@ -158,13 +157,10 @@ public class LonglineDetailCompositionUIValidationHelper { } public void removeOldMessages() { - errorTableModel.removeMessages(new Predicate<SwingValidatorMessage>() { - @Override - public boolean apply(SwingValidatorMessage input) { - SimpleBeanValidator<?> validator = input.getValidator(); - boolean remove = validators.contains(validator); - return remove; - } + errorTableModel.removeMessages(input -> { + SimpleBeanValidator<?> validator = input.getValidator(); + boolean remove = validators.contains(validator); + return remove; }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java index e736167..dc8d10a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java @@ -48,9 +48,7 @@ import org.nuiton.jaxx.widgets.gis.CoordinateFormat; import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditorModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.HashSet; import java.util.Set; @@ -69,36 +67,13 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { static private Log log = LogFactory.getLog(SetLonglineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + protected final TableModelListener computeTabValidStateListener; // Change toogle target visible on all TimeEditors - protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onToogleTimeEditorSliderChanged(newValue); - } - }; + protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener; // Change toogle target visible on all TimeEditors - protected final PropertyChangeListener onCoordinateFormatChangedListener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - CoordinateFormat newValue = (CoordinateFormat) evt.getNewValue(); - onCoordinateFormatChanged(newValue); - } - }; + protected final PropertyChangeListener onCoordinateFormatChangedListener; // private final LogPropertyChanges logCoordinatesChanges; @@ -123,6 +98,20 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { public SetLonglineUIHandler(SetLonglineUI ui) { super(ui, DataContextType.ActivityLongline, DataContextType.SetLongline); // this.logCoordinatesChanges = new LogPropertyChanges(COORDINATES_PROPERTIES); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + onToogleTimeEditorSliderChangedListener = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onToogleTimeEditorSliderChanged(newValue); + }; + onCoordinateFormatChangedListener = evt -> { + CoordinateFormat newValue = (CoordinateFormat) evt.getNewValue(); + onCoordinateFormatChanged(newValue); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java index 0d4681c..f6bfced 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java @@ -308,13 +308,10 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH break; } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { + SwingUtilities.invokeLater(() -> { - // recalcul de la disposition - getUi().revalidate(); - } + // recalcul de la disposition + getUi().revalidate(); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java index fbf03ab..4611e2c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java @@ -50,9 +50,7 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.util.DateUtil; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Date; import java.util.HashSet; @@ -70,29 +68,25 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { static private Log log = LogFactory.getLog(SetSeineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + protected final TableModelListener computeTabValidStateListener; // Change toogle target visible on all TimeEditors - protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onToogleTimeEditorSliderChanged(newValue); - } - }; + protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener; protected boolean toogleTimeEditorSliderIsChanging; public SetSeineUIHandler(SetSeineUI ui) { super(ui, DataContextType.ActivitySeine, DataContextType.SetSeine); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + onToogleTimeEditorSliderChangedListener = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onToogleTimeEditorSliderChanged(newValue); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIModel.java index 7f450c0..7978825 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIModel.java @@ -29,8 +29,6 @@ import fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDt import fr.ird.observe.ui.content.open.ContentOpenableUIModel; import org.nuiton.util.DateUtil; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Date; /** @@ -52,13 +50,10 @@ public class ActivityLonglineUIModel extends ContentOpenableUIModel<ActivityLong public ActivityLonglineUIModel() { super(ActivityLonglineDto.class); - getBean().addPropertyChangeListener(ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - boolean oldValue = VesselActivityLonglineDtos.isSetOperation((ReferentialReference<VesselActivityLonglineDto>) evt.getOldValue()); - boolean newValue = VesselActivityLonglineDtos.isSetOperation((ReferentialReference<VesselActivityLonglineDto>) evt.getNewValue()); - firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue); - } + getBean().addPropertyChangeListener(ActivityLonglineDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, evt -> { + boolean oldValue = VesselActivityLonglineDtos.isSetOperation((ReferentialReference<VesselActivityLonglineDto>) evt.getOldValue()); + boolean newValue = VesselActivityLonglineDtos.isSetOperation((ReferentialReference<VesselActivityLonglineDto>) evt.getNewValue()); + firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java index 62e4374..113daa5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java @@ -46,8 +46,6 @@ import org.nuiton.util.DateUtil; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.util.Collection; import java.util.Date; import java.util.LinkedList; @@ -100,36 +98,28 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline tripMap.getHandler().setConfig(config); - getUi().getTripLonglineTabPane().addChangeListener(new ChangeListener() { + getUi().getTripLonglineTabPane().addChangeListener(e -> { + JTabbedPane tripLonglineTabPane = (JTabbedPane) e.getSource(); + TripLonglineUI ui1 = getUi(); + TripMapUI tripMap1 = ui1.getTripMap(); + if (tripLonglineTabPane.getSelectedComponent().equals(tripMap1)) { + ui1.getActions().setVisible(false); - @Override - public void stateChanged(ChangeEvent e) { - JTabbedPane tripLonglineTabPane = (JTabbedPane) e.getSource(); - TripLonglineUI ui = getUi(); - TripMapUI tripMap = ui.getTripMap(); - if (tripLonglineTabPane.getSelectedComponent().equals(tripMap)) { - ui.getActions().setVisible(false); + if (buildTripMap) { + SwingUtilities.invokeLater(() -> { - if (buildTripMap) { - SwingUtilities.invokeLater(new Runnable() { + TripLonglineUI ui11 = getUi(); + TripMapUI tripMap11 = ui11.getTripMap(); - @Override - public void run() { + TripMapDto tripLonglineMap = getTripLonglineService().getTripLonglineMap(getSelectedId()); - TripLonglineUI ui = getUi(); - TripMapUI tripMap = ui.getTripMap(); - - TripMapDto tripLonglineMap = getTripLonglineService().getTripLonglineMap(getSelectedId()); - - tripMap.getHandler().doOpenMap(tripLonglineMap); - } - }); - buildTripMap = false; - } - - } else { - ui.getActions().setVisible(true); + tripMap11.getHandler().doOpenMap(tripLonglineMap); + }); + buildTripMap = false; } + + } else { + ui1.getActions().setVisible(true); } }); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java index cbcdceb..4e52fbd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java @@ -42,7 +42,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -60,16 +59,7 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei static private Log log = LogFactory.getLog(ActivitySeineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + protected final TableModelListener computeTabValidStateListener; // static ImmutableSet<String> COORDINATES_PROPERTIES = ImmutableSet.of(ActivitySeine.PROPERTY_QUADRANT, // ActivitySeine.PROPERTY_LATITUDE, @@ -84,6 +74,12 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei DataContextType.ActivitySeine, n("observe.activitySeine.message.not.open")); // this.logCoordinatesChanges = new LogPropertyChanges(COORDINATES_PROPERTIES); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIModel.java index 27b97cd..912a676 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIModel.java @@ -29,8 +29,6 @@ import fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDtos; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.ui.content.open.ContentOpenableUIModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Set; /** @@ -75,21 +73,18 @@ public class ActivitySeineUIModel extends ContentOpenableUIModel<ActivitySeineDt public ActivitySeineUIModel() { super(ActivitySeineDto.class); - getBean().addPropertyChangeListener(ActivitySeineDto.PROPERTY_VESSEL_ACTIVITY_SEINE, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - ReferentialReference<VesselActivitySeineDto> oldActivitySeine = (ReferentialReference<VesselActivitySeineDto>) evt.getOldValue(); - ReferentialReference<VesselActivitySeineDto> newActivitySeine = (ReferentialReference<VesselActivitySeineDto>) evt.getNewValue(); - { - boolean oldValue = VesselActivitySeineDtos.isSetOperation(oldActivitySeine); - boolean newValue = VesselActivitySeineDtos.isSetOperation(newActivitySeine); - firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue); - } - { - boolean oldValue = VesselActivitySeineDtos.isChangedZoneOperation(oldActivitySeine); - boolean newValue = VesselActivitySeineDtos.isChangedZoneOperation(newActivitySeine); - firePropertyChange(PROPERTY_CHANGED_ZONE_OPERATION, oldValue, newValue); - } + getBean().addPropertyChangeListener(ActivitySeineDto.PROPERTY_VESSEL_ACTIVITY_SEINE, evt -> { + ReferentialReference<VesselActivitySeineDto> oldActivitySeine = (ReferentialReference<VesselActivitySeineDto>) evt.getOldValue(); + ReferentialReference<VesselActivitySeineDto> newActivitySeine = (ReferentialReference<VesselActivitySeineDto>) evt.getNewValue(); + { + boolean oldValue = VesselActivitySeineDtos.isSetOperation(oldActivitySeine); + boolean newValue = VesselActivitySeineDtos.isSetOperation(newActivitySeine); + firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue); + } + { + boolean oldValue = VesselActivitySeineDtos.isChangedZoneOperation(oldActivitySeine); + boolean newValue = VesselActivitySeineDtos.isChangedZoneOperation(newActivitySeine); + firePropertyChange(PROPERTY_CHANGED_ZONE_OPERATION, oldValue, newValue); } }); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java index fca0e9f..b466d5b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java @@ -45,8 +45,6 @@ import org.nuiton.util.DateUtil; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.util.Collection; import java.util.Date; import java.util.LinkedList; @@ -98,36 +96,28 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { tripMap.getHandler().setConfig(config); - getUi().getTripSeineTabPane().addChangeListener(new ChangeListener() { + getUi().getTripSeineTabPane().addChangeListener(e -> { + JTabbedPane tripSeineTabPane = (JTabbedPane) e.getSource(); + TripSeineUI ui1 = getUi(); + TripMapUI tripMap1 = ui1.getTripMap(); + if (tripSeineTabPane.getSelectedComponent().equals(tripMap1)) { + ui1.getActions().setVisible(false); - @Override - public void stateChanged(ChangeEvent e) { - JTabbedPane tripSeineTabPane = (JTabbedPane) e.getSource(); - TripSeineUI ui = getUi(); - TripMapUI tripMap = ui.getTripMap(); - if (tripSeineTabPane.getSelectedComponent().equals(tripMap)) { - ui.getActions().setVisible(false); + if (buildTripMap) { + SwingUtilities.invokeLater(() -> { - if (buildTripMap) { - SwingUtilities.invokeLater(new Runnable() { + TripSeineUI ui11 = getUi(); + TripMapUI tripMap11 = ui11.getTripMap(); + TripMapDto tripSeineMap = getTripSeineService().getTripSeineMap(getSelectedId()); - @Override - public void run() { - TripSeineUI ui = getUi(); - TripMapUI tripMap = ui.getTripMap(); - TripMapDto tripSeineMap = getTripSeineService().getTripSeineMap(getSelectedId()); - - - tripMap.getHandler().doOpenMap(tripSeineMap); - } - }); - buildTripMap = false; - } - - } else { - ui.getActions().setVisible(true); + tripMap11.getHandler().doOpenMap(tripSeineMap); + }); + buildTripMap = false; } + + } else { + ui1.getActions().setVisible(true); } }); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index c4b8264..f8d412d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -102,29 +102,11 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content private static final Log log = LogFactory.getLog(ContentReferenceUIHandler.class); - final private Runnable revalidate = new Runnable() { + private final Runnable revalidate; - @Override - public void run() { + private final ReferentialContentUIInitializer<E, ContentReferenceUI<E>> uiInitializer; - // revalidate ui layout - ContentReferenceUI<E> ui = getUi(); - Container parent = ui.getParent(); - if (parent == null) { - - // plus de parent donc rien a faire - return; - } - if (log.isDebugEnabled()) { - log.debug("Will revalidate " + parent.getName()); - } - ui.revalidate(); - } - }; - - private ReferentialContentUIInitializer<E, ContentReferenceUI<E>> uiInitializer; - - protected final FastDateFormat dateFormat; + private final FastDateFormat dateFormat; public ContentReferenceUIHandler(ContentReferenceUI<E> ui) { super(ui, null, null); @@ -136,6 +118,21 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content dateFormat = FastDateFormat.getInstance("dd/MM/yyyy"); } + revalidate = () -> { + + // revalidate ui layout + ContentReferenceUI<E> ui1 = getUi(); + Container parent = ui1.getParent(); + if (parent == null) { + + // plus de parent donc rien a faire + return; + } + if (log.isDebugEnabled()) { + log.debug("Will revalidate " + parent.getName()); + } + ui1.revalidate(); + }; } public static <E extends IdDto> void showUsagesForDelete(JAXXContext tx, @@ -146,10 +143,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); String type = DecoratorService.getEntityLabel(entity.getClass()); type = t(type); - String message = t("observe.message.show.usage.for.delete", - type, - decorator.toString(entity) - ); + String message = t("observe.message.show.usage.for.delete", type, decorator.toString(entity)); String message2 = t("observe.message.show.usage.for.delete2"); UsagesUI usagesUI = new UsagesUI(tx); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java index 56a0367..1670939 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class GearUIHandler extends ContentReferenceUIHandler<GearDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public GearUIHandler(ContentReferenceUI<GearDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public GearUIHandler(ContentReferenceUI<GearDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java index 7399a05..02321e3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class LengthWeightParameterUIHandler extends ContentReferenceUIHandler<LengthWeightParameterDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public LengthWeightParameterUIHandler(ContentReferenceUI<LengthWeightParameterDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public LengthWeightParameterUIHandler(ContentReferenceUI<LengthWeightParameterDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java index 589755f..8b66371 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class ProgramUIHandler extends ContentReferenceUIHandler<ProgramDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public ProgramUIHandler(ContentReferenceUI<ProgramDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public ProgramUIHandler(ContentReferenceUI<ProgramDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java index 0368219..a2e36e9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class SpeciesListUIHandler extends ContentReferenceUIHandler<SpeciesListDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public SpeciesListUIHandler(ContentReferenceUI<SpeciesListDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public SpeciesListUIHandler(ContentReferenceUI<SpeciesListDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java index a27368d..5e33dbc 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class SpeciesUIHandler extends ContentReferenceUIHandler<SpeciesDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public SpeciesUIHandler(ContentReferenceUI<SpeciesDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public SpeciesUIHandler(ContentReferenceUI<SpeciesDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java index 2cd4968..593d502 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java @@ -30,7 +30,6 @@ import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import java.util.HashSet; import java.util.Set; @@ -44,18 +43,16 @@ import java.util.Set; public class VesselUIHandler extends ContentReferenceUIHandler<VesselDto> { // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { + protected final TableModelListener computeTabValidStateListener; + + public VesselUIHandler(ContentReferenceUI<VesselDto> ui) { + super(ui); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - public VesselUIHandler(ContentReferenceUI<VesselDto> ui) { - super(ui); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java index f91df9c..100bb68 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java @@ -144,12 +144,7 @@ public class ContentTableMeta<B> implements Serializable { if (propertyDescriptor == null) { Predicate<PropertyDescriptor> predicate = Predicates.and( BeanUtil.IS_READ_DESCRIPTOR, - new Predicate<PropertyDescriptor>() { - @Override - public boolean apply(PropertyDescriptor input) { - return name.equals(input.getName()); - } - }); + input -> name.equals(input.getName())); Set<PropertyDescriptor> descriptors = BeanUtil.getDescriptors(klass, predicate); Preconditions.checkState(!descriptors.isEmpty(), "could not find readable property " + name + " for bean " + klass); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index 0777d3b..86764d1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -52,7 +52,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.TableModelEvent; import javax.swing.table.DefaultTableCellRenderer; import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; import java.util.List; @@ -166,15 +165,11 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex return; } - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - if (!ui.getSelectionModel().isSelectionEmpty()) { - // on veut toujours que la ligne sélectionnée soit visible - Rectangle rect = ui.getTable().getCellRect(ui.getSelectionModel().getAnchorSelectionIndex(), 0, false); - ui.getTable().scrollRectToVisible(rect); - } + SwingUtilities.invokeLater(() -> { + if (!ui.getSelectionModel().isSelectionEmpty()) { + // on veut toujours que la ligne sélectionnée soit visible + Rectangle rect = ui.getTable().getCellRect(ui.getSelectionModel().getAnchorSelectionIndex(), 0, false); + ui.getTable().scrollRectToVisible(rect); } }); @@ -255,13 +250,7 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex new ContentTableUIInitializer<>(getUi()); uiInitializer.initUI(); - getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateUiWithReferenceSetsFromModel(); - } - }); + getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, evt -> updateUiWithReferenceSetsFromModel()); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java index 795652c..4b3cf1a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java @@ -30,17 +30,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; -import javax.swing.*; +import javax.swing.AbstractButton; +import javax.swing.ActionMap; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JTextArea; +import javax.swing.JTextField; import javax.swing.table.DefaultTableCellRenderer; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.BorderLayout; import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; /** * To initialize ui. @@ -106,48 +106,40 @@ public class ContentTableUIInitializer<E extends IdDto, D extends IdDto, UI exte // ajout d'un listener pour preparer l'éditeur d'une entrée selectionnée tableModel.addPropertyChangeListener( ContentTableModel.SELECTED_ROW_PROPERTY, - new PropertyChangeListener() { - - @SuppressWarnings("unchecked") - @Override - public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<E, D> model; - model = (ContentTableModel<E, D>) evt.getSource(); - D bean = model.getRowBean(); - boolean create = bean.getId() == null; - Integer selectedRow = (Integer) evt.getNewValue(); + evt -> { + ContentTableModel<E, D> model; + model = (ContentTableModel<E, D>) evt.getSource(); + D bean = model.getRowBean(); + boolean create = bean.getId() == null; + Integer selectedRow = (Integer) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("callback new selectedRow : " + selectedRow + " : " + bean.getId()); + } + getHandler().onSelectedRowChanged(selectedRow, bean, create); + getModel().setRowSaved(!create); + if (selectedRow == -1) { if (log.isDebugEnabled()) { - log.debug("callback new selectedRow : " + selectedRow + " : " + bean.getId()); + log.debug(">>>>>>>>>> will clear selection..."); } - getHandler().onSelectedRowChanged(selectedRow, bean, create); - getModel().setRowSaved(!create); - if (selectedRow == -1) { - if (log.isDebugEnabled()) { - log.debug(">>>>>>>>>> will clear selection..."); - } - // on supprime la selection - ui.getSelectionModel().clearSelection(); - if (log.isDebugEnabled()) { - log.debug("<<<<<<<<<< has clear selection..."); - } - } else { - // on met a jour le modele de selection - ui.getSelectionModel().setSelectionInterval( - selectedRow, selectedRow); + // on supprime la selection + ui.getSelectionModel().clearSelection(); + if (log.isDebugEnabled()) { + log.debug("<<<<<<<<<< has clear selection..."); } + } else { + // on met a jour le modele de selection + ui.getSelectionModel().setSelectionInterval( + selectedRow, selectedRow); } }); getModel().addPropertyChangeListener( ContentTableUIModel.PROPERTY_SHOW_DATA, - new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { + evt -> { - Boolean newValue = (Boolean) evt.getNewValue(); - onShowDataChanged(newValue); + Boolean newValue = (Boolean) evt.getNewValue(); + onShowDataChanged(newValue); - } }); } @@ -187,12 +179,7 @@ public class ContentTableUIInitializer<E extends IdDto, D extends IdDto, UI exte final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_RESET_TABLE_PROPERTY_NAME); if (propertyName != null) { - editor.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, null); - } - }); + editor.addActionListener(e -> JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, null)); } } @@ -242,12 +229,9 @@ public class ContentTableUIInitializer<E extends IdDto, D extends IdDto, UI exte final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_TABLE_PROPERTY_NAME); if (propertyName != null) { - editor.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent event) { - Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); - JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, newValue); - } + editor.addItemListener(event -> { + Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); + JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, newValue); }); } @@ -260,14 +244,11 @@ public class ContentTableUIInitializer<E extends IdDto, D extends IdDto, UI exte final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_TABLE_PROPERTY_NAME); if (propertyName != null) { - editor.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent event) { - if (event.getStateChange() == ItemEvent.SELECTED) { + editor.addItemListener(event -> { + if (event.getStateChange() == ItemEvent.SELECTED) { - Boolean newValue = ((BooleanEditor) event.getSource()).getBooleanValue(); - JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, newValue); - } + Boolean newValue = ((BooleanEditor) event.getSource()).getBooleanValue(); + JavaBeanObjectUtil.setProperty(getTableEditBean(), propertyName, newValue); } }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java index 9b55b32..01ba8a9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java @@ -33,8 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -96,13 +94,9 @@ public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLongline UIHelper.setTableColumnRenderer(table, 4, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - table.getModel().addTableModelListener(new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - int proportionSum = getBean().getBaitsCompositionProportionSum(); - getBean().setBaitsCompositionProportionSum(proportionSum); - } + table.getModel().addTableModelListener(e -> { + int proportionSum = getBean().getBaitsCompositionProportionSum(); + getBean().setBaitsCompositionProportionSum(proportionSum); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java index 98d6423..ff6c9bf 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java @@ -33,8 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -93,12 +91,9 @@ public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLo UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - table.getModel().addTableModelListener(new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - int proportionSum = getBean().getBranchlinesCompositionProportionSum(); - getBean().setBranchlinesCompositionProportionSum(proportionSum); - } + table.getModel().addTableModelListener(e -> { + int proportionSum = getBean().getBranchlinesCompositionProportionSum(); + getBean().setBranchlinesCompositionProportionSum(proportionSum); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineContentTableUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineContentTableUIInitializer.java index 2fe0e15..20be675 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineContentTableUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineContentTableUIInitializer.java @@ -31,8 +31,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.jaxx.application.bean.JavaBeanObjectUtil; import javax.swing.JCheckBox; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; /** * Created on 3/17/15. @@ -57,12 +55,9 @@ public class CatchLonglineContentTableUIInitializer extends ContentTableUIInitia super.init(editor); final String propertyName = (String) editor.getClientProperty("branchlineBeanPropertyName"); if (propertyName != null) { - editor.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent event) { - Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); - JavaBeanObjectUtil.setProperty(ui.getBranchlineBean(), propertyName, newValue); - } + editor.addItemListener(event -> { + Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); + JavaBeanObjectUtil.setProperty(ui.getBranchlineBean(), propertyName, newValue); }); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java index 37e1932..c22d055 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java @@ -24,6 +24,8 @@ package fr.ird.observe.ui.content.table.impl.longline; import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; +import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.Form; @@ -48,14 +50,12 @@ import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.service.longline.BranchlineService; import fr.ird.observe.services.service.longline.SetLonglineCatchService; import fr.ird.observe.services.service.longline.TripLonglineService; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentUIInitializer; import fr.ird.observe.ui.content.ContentUIModel; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIHandler; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.validator.swing.SwingValidator; import jaxx.runtime.validator.swing.SwingValidatorMessage; @@ -68,10 +68,8 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; @@ -95,62 +93,34 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat static private Log log = LogFactory.getLog(CatchLonglineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { + protected final TableModelListener computeTabValidStateListener; - @Override - public void tableChanged(TableModelEvent e) { + private final PropertyChangeListener catchFateChanged; - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + private final PropertyChangeListener branchlineChanged; - private final PropertyChangeListener catchFateChanged = new PropertyChangeListener() { + private final PropertyChangeListener depredatedChanged; - @Override - public void propertyChange(PropertyChangeEvent evt) { - onCatchFateChanged((ReferentialReference<CatchFateLonglineDto>) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); - } - }; + private final PropertyChangeListener sizeTableModelModified; - private final PropertyChangeListener branchlineChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onBranchlineChanged((DataReference<BranchlineDto>) evt.getNewValue()); - } - }; - - private final PropertyChangeListener depredatedChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onDepretadedChanged((Boolean) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); - } - }; - - private final PropertyChangeListener sizeTableModelModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onSizeTableModelModified((Boolean) evt.getNewValue()); - } - }; - - private final PropertyChangeListener weightTableModelModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onWeightTableModelModified((Boolean) evt.getNewValue()); - } - }; + private final PropertyChangeListener weightTableModelModified; JAXXContextEntryDef<LonglinePositionHelper<CatchLonglineDto>> POSITION_HELPER_ENTRY = UIHelper.newContextEntryDef("CatchLonglineUI-positionHelper", LonglinePositionHelper.class); public CatchLonglineUIHandler(CatchLonglineUI ui) { super(ui, DataContextType.SetLongline); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + catchFateChanged = evt -> onCatchFateChanged((ReferentialReference<CatchFateLonglineDto>) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); + branchlineChanged = evt -> onBranchlineChanged((DataReference<BranchlineDto>) evt.getNewValue()); + weightTableModelModified = evt -> onWeightTableModelModified((Boolean) evt.getNewValue()); + sizeTableModelModified = evt -> onSizeTableModelModified((Boolean) evt.getNewValue()); + depredatedChanged = evt -> onDepretadedChanged((Boolean) evt.getNewValue(), (CatchLonglineDto) evt.getSource()); } @Override @@ -169,31 +139,17 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat final CatchLonglineContentTableUIInitializer uiInitializer = new CatchLonglineContentTableUIInitializer(getUi()); uiInitializer.initUI(); - getModel().addPropertyChangeListener(CatchLonglineUIModel.PROPERTY_SHOW_INDIVIDUAL_TABS, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - showIndividualTabs(newValue); - } + getModel().addPropertyChangeListener(CatchLonglineUIModel.PROPERTY_SHOW_INDIVIDUAL_TABS, evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + showIndividualTabs(newValue); }); - getModel().addPropertyChangeListener(CatchLonglineUIModel.PROPERTY_EDITABLE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - setTableModelEditable(newValue); - } + getModel().addPropertyChangeListener(CatchLonglineUIModel.PROPERTY_EDITABLE, evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + setTableModelEditable(newValue); }); - getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - updateUiWithReferenceSetsFromModel(); - } - }); + getModel().addPropertyChangeListener(ContentUIModel.PROPERTY_FORM, evt -> updateUiWithReferenceSetsFromModel()); setTableModelEditable(getModel().isEditable()); @@ -596,14 +552,10 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat } - getTableModel().addPropertyChangeListener(ContentTableModel.CREATE_PROPERTY, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean oldValue = (Boolean) evt.getOldValue(); - Boolean newValue = (Boolean) evt.getNewValue(); - setTableModelCreate(oldValue, newValue); - } + getTableModel().addPropertyChangeListener(ContentTableModel.CREATE_PROPERTY, evt -> { + Boolean oldValue = (Boolean) evt.getOldValue(); + Boolean newValue = (Boolean) evt.getNewValue(); + setTableModelCreate(oldValue, newValue); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java index 1ad8a3d..db19fbd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java @@ -32,8 +32,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -89,14 +87,10 @@ public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLon UIHelper.setTableColumnRenderer(table, 2, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - table.getModel().addTableModelListener(new TableModelListener() { + table.getModel().addTableModelListener(e -> { - @Override - public void tableChanged(TableModelEvent e) { - - int proportionSum = getBean().getFloatlinesCompositionProportionSum(); - getBean().setFloatlinesCompositionProportionSum(proportionSum); - } + int proportionSum = getBean().getFloatlinesCompositionProportionSum(); + getBean().setFloatlinesCompositionProportionSum(proportionSum); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java index 855be39..0ecce5e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java @@ -22,10 +22,10 @@ package fr.ird.observe.ui.content.table.impl.longline; * #L% */ -import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.Form; @@ -47,7 +47,6 @@ import fr.ird.observe.ui.content.ContentUIInitializer; import fr.ird.observe.ui.content.table.ContentTableUIHandler; import fr.ird.observe.ui.content.table.impl.seine.GearUseFeatureMeasurementCellEditor; import fr.ird.observe.ui.content.table.impl.seine.GearUseFeatureMeasurementCellRenderer; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; @@ -58,12 +57,10 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import java.awt.GridBagConstraints; import java.awt.Insets; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; import java.util.HashSet; @@ -86,27 +83,19 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip static private Log log = LogFactory.getLog(GearUseFeaturesLonglineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { + protected final TableModelListener computeTabValidStateListener; - @Override - public void tableChanged(TableModelEvent e) { + private final PropertyChangeListener measurementsTableModelModified; + + public GearUseFeaturesLonglineUIHandler(GearUseFeaturesLonglineUI ui) { + super(ui, DataContextType.TripLongline); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - private final PropertyChangeListener measurementsTableModelModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onMeasurementsTableModelModified((Boolean) evt.getNewValue()); - } - }; - - public GearUseFeaturesLonglineUIHandler(GearUseFeaturesLonglineUI ui) { - super(ui, DataContextType.TripLongline); + }; + measurementsTableModelModified = evt -> onMeasurementsTableModelModified((Boolean) evt.getNewValue()); } @Override @@ -124,13 +113,9 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip super.initUI(); - getModel().addPropertyChangeListener(GearUseFeaturesLonglineUIModel.PROPERTY_EDITABLE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - setTableModelEditable(newValue); - } + getModel().addPropertyChangeListener(GearUseFeaturesLonglineUIModel.PROPERTY_EDITABLE, evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + setTableModelEditable(newValue); }); setTableModelEditable(getModel().isEditable()); @@ -219,18 +204,14 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip List<GearUseFeaturesMeasurementLonglineDto> measurements = Lists.newArrayList( Iterables.transform(gearDto.getGearCaracteristic(), - new Function<ReferentialReference, GearUseFeaturesMeasurementLonglineDto>() { - - @Override - public GearUseFeaturesMeasurementLonglineDto apply(ReferentialReference input) { - GearUseFeaturesMeasurementLonglineDto measurementLonglineDto = new GearUseFeaturesMeasurementLonglineDto(); - measurementLonglineDto.setGearCaracteristic(input); - String gearCaracterisiticTypeId = (String) input.getPropertyValue(GearCaracteristicDto.PROPERTY_GEAR_CARACTERISTIC_TYPE); - if (GearCaracteristicTypeDtos.isBoolean(gearCaracterisiticTypeId)) { - measurementLonglineDto.setMeasurementValue(Boolean.FALSE.toString()); - } - return measurementLonglineDto; + input -> { + GearUseFeaturesMeasurementLonglineDto measurementLonglineDto = new GearUseFeaturesMeasurementLonglineDto(); + measurementLonglineDto.setGearCaracteristic(input); + String gearCaracterisiticTypeId = (String) input.getPropertyValue(GearCaracteristicDto.PROPERTY_GEAR_CARACTERISTIC_TYPE); + if (GearCaracteristicTypeDtos.isBoolean(gearCaracterisiticTypeId)) { + measurementLonglineDto.setMeasurementValue(Boolean.FALSE.toString()); } + return measurementLonglineDto; })); return measurements; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java index 4e51701..cf8ea37 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java @@ -33,8 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; -import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import static org.nuiton.i18n.I18n.n; @@ -93,12 +91,9 @@ public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLongline UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); // when model change in table, let's recompute the proportion sum - table.getModel().addTableModelListener(new TableModelListener() { - @Override - public void tableChanged(TableModelEvent e) { - int proportionSum = getBean().getHooksCompositionProportionSum(); - getBean().setHooksCompositionProportionSum(proportionSum); - } + table.getModel().addTableModelListener(e -> { + int proportionSum = getBean().getHooksCompositionProportionSum(); + getBean().setHooksCompositionProportionSum(proportionSum); }); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java index d16a103..d1ef627 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java @@ -32,7 +32,6 @@ import fr.ird.observe.services.dto.longline.LonglinePositionSetDto; import fr.ird.observe.services.dto.longline.SectionDto; import jaxx.runtime.swing.editor.bean.BeanComboBox; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; @@ -71,22 +70,10 @@ public class LonglinePositionHelper<D extends LonglinePositionAwareDto> { this.uiBasket = uiBasket; this.uiBranchline = uiBranchline; - PropertyChangeListener sectionChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onSectionChanged((DataReference<SectionDto>) evt.getNewValue(), (D) evt.getSource()); - } - }; + PropertyChangeListener sectionChanged = evt -> onSectionChanged((DataReference<SectionDto>) evt.getNewValue(), (D) evt.getSource()); tableEditBean.addPropertyChangeListener(CatchLonglineDto.PROPERTY_SECTION, sectionChanged); - PropertyChangeListener basketChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onBasketChanged((DataReference<BasketDto>) evt.getNewValue(), (D) evt.getSource()); - } - }; + PropertyChangeListener basketChanged = evt -> onBasketChanged((DataReference<BasketDto>) evt.getNewValue(), (D) evt.getSource()); tableEditBean.addPropertyChangeListener(CatchLonglineDto.PROPERTY_BASKET, basketChanged); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java index 2b8642f..159cc0f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java @@ -54,11 +54,9 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import java.awt.Component; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.IOException; @@ -85,26 +83,10 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt static private Log log = LogFactory.getLog(TdrUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { - - @Override - public void tableChanged(TableModelEvent e) { - - SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); - computeTabValidState(source); - - } - }; + protected final TableModelListener computeTabValidStateListener; // Change toogle target visible on all TimeEditors - protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - onToogleTimeEditorSliderChanged(newValue); - } - }; + protected final PropertyChangeListener onToogleTimeEditorSliderChangedListener; protected boolean toogleTimeEditorSliderIsChanging; @@ -113,6 +95,16 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt public TdrUIHandler(TdrUI ui) { super(ui, DataContextType.SetLongline); + computeTabValidStateListener = e -> { + + SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); + computeTabValidState(source); + + }; + onToogleTimeEditorSliderChangedListener = evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + onToogleTimeEditorSliderChanged(newValue); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java index 0949118..c0f8b43 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java @@ -22,10 +22,10 @@ package fr.ird.observe.ui.content.table.impl.seine; * #L% */ -import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.Form; @@ -45,7 +45,6 @@ import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.ContentMode; import fr.ird.observe.ui.content.ContentUIInitializer; import fr.ird.observe.ui.content.table.ContentTableUIHandler; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import jaxx.runtime.SwingUtil; import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; @@ -56,12 +55,10 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; -import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableCellRenderer; import java.awt.GridBagConstraints; import java.awt.Insets; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collections; import java.util.HashSet; @@ -84,27 +81,19 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei static private Log log = LogFactory.getLog(GearUseFeaturesSeineUIHandler.class); // Compute valid state of tab from the error table - protected final TableModelListener computeTabValidStateListener = new TableModelListener() { + protected final TableModelListener computeTabValidStateListener; - @Override - public void tableChanged(TableModelEvent e) { + private final PropertyChangeListener measurementsTableModelModified; + + public GearUseFeaturesSeineUIHandler(GearUseFeaturesSeineUI ui) { + super(ui, DataContextType.TripSeine); + computeTabValidStateListener = e -> { SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource(); computeTabValidState(source); - } - }; - - private final PropertyChangeListener measurementsTableModelModified = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - onMeasurementsTableModelModified((Boolean) evt.getNewValue()); - } - }; - - public GearUseFeaturesSeineUIHandler(GearUseFeaturesSeineUI ui) { - super(ui, DataContextType.TripSeine); + }; + measurementsTableModelModified = evt -> onMeasurementsTableModelModified((Boolean) evt.getNewValue()); } @Override @@ -122,13 +111,9 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei super.initUI(); - getModel().addPropertyChangeListener(GearUseFeaturesSeineUIModel.PROPERTY_EDITABLE, new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - Boolean newValue = (Boolean) evt.getNewValue(); - setTableModelEditable(newValue); - } + getModel().addPropertyChangeListener(GearUseFeaturesSeineUIModel.PROPERTY_EDITABLE, evt -> { + Boolean newValue = (Boolean) evt.getNewValue(); + setTableModelEditable(newValue); }); setTableModelEditable(getModel().isEditable()); @@ -217,18 +202,14 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei List<GearUseFeaturesMeasurementSeineDto> measurements = Lists.newArrayList( Iterables.transform(gearDto.getGearCaracteristic(), - new Function<ReferentialReference, GearUseFeaturesMeasurementSeineDto>() { - - @Override - public GearUseFeaturesMeasurementSeineDto apply(ReferentialReference input) { - GearUseFeaturesMeasurementSeineDto measurementSeineDto = new GearUseFeaturesMeasurementSeineDto(); - String gearCaracterisiticTypeId = (String) input.getPropertyValue(GearCaracteristicDto.PROPERTY_GEAR_CARACTERISTIC_TYPE); - if (GearCaracteristicTypeDtos.isBoolean(gearCaracterisiticTypeId)) { - measurementSeineDto.setMeasurementValue(Boolean.FALSE.toString()); - } - measurementSeineDto.setGearCaracteristic(input); - return measurementSeineDto; + input -> { + GearUseFeaturesMeasurementSeineDto measurementSeineDto = new GearUseFeaturesMeasurementSeineDto(); + String gearCaracterisiticTypeId = (String) input.getPropertyValue(GearCaracteristicDto.PROPERTY_GEAR_CARACTERISTIC_TYPE); + if (GearCaracteristicTypeDtos.isBoolean(gearCaracterisiticTypeId)) { + measurementSeineDto.setMeasurementValue(Boolean.FALSE.toString()); } + measurementSeineDto.setGearCaracteristic(input); + return measurementSeineDto; })); return measurements; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java index 06dae5f..025a509 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java @@ -25,6 +25,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.db.constants.DataContextType; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.constants.seine.NonTargetCatchComputedValueSource; @@ -44,7 +45,6 @@ import fr.ird.observe.services.service.seine.TripSeineService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIHandler; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -52,7 +52,6 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Collection; @@ -79,14 +78,7 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa * * @since 3.0 */ - protected final PropertyChangeListener totalCountChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); - source.setTotalCountComputedSource(null); - } - }; + protected final PropertyChangeListener totalCountChanged; /** * Ecoute les modifications de la propriété {@link NonTargetCatchDto#getCatchWeight()}, @@ -95,14 +87,7 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa * * @since 3.0 */ - protected final PropertyChangeListener catchWeightChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); - source.setCatchWeightComputedSource(null); - } - }; + protected final PropertyChangeListener catchWeightChanged; /** * Ecoute les modifications de la propriété {@link NonTargetCatchDto#getMeanWeight()}, @@ -111,14 +96,7 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa * * @since 3.0 */ - protected final PropertyChangeListener meanWeightChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); - source.setMeanWeightComputedSource(null); - } - }; + protected final PropertyChangeListener meanWeightChanged; /** * Ecoute les modifications de la propriété {@link NonTargetCatchDto#getMeanLength()}, @@ -127,17 +105,26 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTa * * @since 3.0 */ - protected final PropertyChangeListener meanLengthChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); - source.setMeanLengthComputedSource(null); - } - }; + protected final PropertyChangeListener meanLengthChanged; public NonTargetCatchUIHandler(NonTargetCatchUI ui) { super(ui, DataContextType.SetSeine); + totalCountChanged = evt -> { + NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); + source.setTotalCountComputedSource(null); + }; + catchWeightChanged = evt -> { + NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); + source.setCatchWeightComputedSource(null); + }; + meanWeightChanged = evt -> { + NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); + source.setMeanWeightComputedSource(null); + }; + meanLengthChanged = evt -> { + NonTargetCatchDto source = (NonTargetCatchDto) evt.getSource(); + source.setMeanLengthComputedSource(null); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java index ae767b6..869a802 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java @@ -47,7 +47,6 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.LinkedList; @@ -73,14 +72,7 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam * * @since 3.0 */ - protected final PropertyChangeListener weightChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); - source.setWeightSource(false); - } - }; + protected final PropertyChangeListener weightChanged; /** * Ecoute les modifications de la propriété {@link NonTargetLengthDto#getLength()}, @@ -89,17 +81,18 @@ public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSam * * @since 3.0 */ - protected final PropertyChangeListener lengthChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); - source.setLengthSource(false); - } - }; + protected final PropertyChangeListener lengthChanged; public NonTargetSampleUIHandler(NonTargetSampleUI ui) { super(ui, DataContextType.SetSeine); + weightChanged = evt -> { + NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); + source.setWeightSource(false); + }; + lengthChanged = evt -> { + NonTargetLengthDto source = (NonTargetLengthDto) evt.getSource(); + source.setLengthSource(false); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index b78744e..05427ed 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -52,8 +52,6 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; @@ -91,19 +89,15 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa getUi().getSpecies().addPropertyChangeListener( BeanComboBox.PROPERTY_SELECTED_ITEM, - new PropertyChangeListener() { + evt -> { - @Override - public void propertyChange(PropertyChangeEvent evt) { + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isNewRow()) { - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - if (model.isNewRow()) { + // en mode creation , on doit recalculer la liste des categories + ReferentialReference<SpeciesDto> species = (ReferentialReference<SpeciesDto>) evt.getNewValue(); + onSpeciesChanged(species); - // en mode creation , on doit recalculer la liste des categories - ReferentialReference<SpeciesDto> species = (ReferentialReference<SpeciesDto>) evt.getNewValue(); - onSpeciesChanged(species); - - } } } ); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index 5e66f83..e11f990 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -54,8 +54,6 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; @@ -122,22 +120,18 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT ui.getSpecies().addPropertyChangeListener( BeanComboBox.PROPERTY_SELECTED_ITEM, - new PropertyChangeListener() { + evt -> { - @Override - public void propertyChange(PropertyChangeEvent evt) { + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isNewRow()) { - if (model.isNewRow()) { - - // en mode creation , on doit recalculer la liste des categories - ReferentialReference<SpeciesDto> species = (ReferentialReference<SpeciesDto>) evt.getNewValue(); - onSpeciesChanged(model.getRowBean(), species); - - } + // en mode creation , on doit recalculer la liste des categories + ReferentialReference<SpeciesDto> species = (ReferentialReference<SpeciesDto>) evt.getNewValue(); + onSpeciesChanged(model.getRowBean(), species); } + } ); @@ -147,22 +141,18 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT ui.getWeightCategory().addPropertyChangeListener( BeanComboBox.PROPERTY_SELECTED_ITEM, - new PropertyChangeListener() { + evt -> { - @Override - public void propertyChange(PropertyChangeEvent evt) { + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isNewRow()) { - ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); - if (model.isNewRow()) { - - // en mode creation , on doit recalculer la liste des raison rejet - ReferentialReference<WeightCategoryDto> weightCategory = - (ReferentialReference<WeightCategoryDto>) evt.getNewValue(); - onWeightCategoryChanged(model.getRowBean(), weightCategory); - - } + // en mode creation , on doit recalculer la liste des raison rejet + ReferentialReference<WeightCategoryDto> weightCategory = + (ReferentialReference<WeightCategoryDto>) evt.getNewValue(); + onWeightCategoryChanged(model.getRowBean(), weightCategory); } + } ); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java index 94aca6c..990af33 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java @@ -46,7 +46,6 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Collection; import java.util.LinkedList; @@ -79,14 +78,7 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto * * @since 3.0 */ - protected final PropertyChangeListener weightChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - TargetLengthDto source = (TargetLengthDto) evt.getSource(); - source.setWeightSource(false); - } - }; + protected final PropertyChangeListener weightChanged; /** * Ecoute les modifications de la propriété {@link TargetLengthDto#getLength()}, @@ -95,19 +87,20 @@ public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto * * @since 3.0 */ - protected final PropertyChangeListener lengthChanged = new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - TargetLengthDto source = (TargetLengthDto) evt.getSource(); - source.setLengthSource(false); - } - }; + protected final PropertyChangeListener lengthChanged; public TargetSampleUIHandler(ContentTableUI<TargetSampleDto, TargetLengthDto> ui, boolean discarded) { super(ui, DataContextType.SetSeine); this.discarded = discarded; + weightChanged = evt -> { + TargetLengthDto source = (TargetLengthDto) evt.getSource(); + source.setWeightSource(false); + }; + lengthChanged = evt -> { + TargetLengthDto source = (TargetLengthDto) evt.getSource(); + source.setLengthSource(false); + }; } @Override diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index 4f3a4f2..1c29079 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -28,6 +28,7 @@ import fr.ird.observe.ObserveActionExecutor; import fr.ird.observe.ObserveRunner; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.ObserveTextGenerator; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.db.constants.ConnexionStatus; @@ -45,7 +46,6 @@ import fr.ird.observe.services.dto.DataSourceCreateConfigurationDto; import fr.ird.observe.services.dto.ObserveDbUserDto; import fr.ird.observe.services.service.SqlScriptProducerRequest; import fr.ird.observe.services.service.SqlScriptProducerService; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; @@ -63,8 +63,6 @@ import org.apache.commons.logging.LogFactory; import javax.swing.JTabbedPane; import java.awt.Component; import java.awt.Window; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -140,54 +138,51 @@ public class StorageUIHandler { StorageUIModel model = ui.getModel(); // on écoute les changements d'étapes - model.addPropertyChangeListener(StorageUIModel.STEP_PROPERTY_NAME, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - StorageUIModel model = (StorageUIModel) evt.getSource(); - StorageStep oldStep = (StorageStep) evt.getOldValue(); - StorageStep newStep = (StorageStep) evt.getNewValue(); + model.addPropertyChangeListener(StorageUIModel.STEP_PROPERTY_NAME, evt -> { + StorageUIModel model1 = (StorageUIModel) evt.getSource(); + StorageStep oldStep = (StorageStep) evt.getOldValue(); + StorageStep newStep = (StorageStep) evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug("step has changed <old:" + oldStep + ", new:" + newStep + ">"); + } + int oldStepIndex = oldStep == null ? -1 : model1.getStepIndex(oldStep); + int newStepIndex = model1.getStepIndex(newStep); + JTabbedPane tabs = ui.getTabs(); + if (oldStepIndex + 1 == newStepIndex) { + + // creation d'un nouvel onglet + StorageTabUI c = (StorageTabUI) ui.getObjectById(newStep.name()); + String title = t(newStep.getLabel()); + String tip = t(newStep.getDescription()); + if (log.isDebugEnabled()) { - log.debug("step has changed <old:" + oldStep + ", new:" + newStep + ">"); + log.debug("Create tab " + title + " ui = " + c); } - int oldStepIndex = oldStep == null ? -1 : model.getStepIndex(oldStep); - int newStepIndex = model.getStepIndex(newStep); - JTabbedPane tabs = ui.getTabs(); - if (oldStepIndex + 1 == newStepIndex) { + tabs.addTab(title, null, c, tip); + tabs.setMnemonicAt(newStepIndex, title.charAt(0)); - // creation d'un nouvel onglet - StorageTabUI c = (StorageTabUI) ui.getObjectById(newStep.name()); - String title = t(newStep.getLabel()); - String tip = t(newStep.getDescription()); + // selection du nouvel onglet + int index = tabs.indexOfComponent(c); + if (index > -1) { + tabs.setSelectedIndex(index); + } + ui.onStepChanged(oldStep, newStep); - if (log.isDebugEnabled()) { - log.debug("Create tab " + title + " ui = " + c); - } - tabs.addTab(title, null, c, tip); - tabs.setMnemonicAt(newStepIndex, title.charAt(0)); + } else if (oldStepIndex > newStepIndex) { - // selection du nouvel onglet - int index = tabs.indexOfComponent(c); - if (index > -1) { - tabs.setSelectedIndex(index); - } - ui.onStepChanged(oldStep, newStep); - - } else if (oldStepIndex > newStepIndex) { - - // il s'agit d'un retour en arrière - // on supprime tous les onglets obsoletes - int index = newStepIndex + 1; - while (tabs.getTabCount() > index) { - if (log.isDebugEnabled()) { - log.debug("remove tab : " + index); - } - tabs.remove(index); + // il s'agit d'un retour en arrière + // on supprime tous les onglets obsoletes + int index = newStepIndex + 1; + while (tabs.getTabCount() > index) { + if (log.isDebugEnabled()) { + log.debug("remove tab : " + index); } - - ui.onStepChanged(oldStep, newStep); - } else { - throw new IllegalStateException("can not go from " + oldStep + " to " + newStep); + tabs.remove(index); } + + ui.onStepChanged(oldStep, newStep); + } else { + throw new IllegalStateException("can not go from " + oldStep + " to " + newStep); } }); @@ -295,15 +290,11 @@ public class StorageUIHandler { if (action == null) { final StorageUILauncher launcher = ui.getContextValue(StorageUILauncher.class); - action = new Runnable() { - - @Override - public void run() { - try { - launcher.doAction(ui); - } finally { - launcher.doClose(ui, false); - } + action = () -> { + try { + launcher.doAction(ui); + } finally { + launcher.doClose(ui, false); } }; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java index e4fe0ea..8fda354 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java @@ -62,7 +62,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.version.Version; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileInputStream; @@ -166,6 +165,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { /** * Un drapeau pour savoir si on a déjà lancé l'action Appliquer (pour éviter le code ré-entrant). + * * @since 4.0.4 */ protected boolean alreadyApplied; @@ -214,10 +214,10 @@ public class StorageUIModel extends WizardModel<StorageStep> { protected String serverUrl; - /** Les information de connextion a la base**/ + /** Les information de connextion a la base **/ protected ObserveDataSourceInformation dataSourceInformation; - /** Les information de connextion a la base**/ + /** Les information de connextion a la base **/ protected ObserveDataSourceInformation h2DataSourceInformation; /** le fichier d'import des donné */ @@ -257,9 +257,9 @@ public class StorageUIModel extends WizardModel<StorageStep> { public StorageUIModel() { super(StorageStep.class, - StorageStep.CHOOSE_DB_MODE, - StorageStep.BACKUP, - StorageStep.CONFIRM + StorageStep.CHOOSE_DB_MODE, + StorageStep.BACKUP, + StorageStep.CONFIRM ); selectDataModel = new DataSelectionModel(); securityModel = new SecurityModel(); @@ -302,12 +302,9 @@ public class StorageUIModel extends WizardModel<StorageStep> { modelVersion ); - PropertyChangeListener clearStatus = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - setConnexionStatus(ConnexionStatus.UNTESTED); - dataSourceInformation = null; - } + PropertyChangeListener clearStatus = evt -> { + setConnexionStatus(ConnexionStatus.UNTESTED); + dataSourceInformation = null; }; addPropertyChangeListener(REMOTE_URL_ROPERTY_NAME, clearStatus); @@ -342,7 +339,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { if (log.isDebugEnabled()) { log.debug("from a incoming model " + - incomingModel.getLabel() + " : " + incomingModel); + incomingModel.getLabel() + " : " + incomingModel); } // on initialie a partir d'un autre modèle @@ -406,7 +403,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { // on est actuellement connecte sur une base locale fromStorageConfig((ObserveDataSourceConfigurationTopiaH2) source); - } else if (source instanceof ObserveDataSourceConfigurationTopiaPG){ + } else if (source instanceof ObserveDataSourceConfigurationTopiaPG) { if (!isLocalStorageExist) { // aucune base locale, on positionne le mode de création @@ -418,7 +415,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { // on est sur une base distante fromStorageConfig((ObserveDataSourceConfigurationTopiaPG) source); - } else if (source instanceof ObserveDataSourceConfigurationRest){ + } else if (source instanceof ObserveDataSourceConfigurationRest) { // on est sur une base distante fromStorageConfig((ObserveDataSourceConfigurationRest) source); @@ -513,7 +510,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { // on est actuellement connecte sur une base locale fromStorageConfig((ObserveDataSourceConfigurationTopiaH2) previousConfig); h2DataSourceInformation = previousInfo; - } else if (previousConfig instanceof ObserveDataSourceConfigurationTopiaPG){ + } else if (previousConfig instanceof ObserveDataSourceConfigurationTopiaPG) { if (!isLocalStorageExist) { @@ -524,7 +521,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { // on est sur une base distante fromStorageConfig((ObserveDataSourceConfigurationTopiaPG) previousConfig); - } else if (previousConfig instanceof ObserveDataSourceConfigurationRest){ + } else if (previousConfig instanceof ObserveDataSourceConfigurationRest) { // on est sur une base distante fromStorageConfig((ObserveDataSourceConfigurationRest) previousConfig); @@ -625,17 +622,14 @@ public class StorageUIModel extends WizardModel<StorageStep> { centralSourceModel.start(DbMode.USE_REMOTE); if (log.isDebugEnabled()) { - centralSourceModel.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - Object oldValue = evt.getOldValue(); - Object newValue = evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); - } - + centralSourceModel.addPropertyChangeListener(evt -> { + String name = evt.getPropertyName(); + Object oldValue = evt.getOldValue(); + Object newValue = evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); } + }); } @@ -662,17 +656,14 @@ public class StorageUIModel extends WizardModel<StorageStep> { dataSourceModel.start(DbMode.USE_REMOTE); if (log.isDebugEnabled()) { - dataSourceModel.addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - String name = evt.getPropertyName(); - Object oldValue = evt.getOldValue(); - Object newValue = evt.getNewValue(); - if (log.isDebugEnabled()) { - log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); - } - + dataSourceModel.addPropertyChangeListener(evt -> { + String name = evt.getPropertyName(); + Object oldValue = evt.getOldValue(); + Object newValue = evt.getNewValue(); + if (log.isDebugEnabled()) { + log.debug(evt.getSource() + " - Property [" + name + "] has changed from " + oldValue + " to " + newValue); } + }); } @@ -684,12 +675,12 @@ public class StorageUIModel extends WizardModel<StorageStep> { public boolean isNeedReferentielDataSource() { return adminAction != null && - adminAction == ObstunaAdminAction.CREATE; + adminAction == ObstunaAdminAction.CREATE; } public boolean isNeedDataDataSource() { return adminAction != null && - adminAction == ObstunaAdminAction.CREATE; + adminAction == ObstunaAdminAction.CREATE; } public void start(DbMode dbMode) { @@ -791,9 +782,9 @@ public class StorageUIModel extends WizardModel<StorageStep> { String txt = t("observe.storage.label.import.referentiel"); if (getDbMode() == DbMode.CREATE_LOCAL) { txt = t("observe.storage.label.import.referentiel", getH2Config().getDirectory().getAbsolutePath()); - } else if (isRemote()){ + } else if (isRemote()) { txt = t("observe.storage.label.import.referentiel.remote", getRemoteUrl()); - } else if (isServer()){ + } else if (isServer()) { txt = t("observe.storage.label.import.referentiel.server", getServerUrl()); } return txt; @@ -820,9 +811,9 @@ public class StorageUIModel extends WizardModel<StorageStep> { String txt = t("observe.storage.label.import.data"); if (getDbMode() == DbMode.CREATE_LOCAL) { txt = t("observe.storage.label.import.data", getH2Config().getDirectory().getAbsolutePath()); - } else if (isRemote()){ + } else if (isRemote()) { txt = t("observe.storage.label.import.data.remote", getRemoteUrl()); - } else if (isServer()){ + } else if (isServer()) { txt = t("observe.storage.label.import.data.server", getServerUrl()); } return txt; @@ -957,8 +948,8 @@ public class StorageUIModel extends WizardModel<StorageStep> { if (DbMode.USE_REMOTE.equals(dbMode) || DbMode.USE_SERVER.equals(dbMode) || DbMode.CREATE_LOCAL.equals(dbMode) - && (CreationMode.IMPORT_SERVER_STORAGE.equals(creationMode) - || CreationMode.IMPORT_REMOTE_STORAGE.equals(creationMode))) { + && (CreationMode.IMPORT_SERVER_STORAGE.equals(creationMode) + || CreationMode.IMPORT_REMOTE_STORAGE.equals(creationMode))) { validate = ConnexionStatus.SUCCESS.equals(getConnexionStatus()); //FIXME Il faut savoir si l'utilisateur est le //FIXME propriétaire de la base @@ -1088,7 +1079,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { case CREATE_LOCAL: result = getCreationMode() != null && - validate(StorageStep.CONFIG); + validate(StorageStep.CONFIG); break; case USE_REMOTE: case USE_SERVER: @@ -1115,7 +1106,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { public boolean isUseSelectData() { return getSteps() != null && - getSteps().contains(StorageStep.SELECT_DATA); + getSteps().contains(StorageStep.SELECT_DATA); } public boolean isBackupAction() { @@ -1232,11 +1223,11 @@ public class StorageUIModel extends WizardModel<StorageStep> { boolean oldValueServer = isEditServerConfig(); editRemoteConfig = DbMode.USE_REMOTE.equals(dbMode) || - DbMode.CREATE_LOCAL.equals(dbMode) && CreationMode.IMPORT_REMOTE_STORAGE.equals(creationMode); + DbMode.CREATE_LOCAL.equals(dbMode) && CreationMode.IMPORT_REMOTE_STORAGE.equals(creationMode); firePropertyChange(EDIT_REMOTE_CONFIG_PROPERTY_NAME, oldValueRemote, editRemoteConfig); editServerConfig = DbMode.USE_SERVER.equals(dbMode) || - DbMode.CREATE_LOCAL.equals(dbMode) && CreationMode.IMPORT_SERVER_STORAGE.equals(creationMode); + DbMode.CREATE_LOCAL.equals(dbMode) && CreationMode.IMPORT_SERVER_STORAGE.equals(creationMode); firePropertyChange(EDIT_SERVER_CONFIG_PROPERTY_NAME, oldValueServer, editServerConfig); } @@ -1468,11 +1459,11 @@ public class StorageUIModel extends WizardModel<StorageStep> { if (isEditRemoteConfig()) { - pgConfig.setUsername(remoteLogin); + pgConfig.setUsername(remoteLogin); } else if (isEditServerConfig()) { - restConfig.setLogin(remoteLogin); + restConfig.setLogin(remoteLogin); } @@ -1503,7 +1494,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { public void setCanCreateLocalService(boolean canCreateLocalService) { this.canCreateLocalService = canCreateLocalService; firePgConfigChanged(CAN_CREATE_LOCALE_SERVICE_PROPERTY_NAME, null, - canCreateLocalService); + canCreateLocalService); } public void setCanUseRemoteService(boolean canUseRemoteService) { @@ -1775,7 +1766,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { Version versionDataSource = dataSourceInformation.getVersion(); // en mise a jour de la base on ne test pas la version - if (getModelVersion().equals(versionDataSource) || isCanMigrate() || ObstunaAdminAction.CREATE.equals(adminAction)) { + if (getModelVersion().equals(versionDataSource) || isCanMigrate() || ObstunaAdminAction.CREATE.equals(adminAction)) { setConnexionStatus(ConnexionStatus.SUCCESS); @@ -1879,7 +1870,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { public DataSourceCreateConfigurationDto toImportReferentielSourceConfig() { - DataSourceCreateConfigurationDto importReferenceConfig = new DataSourceCreateConfigurationDto();; + DataSourceCreateConfigurationDto importReferenceConfig = new DataSourceCreateConfigurationDto(); // on peut créer une base vide importReferenceConfig.setCanCreateEmptyDatabase(true); @@ -2007,7 +1998,6 @@ public class StorageUIModel extends WizardModel<StorageStep> { createConfigurationDto.setImportDatabase(bytes); - } catch (Exception e) { throw new RuntimeException("Could not read dump file", e); @@ -2041,7 +2031,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { importDataSource = ObserveSwingApplicationContext.get().newDataSource(dataSourceConfig); } - break; + break; case IMPORT_SERVER_STORAGE: { @@ -2051,7 +2041,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { importDataSource = ObserveSwingApplicationContext.get().newDataSource(dataSourceConfig); } - break; + break; default: throw new IllegalStateException("Can't come here"); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java index 275c4ec..fce5203 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/StorageTabUIHandler.java @@ -52,7 +52,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Window; -import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.util.Date; @@ -96,16 +95,13 @@ public class StorageTabUIHandler { public void initUI(final ChooseDbModeUI ui) { - PropertyChangeListener listener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - StorageUIModel model = (StorageUIModel) evt.getSource(); + PropertyChangeListener listener = evt -> { + StorageUIModel model = (StorageUIModel) evt.getSource(); - ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - ObserveTextGenerator textGenerator = applicationContext.getTextGenerator(); - String txt = textGenerator.getLoadDataSourceResume(model); - ui.getResume().setText(txt); - } + ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); + ObserveTextGenerator textGenerator = applicationContext.getTextGenerator(); + String txt = textGenerator.getLoadDataSourceResume(model); + ui.getResume().setText(txt); }; StorageUIModel model = ui.getModel(); model.addPropertyChangeListener(StorageUIModel.DB_MODE_PROPERTY_NAME, listener); @@ -115,27 +111,24 @@ public class StorageTabUIHandler { public void initUI(final ConfigUI ui) { - PropertyChangeListener listener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - StorageUIModel model = (StorageUIModel) evt.getSource(); - String propertyName = evt.getPropertyName(); - if (StorageUIModel.CREATION_MODE_PROPERTY_NAME.equals(propertyName) || - StorageUIModel.DB_MODE_PROPERTY_NAME.equals(propertyName)) { - String id = null; - if (model.getDbMode() == DbMode.USE_REMOTE) { - id = DbMode.USE_REMOTE.name(); - } else if (model.getDbMode() == DbMode.USE_SERVER) { - id = DbMode.USE_SERVER.name(); - } else { - if (model.getCreationMode() != null) { - id = model.getCreationMode().name(); - } - } - if (id != null) { - refreshConfig(ui, id); + PropertyChangeListener listener = evt -> { + StorageUIModel model = (StorageUIModel) evt.getSource(); + String propertyName = evt.getPropertyName(); + if (StorageUIModel.CREATION_MODE_PROPERTY_NAME.equals(propertyName) || + StorageUIModel.DB_MODE_PROPERTY_NAME.equals(propertyName)) { + String id = null; + if (model.getDbMode() == DbMode.USE_REMOTE) { + id = DbMode.USE_REMOTE.name(); + } else if (model.getDbMode() == DbMode.USE_SERVER) { + id = DbMode.USE_SERVER.name(); + } else { + if (model.getCreationMode() != null) { + id = model.getCreationMode().name(); } } + if (id != null) { + refreshConfig(ui, id); + } } }; ui.getModel().addPropertyChangeListener(listener); @@ -145,14 +138,11 @@ public class StorageTabUIHandler { if (ui.getStep() != null) { ui.setDescriptionText(t(ui.getStep().getDescription())); - PropertyChangeListener listener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - String propertyName = evt.getPropertyName(); - if (StorageUIModel.REFERENTIEL_IMPORT_MODE_PROPERTY_NAME.equals(propertyName)) { - CreationMode id = (CreationMode) evt.getNewValue(); - refreshConfig(ui, id.name()); - } + PropertyChangeListener listener = evt -> { + String propertyName = evt.getPropertyName(); + if (StorageUIModel.REFERENTIEL_IMPORT_MODE_PROPERTY_NAME.equals(propertyName)) { + CreationMode id = (CreationMode) evt.getNewValue(); + refreshConfig(ui, id.name()); } }; ui.getModel().addPropertyChangeListener(listener); @@ -164,19 +154,16 @@ public class StorageTabUIHandler { if (ui.getStep() != null) { ui.setDescriptionText(t(ui.getStep().getDescription())); - PropertyChangeListener listener = new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - String propertyName = evt.getPropertyName(); - if (StorageUIModel.DATA_IMPORT_MODE_PROPERTY_NAME.equals(propertyName)) { - CreationMode id = (CreationMode) evt.getNewValue(); - - if (id != null) { - refreshConfig(ui, id.name()); + PropertyChangeListener listener = evt -> { + String propertyName = evt.getPropertyName(); + if (StorageUIModel.DATA_IMPORT_MODE_PROPERTY_NAME.equals(propertyName)) { + CreationMode id = (CreationMode) evt.getNewValue(); - } + if (id != null) { + refreshConfig(ui, id.name()); } + } }; ui.getModel().addPropertyChangeListener(listener); @@ -189,14 +176,11 @@ public class StorageTabUIHandler { ui.setDescriptionText(t(ui.getStep().getDescription())); } - ui.getSecurityModel().addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug("Security model changed [" + evt.getPropertyName() + "] <" + evt.getOldValue() + " : " + evt.getNewValue() + ">"); - } - ui.getModel().validate(); + ui.getSecurityModel().addPropertyChangeListener(evt -> { + if (log.isDebugEnabled()) { + log.debug("Security model changed [" + evt.getPropertyName() + "] <" + evt.getOldValue() + " : " + evt.getNewValue() + ">"); } + ui.getModel().validate(); }); JTable table = ui.getRoles(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeCellRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeCellRenderer.java index d06c8b6..5509875 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeCellRenderer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeCellRenderer.java @@ -33,7 +33,6 @@ import javax.swing.JTree; import javax.swing.UIDefaults; import java.awt.Color; import java.awt.Component; -import java.awt.Graphics2D; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -144,13 +143,7 @@ public class DataSelectionTreeCellRenderer extends AbstractObserveTreeCellRender // customize tree selection colors UIDefaults defaults = new UIDefaults(); - Painter<JComponent> painter = new Painter<JComponent>() { - - public void paint(Graphics2D g, JComponent c, int w, int h) { - g.fillRect(0, 0, w, h); - } - - }; + Painter<JComponent> painter = (g, c, w, h) -> g.fillRect(0, 0, w, h); defaults.put("Tree:TreeCell[Enabled+Selected].backgroundPainter", painter); defaults.put("Tree:TreeCell[Enabled+Focused].backgroundPainter", painter); defaults.put("Tree:TreeCell[Focused+Selected].backgroundPainter", painter); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java index f262516..d9ed766 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java @@ -30,7 +30,6 @@ import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor; import javax.swing.JTable; import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellEditor; @@ -609,22 +608,19 @@ public abstract class EditableTableModelSupport<E extends Serializable> extends protected ListSelectionListener getWhenSelectionModelChanged() { if (whenSelectionModelChanged == null) { - whenSelectionModelChanged = new ListSelectionListener() { - @Override - public void valueChanged(ListSelectionEvent e) { - - if (!e.getValueIsAdjusting()) { - int selectedRow = table.getSelectedRow(); - if (selectedRow >= getRowCount()) { - selectedRow = getRowCount() - 1; - if (log.isInfoEnabled()) { - log.info("Decrease selectedRow!!! to " + selectedRow); - } + whenSelectionModelChanged = e -> { + + if (!e.getValueIsAdjusting()) { + int selectedRow = table.getSelectedRow(); + if (selectedRow >= getRowCount()) { + selectedRow = getRowCount() - 1; + if (log.isInfoEnabled()) { + log.info("Decrease selectedRow!!! to " + selectedRow); } - setSelectedRowIndex(selectedRow); } - + setSelectedRowIndex(selectedRow); } + }; } return whenSelectionModelChanged; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java index 4be65a3..77eaa56 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.util.tripMap; */ import com.google.common.base.Optional; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -424,12 +423,7 @@ public class TripMapContentBuilder { protected Style findStyle(StyledLayerDescriptor styledLayerDescriptor, final String layerName, String styleName, Style defaultStyle) { - Optional<StyledLayer> styledLayerOptional = Iterables.tryFind(styledLayerDescriptor.layers(), new Predicate<StyledLayer>() { - @Override - public boolean apply(StyledLayer input) { - return input.getName().equals(layerName); - } - }); + Optional<StyledLayer> styledLayerOptional = Iterables.tryFind(styledLayerDescriptor.layers(), input -> input.getName().equals(layerName)); Style style = defaultStyle; diff --git a/pom.xml b/pom.xml index b82f617..3f06567 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,7 @@ <processorPluginVersion>1.3</processorPluginVersion> <topiaVersion>3.1.2-SNAPSHOT</topiaVersion> - <jaxxVersion>2.29</jaxxVersion> + <jaxxVersion>2.30-SNAPSHOT</jaxxVersion> <nuitonI18nVersion>3.5</nuitonI18nVersion> <nuitonValidatorVersion>3.0.1</nuitonValidatorVersion> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit e538764c98a8998b645cd2897820579d72e8b165 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 13:51:51 2016 +0200 Update libraries to none snapshot + up codelutinpom to 10.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3f06567..959f874 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>codelutinpom</artifactId> - <version>10.1</version> + <version>10.2</version> </parent> <groupId>fr.ird.observe</groupId> @@ -125,8 +125,8 @@ <eugenePluginVersion>3.0-alpha-5</eugenePluginVersion> <processorPluginVersion>1.3</processorPluginVersion> - <topiaVersion>3.1.2-SNAPSHOT</topiaVersion> - <jaxxVersion>2.30-SNAPSHOT</jaxxVersion> + <topiaVersion>3.1.2</topiaVersion> + <jaxxVersion>2.30</jaxxVersion> <nuitonI18nVersion>3.5</nuitonI18nVersion> <nuitonValidatorVersion>3.0.1</nuitonValidatorVersion> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit a7331576566ba504f99692cba31deae4f1f44743 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 13:52:13 2016 +0200 Improve code --- .../AbstractSpeciesFieldDtoValidator.java | 4 +- .../validation/BeanValidatorDetectorTest.java | 2 +- .../main/java/fr/ird/observe/ObserveAdminCLI.java | 2 +- .../main/java/fr/ird/observe/ObserveCLAction.java | 12 +- .../fr/ird/observe/ObserveResourceManager.java | 2 +- .../main/java/fr/ird/observe/ObserveRunner.java | 6 +- .../observe/ObserveSwingApplicationContext.java | 2 +- .../ObserveSwingApplicationConfig.java | 4 +- .../ObserveSwingApplicationConfigOption.java | 2 +- .../fr/ird/observe/db/ObserveSwingDataSource.java | 4 +- .../observe/entities/tripMap/TripMapPointType.java | 2 +- .../fr/ird/observe/ui/ObserveMainUIHandler.java | 2 +- .../src/main/java/fr/ird/observe/ui/UIHelper.java | 8 +- .../observe/ui/actions/ChangeDbLanguageAction.java | 4 +- .../fr/ird/observe/ui/actions/ShowAboutAction.java | 2 +- .../ird/observe/ui/actions/ShowConfigAction.java | 2 +- .../observe/ui/actions/StopH2WebServerAction.java | 1 - .../observe/ui/actions/StopServerModeAction.java | 1 - .../ui/actions/shared/MoveTripsUIAction.java | 6 +- .../fr/ird/observe/ui/admin/AdminActionWorker.java | 2 +- .../java/fr/ird/observe/ui/admin/AdminUIModel.java | 8 +- .../ui/admin/consolidate/ConsolidateUIHandler.java | 2 +- .../ui/admin/export/TripToExportTableModel.java | 2 +- .../ird/observe/ui/admin/report/ReportModel.java | 2 +- .../observe/ui/admin/report/ReportUIHandler.java | 9 +- .../observe/ui/admin/save/SaveLocalUIHandler.java | 2 +- .../validate/ValidateEntityListCellRenderer.java | 7 +- .../ui/admin/validate/ValidateUIHandler.java | 6 +- .../validate/ValidationMessageTableModel.java | 5 +- .../java/fr/ird/observe/ui/content/ContentUI.jaxx | 6 +- .../ird/observe/ui/content/ContentUIHandler.java | 11 +- .../observe/ui/content/ContentUIInitializer.java | 15 +- .../ird/observe/ui/content/ObserveContentUI.java | 7 +- .../content/impl/longline/BranchlineUIHandler.java | 6 +- .../LonglineDetailCompositionUIHandler.java | 44 +- .../LonglineDetailCompositionUIInitializer.java | 4 +- ...onglineDetailCompositionUIValidationHelper.java | 2 +- .../LonglineGlobalCompositionUIHandler.java | 6 +- .../impl/longline/SetLonglineUIHandler.java | 8 +- .../ActivitySeineObservedSystemUIHandler.java | 4 +- .../seine/ActivitySeineObservedSystemUIModel.java | 2 - ...ngObjectTransmittingBuoyOperationUIHandler.java | 6 +- .../impl/seine/FloatingObjectUIHandler.java | 6 +- .../ui/content/impl/seine/SetSeineUIHandler.java | 8 +- .../ui/content/list/ContentListUIHandler.java | 17 +- .../impl/longline/ActivityLonglinesUIHandler.java | 2 +- .../list/impl/seine/ActivitySeinesUIHandler.java | 2 +- .../content/list/impl/seine/RoutesUIHandler.java | 2 +- .../impl/longline/ActivityLonglineUIHandler.java | 8 +- .../open/impl/longline/TripLonglineUIHandler.java | 6 +- .../open/impl/seine/ActivitySeineUIHandler.java | 8 +- .../ui/content/open/impl/seine/RouteUIHandler.java | 6 +- .../open/impl/seine/TripSeineUIHandler.java | 6 +- .../ui/content/ref/ContentReferenceUIHandler.java | 6 +- .../ui/content/ref/UniqueKeyTableModel.java | 6 +- .../observe/ui/content/ref/impl/GearUIHandler.java | 2 +- .../ref/impl/LengthWeightParameterUIHandler.java | 2 +- .../ui/content/ref/impl/ProgramUIHandler.java | 2 +- .../ui/content/ref/impl/SpeciesListUIHandler.java | 2 +- .../ui/content/ref/impl/SpeciesUIHandler.java | 2 +- .../ui/content/ref/impl/VesselUIHandler.java | 2 +- .../observe/ui/content/table/ContentTableMeta.java | 16 +- .../ui/content/table/ContentTableModel.java | 2 +- .../ui/content/table/ContentTableUIHandler.java | 6 +- .../content/table/ContentTableUIInitializer.java | 2 +- .../ui/content/table/ContentTableUIModel.java | 11 +- .../impl/longline/BaitsCompositionUIHandler.java | 2 +- .../impl/longline/BaitsCompositionUIModel.java | 2 + .../longline/BranchlinesCompositionUIHandler.java | 2 +- .../longline/BranchlinesCompositionUIModel.java | 2 + .../impl/longline/CatchAcquisitionModeEnum.java | 2 +- .../impl/longline/CatchLonglineTableModel.java | 5 + .../impl/longline/CatchLonglineUIHandler.java | 12 +- .../table/impl/longline/EncounterUIHandler.java | 2 +- .../table/impl/longline/EncounterUIModel.java | 2 + .../longline/FloatlinesCompositionUIHandler.java | 2 +- .../longline/FloatlinesCompositionUIModel.java | 1 + .../GearUseFeaturesLonglineTableModel.java | 7 +- .../longline/GearUseFeaturesLonglineUIHandler.java | 8 +- .../impl/longline/HooksCompositionUIHandler.java | 2 +- .../impl/longline/HooksCompositionUIModel.java | 1 + .../impl/longline/LonglinePositionHelper.java | 6 +- .../table/impl/longline/SensorUsedUIHandler.java | 2 +- .../table/impl/longline/SensorUsedUIModel.java | 1 + .../content/table/impl/longline/TdrUIHandler.java | 8 +- .../ui/content/table/impl/longline/TdrUIModel.java | 1 + .../seine/GearUseFeatureMeasurementCellEditor.java | 4 +- .../impl/seine/GearUseFeaturesSeineTableModel.java | 7 +- .../impl/seine/GearUseFeaturesSeineUIHandler.java | 8 +- .../impl/seine/ModeSaisieEchantillonEnum.java | 2 +- .../table/impl/seine/NonTargetCatchUIHandler.java | 2 +- .../table/impl/seine/NonTargetCatchUIModel.java | 1 + .../table/impl/seine/NonTargetSampleUIHandler.java | 2 +- .../table/impl/seine/NonTargetSampleUIModel.java | 1 + .../impl/seine/ObjectObservedSpeciesUIHandler.java | 3 +- .../impl/seine/ObjectObservedSpeciesUIModel.java | 1 + .../impl/seine/ObjectSchoolEstimateUIHandler.java | 2 +- .../impl/seine/ObjectSchoolEstimateUIModel.java | 1 + .../table/impl/seine/SchoolEstimateUIHandler.java | 2 +- .../table/impl/seine/SchoolEstimateUIModel.java | 1 + .../table/impl/seine/TargetCatchUIHandler.java | 2 +- .../table/impl/seine/TargetCatchUIModel.java | 1 + .../impl/seine/TargetDiscardCatchUIHandler.java | 4 +- .../impl/seine/TargetDiscardCatchUIModel.java | 1 + .../table/impl/seine/TargetSampleUIHandler.java | 2 +- .../table/impl/seine/TargetSampleUIModel.java | 1 + .../ird/observe/ui/storage/ObstunaAdminAction.java | 8 +- .../ird/observe/ui/storage/RemoteUILauncher.java | 4 +- .../ui/storage/StorageBackupUILauncher.java | 2 +- .../ird/observe/ui/storage/StorageUIHandler.java | 2 - .../ird/observe/ui/storage/StorageUILauncher.java | 2 +- .../fr/ird/observe/ui/storage/StorageUIModel.java | 10 +- .../ui/storage/tabs/DataSelectionModel.java | 17 +- .../ird/observe/ui/storage/tabs/SecurityModel.java | 12 +- .../ui/tree/DataSelectionTreeSelectionModel.java | 4 +- .../fr/ird/observe/ui/tree/ObserveTreeBridge.java | 2 +- .../fr/ird/observe/ui/tree/ObserveTreeHelper.java | 2 +- .../ui/tree/loadors/RootNodeChildLoador.java | 3 - .../ObserveSwingValidatorMessageTableModel.java | 4 +- .../ui/util/table/AbstractSelectTableAction.java | 3 +- .../fr/ird/observe/ui/util/table/EditableList.java | 2 +- .../ui/util/table/EditableTableModelSupport.java | 6 +- .../table/ObserveBooleanTableCellRenderer.java | 13 +- .../observe/ui/util/tripMap/ObserveMapPane.java | 9 +- .../util/tripMap/ObserverMapPanLegendDrawer.java | 24 +- .../ui/util/tripMap/TripMapContentBuilder.java | 4 +- .../observe/ui/util/tripMap/TripMapUIHandler.java | 2 +- .../validation/ValidationMessageDetector.java | 560 --------------------- ...glineDetailCompositionValidatorServiceTest.java | 2 +- .../application/web/ObserveWebMotionRender.java | 2 +- .../ObserveWebApplicationConfigurationOption.java | 9 +- .../web/configuration/db/ObserveWebDatabase.java | 3 +- .../web/configuration/db/ObserveWebDatabases.java | 3 +- .../db/impl/ObserveWebDatabaseBean.java | 11 +- .../db/impl/ObserveWebDatabaseImmutable.java | 21 +- .../db/impl/ObserveWebDatabasesBean.java | 11 +- .../db/impl/ObserveWebDatabasesImmutable.java | 21 +- .../web/configuration/user/ObserveWebUser.java | 3 +- .../web/configuration/user/ObserveWebUsers.java | 3 +- .../configuration/user/ObserveWebUsersHelper.java | 4 +- .../user/impl/ObserveWebUserBean.java | 11 +- .../user/impl/ObserveWebUserImmutable.java | 21 +- .../user/impl/ObserveWebUsersBean.java | 11 +- .../user/impl/ObserveWebUsersImmutable.java | 21 +- .../controller/v1/DataSourceServiceController.java | 2 +- .../web/converter/ObserveDtoConverter.java | 2 +- .../application/web/injector/DateInjector.java | 2 +- .../web/injector/ObserveDtoInjector.java | 2 +- .../web/request/ObserveWebRequestContext.java | 12 +- .../ObserveWebSecurityApplicationContext.java | 2 +- ...ObserveWebSecurityAuthenticationTokenCache.java | 11 +- .../db/ObserveWebDatabasesHelperTest.java | 4 +- .../user/ObserveWebUsersHelperTest.java | 2 +- .../fr/ird/observe/ObserveApplicationContext.java | 2 +- .../java/fr/ird/observe/ObserveServiceHelper.java | 2 +- .../java/fr/ird/observe/db/impl/PGDataSource.java | 2 +- .../fr/ird/observe/db/impl/PGDataSourceConfig.java | 2 +- .../java/fr/ird/observe/entities/Entities.java | 16 +- .../constants/TripMapPointTypePersist.java | 2 +- .../NonTargetCatchComputedValueSourcePersist.java | 2 +- .../entities/constants/seine/OwnershipPersist.java | 2 +- .../constants/seine/SchoolTypePersist.java | 2 +- .../TypeTransmittingBuoyOperationPersist.java | 2 +- .../entities/longline/ActivityLonglines.java | 15 +- .../entities/longline/TripLonglineTopiaDao.java | 4 +- .../migration/AbstractDataSourceMigration.java | 2 +- .../AbstractObserveMigrationCallBack.java | 21 +- .../entities/migration/H2DataSourceMigration.java | 194 ++++--- ...ObserveMigrationCallBackForVersionResolver.java | 2 +- .../entities/migration/PGDataSourceMigration.java | 317 ++++++------ .../DataSourceMigrationForVersion_3_16.java | 38 +- .../DataSourceMigrationForVersion_3_5.java | 2 +- .../DataSourceMigrationForVersion_4_0_1.java | 68 ++- .../DataSourceMigrationForVersion_4_0_RC2.java | 38 +- .../DataSourceMigrationForVersion_4_0_RC3.java | 24 +- .../referentiel/ObserveReferentialEntities.java | 20 +- .../ird/observe/entities/referentiel/Persons.java | 21 +- .../ird/observe/entities/referentiel/Programs.java | 9 +- .../ird/observe/entities/referentiel/Species2.java | 16 +- .../observe/entities/seine/ActivitySeineImpl.java | 3 +- .../ird/observe/entities/seine/ActivitySeines.java | 17 +- .../observe/entities/seine/NonTargetCatchImpl.java | 2 +- .../observe/entities/seine/NonTargetCatchs.java | 7 +- .../observe/entities/seine/NonTargetLenghts.java | 7 +- .../ird/observe/entities/seine/RouteTopiaDao.java | 40 +- .../java/fr/ird/observe/entities/seine/Routes.java | 15 +- .../fr/ird/observe/entities/seine/SetSeines.java | 9 +- .../ird/observe/entities/seine/TargetCatchs.java | 18 +- .../ird/observe/entities/seine/TargetLenghts.java | 10 +- .../observe/entities/seine/TripSeineTopiaDao.java | 4 +- .../ObserveTopiaApplicationContextTest.java | 2 +- .../services/ObserveServiceInitializer.java | 6 +- .../service/actions/report/ReportBuilder.java | 2 +- .../actions/validate/ValidateResultForDtoType.java | 8 +- .../actions/validate/ValidateResultForDtos.java | 30 +- .../actions/validate/ValidationMessage.java | 6 +- .../service/actions/validate/ValidatorDtos.java | 15 +- .../ObserveDataSourceConfigurationRest.java | 4 +- .../observe/services/dto/AbstractReference.java | 26 +- .../fr/ird/observe/services/dto/DataReference.java | 28 +- .../java/fr/ird/observe/services/dto/IdDtos.java | 26 +- .../observe/services/dto/ObserveDbUserDtos.java | 2 +- .../services/dto/actions/report/Report.java | 8 +- .../dto/actions/report/ReportOperation.java | 2 +- .../dto/actions/report/ReportVariable.java | 6 +- .../services/dto/constants/ObserveDbRole.java | 2 +- .../services/dto/constants/ReferenceStatus.java | 2 +- .../services/dto/constants/TripMapPointType.java | 4 +- .../seine/NonTargetCatchComputedValueSource.java | 2 +- .../services/dto/constants/seine/SchoolType.java | 2 +- .../seine/TypeTransmittingBuoyOperation.java | 4 +- .../services/dto/gson/ObserveDtoGsonSupplier.java | 8 +- .../services/dto/longline/SectionWithTemplate.java | 4 - .../dto/longline/SectionWithTemplates.java | 11 +- .../services/dto/referential/PersonDtos.java | 30 +- .../services/dto/referential/ReferentialDtos.java | 2 +- .../dto/referential/ReferentialReferences.java | 21 +- .../services/http/ObserveRequestBuilder.java | 2 +- .../ird/observe/services/http/ObserveResponse.java | 6 +- .../services/http/ObserveResponseBuilder.java | 4 +- .../services/service/AbstractServiceRestTest.java | 2 +- .../service/ReferenceValuesSetServiceRestTest.java | 4 +- .../report/AbstractReportServiceRestTest.java | 5 - .../report/ReportAccessoryCatchRestTest.java | 2 +- .../actions/validate/ValidateServiceRestTest.java | 251 +++++---- .../validators/AbstractSpeciesFieldValidator.java | 4 +- ...erve-services-topia-validation_en_GB.properties | 2 +- ...erve-services-topia-validation_es_ES.properties | 2 +- ...erve-services-topia-validation_fr_FR.properties | 2 +- .../validation/BeanValidatorDetectorTest.java | 2 +- .../observe/services/ObserveSecurityHelper.java | 11 +- .../ird/observe/services/ObserveServiceTopia.java | 4 +- .../ObserveTopiaApplicationContextFactory.java | 4 +- .../ird/observe/services/binder/BinderEngine.java | 12 +- .../ird/observe/services/binder/BinderSupport.java | 104 +--- .../observe/services/entity/EntitiesExtractor.java | 12 +- .../services/entity/EntitiesSetFactory.java | 12 +- .../entity/SpeciesListEntitiesExtractor.java | 2 +- .../entity/SpeciesListOceanEntitiesExtractor.java | 7 +- .../observe/services/entity/TripMapDtoFactory.java | 21 +- .../services/service/DataSourceServiceTopia.java | 2 +- .../services/service/ReferentialServiceTopia.java | 4 +- .../service/SqlScriptProducerServiceTopia.java | 4 +- .../ConsolidateActivitySeineDataResultBuilder.java | 12 +- .../consolidate/ConsolidateDataServiceTopia.java | 4 +- .../service/actions/report/ReportServiceTopia.java | 4 +- ...alReferentialSynchronizeRemoteServiceTopia.java | 5 +- .../validate/ValidationMessageDetector.java | 9 +- .../longline/ActivityLonglineServiceTopia.java | 2 +- .../service/seine/ActivitySeineServiceTopia.java | 2 +- .../services/service/seine/RouteServiceTopia.java | 10 +- .../referentiel/LengthWeightParemetersTest.java | 2 +- .../services/binder/BinderEngineMetadataTest.java | 2 +- .../observe/services/binder/BinderEngineTest.java | 9 +- .../service/DataSourceServiceTopiaTest.java | 2 +- .../services/service/MigrateTestsDatabases.java | 2 +- .../report/AbstractReportServiceTopiaTest.java | 5 +- .../actions/report/ReportAccessoryCatch2Test.java | 2 +- .../report/ReportAccessoryCatchByGroup2Test.java | 2 +- .../report/ReportAccessoryCatchByGroupTest.java | 2 +- .../actions/report/ReportAccessoryCatchTest.java | 2 +- .../report/ReportActivityWithCommentTest.java | 2 +- .../actions/report/ReportAllActivitysTest.java | 2 +- .../actions/report/ReportDailySetAndCatchTest.java | 2 +- .../service/actions/report/ReportDcpUsageTest.java | 2 +- .../actions/report/ReportSetByAssociationTest.java | 2 +- .../report/ReportTargetCatchByAssociationTest.java | 2 +- .../ReportTargetDiscardedByAssociationTest.java | 2 +- .../actions/validate/ValidateServiceTopiaTest.java | 202 +++++--- .../sql/batch/actions/AbstractSqlAction.java | 26 +- .../sql/batch/actions/AbstractTablesAction.java | 2 +- .../sql/batch/actions/DeleteTablesAction.java | 6 +- .../sql/batch/actions/ReplicateTablesAction.java | 2 +- .../sql/batch/actions/UpdateTablesAction.java | 2 +- .../service/sql/batch/tables/TopiaSqlTables.java | 2 +- 275 files changed, 1215 insertions(+), 2201 deletions(-) diff --git a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/AbstractSpeciesFieldDtoValidator.java b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/AbstractSpeciesFieldDtoValidator.java index 338993f..2a3c124 100644 --- a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/AbstractSpeciesFieldDtoValidator.java +++ b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/AbstractSpeciesFieldDtoValidator.java @@ -63,9 +63,9 @@ public abstract class AbstractSpeciesFieldDtoValidator extends FieldValidatorSup public static class Bound { - private Float min; + private final Float min; - private Float max; + private final Float max; Bound(Float min, Float max) { this.min = min; diff --git a/observe-application-swing-validation/src/test/java/fr/ird/observe/application/swing/validation/BeanValidatorDetectorTest.java b/observe-application-swing-validation/src/test/java/fr/ird/observe/application/swing/validation/BeanValidatorDetectorTest.java index 6280341..549e499 100644 --- a/observe-application-swing-validation/src/test/java/fr/ird/observe/application/swing/validation/BeanValidatorDetectorTest.java +++ b/observe-application-swing-validation/src/test/java/fr/ird/observe/application/swing/validation/BeanValidatorDetectorTest.java @@ -138,7 +138,7 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { static Class<?>[] ALL_TYPES; @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { ALL_TYPES = new Class[]{ ActivityLonglineDto.class, ActivityLonglineEncounterDto.class, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveAdminCLI.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveAdminCLI.java index 2796005..e474a4b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveAdminCLI.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveAdminCLI.java @@ -36,7 +36,7 @@ import java.util.Date; public class ObserveAdminCLI extends ObserveRunner { /** Logger */ - private static Log log = LogFactory.getLog(ObserveAdminCLI.class); + private static final Log log = LogFactory.getLog(ObserveAdminCLI.class); @Override public String getRunnerName() { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveCLAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveCLAction.java index 4e9afd1..e11a47c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveCLAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveCLAction.java @@ -54,7 +54,7 @@ import static org.nuiton.i18n.I18n.t; public class ObserveCLAction { /** Logger */ - static private Log log = LogFactory.getLog(ObserveCLAction.class); + private static final Log log = LogFactory.getLog(ObserveCLAction.class); /** * Les actions appellables en ligne de commande. @@ -136,13 +136,13 @@ public class ObserveCLAction { "--create-id"); - public String description; + public final String description; - public String action; + public final String action; - public String[] aliases; + public final String[] aliases; - public boolean admin; + public final boolean admin; ActionDefinition(boolean admin, String description, String action, String... aliases) { this.description = description; @@ -320,7 +320,7 @@ public class ObserveCLAction { disableMainUI(); - Class<?> klazz = null; +// Class<?> klazz = null; //FIXME // List<ObserveEntityEnum> enums = Lists.newArrayList(Entities.ALL_ENTITIES); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveResourceManager.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveResourceManager.java index 0a141a4..c176f2b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveResourceManager.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveResourceManager.java @@ -63,7 +63,7 @@ public class ObserveResourceManager { public static final String OBSERVE_LOG_CONFIGURATION_FILE_PROPERTIES = "/observe-log4j.properties"; /** Logger */ - static private Log log = LogFactory.getLog(ObserveResourceManager.class); + private static final Log log = LogFactory.getLog(ObserveResourceManager.class); public enum Resource { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java index df46160..455d1d2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveRunner.java @@ -525,7 +525,7 @@ public abstract class ObserveRunner extends ApplicationRunner { } - protected void detectLocalDataBase(ObserveSwingApplicationConfig config) throws IOException { + protected void detectLocalDataBase(ObserveSwingApplicationConfig config) { boolean hasLocalStorage = new File(config.getLocalDBDirectory(), ObserveSwingApplicationConfig.DB_NAME).exists(); config.setLocalStorageExist(hasLocalStorage); if (!hasLocalStorage) { @@ -579,7 +579,7 @@ public abstract class ObserveRunner extends ApplicationRunner { } } - protected void initUIConfiguration(ObserveSwingApplicationConfig config) throws IOException { + protected void initUIConfiguration(ObserveSwingApplicationConfig config) { // prepare ui look&feel and load ui properties try { @@ -647,7 +647,7 @@ public abstract class ObserveRunner extends ApplicationRunner { * @return le context applicatif * @throws IllegalStateException si un contexte applicatif a déja été positionné. */ - public ObserveSwingApplicationContext initContext(ObserveSwingApplicationConfig config) throws Exception { + public ObserveSwingApplicationContext initContext(ObserveSwingApplicationConfig config) { ObserveSwingApplicationContext.checkIsNotInit(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index 38157a5..daad9ff 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -122,7 +122,7 @@ import static org.nuiton.i18n.I18n.t; public class ObserveSwingApplicationContext extends DefaultApplicationContext implements Closeable { /** Logger */ - static private Log log = LogFactory.getLog(ObserveSwingApplicationContext.class); + private static final Log log = LogFactory.getLog(ObserveSwingApplicationContext.class); /** Un drapeau pour savoir quand l'application est en cours de fermeture. */ protected static boolean closed; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfig.java b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfig.java index cd81de9..e482d6e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfig.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfig.java @@ -222,7 +222,7 @@ public class ObserveSwingApplicationConfig extends ApplicationConfig { public static final String PROPERTY_TREE_OPEN_NODES = "treeOpenNodes"; /** Logger */ - static private Log log = LogFactory.getLog(ObserveSwingApplicationConfig.class); + private static final Log log = LogFactory.getLog(ObserveSwingApplicationConfig.class); protected static final String DEFAULT_OBSERVE_SWING_CONFIGURATION_FILENAME = "observeSwing.conf"; @@ -1018,7 +1018,7 @@ public class ObserveSwingApplicationConfig extends ApplicationConfig { setServerUrl(config.getServerUrl()); setServerLogin(config.getLogin()); setServerPassword(config.getPassword()); - setServerDataBaseName(config.getOptionalDatabaseName().orNull()); + setServerDataBaseName(config.getOptionalDatabaseName().orElse(null)); saveForUser(); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java index ba3fdc8..c062d94 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/configuration/ObserveSwingApplicationConfigOption.java @@ -814,7 +814,7 @@ public enum ObserveSwingApplicationConfigOption implements ConfigOptionDef { false ); - public static List<ObserveSwingApplicationConfigOption> MAP_LAYERS = ImmutableList.of(MAP_LAYER_1, MAP_LAYER_2, MAP_LAYER_3, + public static final List<ObserveSwingApplicationConfigOption> MAP_LAYERS = ImmutableList.of(MAP_LAYER_1, MAP_LAYER_2, MAP_LAYER_3, MAP_LAYER_4, MAP_LAYER_5, MAP_LAYER_6, MAP_LAYER_7, MAP_LAYER_8, MAP_LAYER_9, MAP_LAYER_10); /** diff --git a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java index 7989bcb..4da3d56 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/db/ObserveSwingDataSource.java @@ -161,7 +161,7 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements canWriteData(), getVersion(), getVersion(), - ImmutableList.<Version>of()); + ImmutableList.of()); } public void open() throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException, BabModelVersionException { @@ -265,7 +265,7 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements dataSourceService.applySecurity(getConfiguration(), users); } - public void migrateData(ObserveDataSourceInformation dataSourceInformation, Version targetVersion) throws DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { + public void migrateData(ObserveDataSourceInformation dataSourceInformation, Version targetVersion) { checkIsNotOpen(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/entities/tripMap/TripMapPointType.java b/observe-application-swing/src/main/java/fr/ird/observe/entities/tripMap/TripMapPointType.java index 4dac356..4833ca7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/entities/tripMap/TripMapPointType.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/entities/tripMap/TripMapPointType.java @@ -46,7 +46,7 @@ public enum TripMapPointType { LONGLINE_ACTIVITY_WITH_INTERACTION(n("observe.map.longLine.activity.interaction")), LONGLINE_ACTIVITY_WITH_STATION(n("observe.map.longLine.activity.station")); - String label; + private final String label; TripMapPointType(String label) { this.label = label; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java index 3c06af7..b9a3ba7 100755 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/ObserveMainUIHandler.java @@ -74,7 +74,7 @@ import static org.nuiton.i18n.I18n.t; public class ObserveMainUIHandler { /** Logger */ - static private Log log = LogFactory.getLog(ObserveMainUIHandler.class); + private static final Log log = LogFactory.getLog(ObserveMainUIHandler.class); public static final String H2_SERVER = "server"; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java index d510064..eb4ea0a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/UIHelper.java @@ -314,7 +314,7 @@ public class UIHelper extends SwingUtil { DecoratorService decoratorService = ObserveSwingApplicationContext.get().getDecoratorService(); Decorator<E> decorator = decoratorService.getDecoratorByType(beanClass); String beanStr; - String messageDelete = null; + String messageDelete; String type = DecoratorService.getEntityLabel(beanClass); type = t(type); @@ -469,11 +469,7 @@ public class UIHelper extends SwingUtil { u.getProtocol().equalsIgnoreCase("file")) { Desktop.getDesktop().browse(u.toURI()); } - } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Error while opening link", e); - } - } catch (URISyntaxException e) { + } catch (IOException | URISyntaxException e) { if (log.isErrorEnabled()) { log.error("Error while opening link", e); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ChangeDbLanguageAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ChangeDbLanguageAction.java index f8f52ac..81393a0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ChangeDbLanguageAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ChangeDbLanguageAction.java @@ -22,11 +22,11 @@ package fr.ird.observe.ui.actions; * #L% */ +import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.configuration.ObserveSwingApplicationConfigOption; -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.constants.ReferentialLocale; -import fr.ird.observe.ui.*; +import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.ObserveUICallback; import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java index a2b63f3..7c760ea 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowAboutAction.java @@ -115,7 +115,7 @@ public class ShowAboutAction extends AbstractAction { } translateArea.setText(translateText); translatePane.getViewport().add(translateArea); - translateArea.addHyperlinkListener(e -> UIHelper.openLink(e)); + translateArea.addHyperlinkListener(UIHelper::openLink); about.getTabs().add(t("observe.about.translate.title"), translatePane); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java index a43774d..b2e0970 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/ShowConfigAction.java @@ -139,7 +139,7 @@ public class ShowConfigAction extends AbstractAction { helper.setFinalizer(new MainCallBackFinalizer(ObserveUICallback.application.name())); - helper.setCloseAction(() -> ObserveMainUIHandler.restartEdit()); + helper.setCloseAction(ObserveMainUIHandler::restartEdit); // categorie repertoires addDirectoriesOptions(helper); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopH2WebServerAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopH2WebServerAction.java index f405b8b..457d3da 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopH2WebServerAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopH2WebServerAction.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.actions; */ import fr.ird.observe.ui.ObserveMainUI; -import fr.ird.observe.ui.ObserveMainUIHandler; import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopServerModeAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopServerModeAction.java index aa0311b..9142228 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopServerModeAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/StopServerModeAction.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.actions; */ import fr.ird.observe.ui.ObserveMainUI; -import fr.ird.observe.ui.ObserveMainUIHandler; import fr.ird.observe.ui.ObserveUIMode; import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java index b4e3eff..e5ac87a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/actions/shared/MoveTripsUIAction.java @@ -27,7 +27,6 @@ import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.DataDto; import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.constants.GearType; -import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.content.list.ContentListUIModel; @@ -35,7 +34,6 @@ import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; import fr.ird.observe.ui.tree.menu.MoveTripNodeMenuPopulator; import fr.ird.observe.ui.util.DecoratedNodeEntity; -import fr.ird.observe.application.swing.decoration.decorators.ReferentialReferenceDecorator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -85,7 +83,7 @@ public abstract class MoveTripsUIAction<T extends DataDto> extends AbstractUIAct if (ui == null) { throw new IllegalStateException( "could not find client property " + - "ui on component" + c); + "ui on component" + c); } checkUIClass(ui); @@ -124,8 +122,6 @@ public abstract class MoveTripsUIAction<T extends DataDto> extends AbstractUIAct // racine ObserveNode rootNode = treeHelper.getRootNode(); - ReferentialReferenceDecorator<ProgramDto> decorator = applicationContext.getDecoratorService().getReferentialReferenceDecorator(ProgramDto.class); - //on crée un tableau avec un programme en moins car on ne propose pas le programme actuel List<DecoratedNodeEntity> decoratedProgramList = new ArrayList<>(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminActionWorker.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminActionWorker.java index 250ad41..67b6af4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminActionWorker.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminActionWorker.java @@ -34,7 +34,7 @@ import java.util.concurrent.Callable; */ public class AdminActionWorker extends ActionWorker<WizardState, String> { - protected AdminTabUIHandler handler; + protected final AdminTabUIHandler handler; protected AdminActionWorker(AdminTabUIHandler handler, String actionLabel) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java index 4f474a1..ac8553b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/AdminUIModel.java @@ -107,10 +107,10 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { protected ObserveSwingDataSource tmpSource; /** la configuration de la base source */ - protected StorageUIModel localSourceModel; + protected final StorageUIModel localSourceModel; /** la configuration de la base central */ - protected StorageUIModel centralSourceModel; + protected final StorageUIModel centralSourceModel; /** le controleur pour configurer les sources */ protected StorageUIHandler storageHandler; @@ -119,10 +119,10 @@ public class AdminUIModel extends WizardExtModel<AdminStep> { protected ObserveSwingApplicationConfig config; /** selection des donnees a valider */ - protected DataSelectionModel selectionDataModel; + protected final DataSelectionModel selectionDataModel; /** la liste des modes disponibles en entrée */ - protected EnumSet<DbMode> availableIncomingModes; + protected final EnumSet<DbMode> availableIncomingModes; private final PropertyChangeListener listenStepChanged; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java index bc5ad7c..15c0546 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/consolidate/ConsolidateUIHandler.java @@ -102,7 +102,7 @@ public class ConsolidateUIHandler extends AdminTabUIHandler { public void startAction() { - addAdminWorker(((ConsolidateUI) ui).getStartButton().getToolTipText(), () -> doAction()); + addAdminWorker(((ConsolidateUI) ui).getStartButton().getToolTipText(), this::doAction); } public WizardState doAction() throws Exception { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/TripToExportTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/TripToExportTableModel.java index 385d870..7b39e6b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/TripToExportTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/export/TripToExportTableModel.java @@ -49,7 +49,7 @@ public class TripToExportTableModel extends AbstractTableModel { protected TripEntry[] data; - protected Set<Integer> selected; + protected final Set<Integer> selected; protected boolean selectAll; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java index b25ad6b..7e3b30b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportModel.java @@ -77,7 +77,7 @@ public class ReportModel extends AdminActionModel { protected Report selectedReport; /** les variables utilisées pour le report. */ - protected Map<String, Object> variables; + protected final Map<String, Object> variables; /** le résultat du report actuellement sélectionné */ protected ResultTableModel resultModel; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java index 704b093..d69f170 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/report/ReportUIHandler.java @@ -94,8 +94,8 @@ public class ReportUIHandler extends AdminTabUIHandler { if (log.isDebugEnabled()) { log.debug(" specialized for [" + tabUI.getStep() + - "] for main ui " + ui.getClass().getName() + - "@" + System.identityHashCode(ui)); + "] for main ui " + ui.getClass().getName() + + "@" + System.identityHashCode(ui)); } UIHelper.setLayerUI(tabUI.getContent(), ui.getConfigBlockLayerUI()); @@ -132,6 +132,7 @@ public class ReportUIHandler extends AdminTabUIHandler { }); tabUI.getReportSelector().setRenderer(new DefaultListCellRenderer() { + private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -148,7 +149,7 @@ public class ReportUIHandler extends AdminTabUIHandler { // ajout du renderer sur le tableau DefaultTableCellRenderer renderer = new DefaultTableCellRenderer() { - + private static final long serialVersionUID = 1L; Font defaultFont; Font headerFont; @@ -272,7 +273,7 @@ public class ReportUIHandler extends AdminTabUIHandler { if (log.isDebugEnabled()) { log.debug("Will copy result of report " + report.getName()); log.debug("Result dimension : [" + model.getRowCount() + "," + - model.getColumnCount() + "]"); + model.getColumnCount() + "]"); } String content = model.getClipbordContent(copyRowHeaders, copyColumnHeaders); UIHelper.copyToClipBoard(content); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/save/SaveLocalUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/save/SaveLocalUIHandler.java index 5f51ece..8d3bd23 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/save/SaveLocalUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/save/SaveLocalUIHandler.java @@ -175,7 +175,7 @@ public class SaveLocalUIHandler extends AdminTabUIHandler { return WizardState.SUCCESSED; } - public void saveUnidirectionalSynchronizeReferential() throws Exception { + public void saveUnidirectionalSynchronizeReferential() { SynchronizeModel stepModel = getModel().getSynchronizeReferentielModel(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java index ef137f5..190fcde 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateEntityListCellRenderer.java @@ -22,11 +22,11 @@ package fr.ird.observe.ui.admin.validate; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.services.dto.AbstractReference; import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.service.actions.validate.ValidateResultForDto; import fr.ird.observe.services.service.actions.validate.ValidateResultForDtos; -import fr.ird.observe.application.swing.decoration.DecoratorService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; @@ -67,12 +67,11 @@ public class ValidateEntityListCellRenderer extends DefaultListCellRenderer impl @Override public void propertyChange(PropertyChangeEvent evt) { - DecoratorService decoratorService = getService(); Map<?, ?> value = (Map<?, ?>) evt.getNewValue(); if (log.isDebugEnabled()) { log.debug("messages changed : " + - (value == null ? 0 : value.size()) + - ", rebuild render cache"); + (value == null ? 0 : value.size()) + + ", rebuild render cache"); } synchronized (renderCache) { renderCache.clear(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java index a8818f4..0984941 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidateUIHandler.java @@ -72,7 +72,7 @@ import javax.swing.RowSorter; import javax.swing.SortOrder; import java.io.File; import java.io.IOException; -import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.EnumSet; import java.util.List; @@ -122,7 +122,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { messageTable.setDefaultRenderer(Object.class, new ObserveValidationMessageTableRenderer()); messageTable.getRowSorter().setSortKeys( - Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); + Collections.singletonList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); SwingUtil.setI18nTableHeaderRenderer( messageTable, n("validator.scope.header"), @@ -575,7 +575,7 @@ public class ValidateUIHandler extends AdminTabUIHandler { } public boolean isObjectOperationSelected(Set<AdminStep> objectOperations, JCheckBox checkBox) { - AdminStep scope = getObjectOperation(checkBox); +// AdminStep scope = getObjectOperation(checkBox); return objectOperations.contains(getObjectOperation(checkBox)); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java index 26c9e47..2ebbe31 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/admin/validate/ValidationMessageTableModel.java @@ -36,13 +36,15 @@ import java.util.List; */ public class ValidationMessageTableModel extends AbstractTableModel { + private static final long serialVersionUID = 1L; + public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"}; public static final Class<?>[] columnClasses = {NuitonValidatorScope.class, String.class, String.class}; - protected List<ValidationMessage> messages = Lists.newArrayList(); + protected final List<ValidationMessage> messages = Lists.newArrayList(); @Override public int getRowCount() { @@ -88,6 +90,7 @@ public class ValidationMessageTableModel extends AbstractTableModel { break; case 2: value = message.getMessage(); + break; default: value = null; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUI.jaxx index c2ff287..bfcbbb5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUI.jaxx @@ -91,15 +91,15 @@ public Object getSelectedBean(JList list) { return list.getSelectedValue(); } -public void init() throws Exception { +public void init() { getHandler().initUI(); } -public void open() throws Exception { +public void open() { getHandler().openUI(); } -public boolean close() throws Exception { +public boolean close() { return getHandler().closeUI(); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index 3c657ee..6cbca35 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -107,7 +107,7 @@ public abstract class ContentUIHandler<E extends IdDto> { private final Icon errorIcon; /** l'interface graphique que le controleur utilise */ - protected ObserveContentUI<E> ui; + protected final ObserveContentUI<E> ui; public static <E extends IdDto> ContentUIHandler<E> newHandler(ObserveContentUI<E> ui) { @@ -283,7 +283,7 @@ public abstract class ContentUIHandler<E extends IdDto> { return result; } - public void initUI() throws Exception { + public void initUI() { final ContentUIInitializer<E, ObserveContentUI<E>> uiInitializer = new ContentUIInitializer<>(ui); uiInitializer.initUI(); @@ -292,7 +292,7 @@ public abstract class ContentUIHandler<E extends IdDto> { } - public void openUI() throws Exception { + public void openUI() { boolean canWrite = computeCanWrite(getDataSource()); @@ -436,7 +436,7 @@ public abstract class ContentUIHandler<E extends IdDto> { } } - public final boolean closeUI() throws Exception { + public final boolean closeUI() { boolean b = checkEdit(ui); if (log.isDebugEnabled()) { log.debug("Can close " + ui.getClass() + " : " + b); @@ -654,7 +654,7 @@ public abstract class ContentUIHandler<E extends IdDto> { } - protected boolean doDelete(E bean) throws Exception { + protected boolean doDelete(E bean) { return false; } @@ -871,7 +871,6 @@ public abstract class ContentUIHandler<E extends IdDto> { updateDataFilterableDoubleList(dtoClass, filterableDoubleList); } - continue; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 55f23bc..ce76f29 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -195,7 +195,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E return ui.getModel().getForm(); } - public void initUI() throws Exception { + public void initUI() { if (log.isDebugEnabled()) { log.debug("ui " + getClass()); @@ -290,7 +290,6 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E if (o instanceof JTextArea) { init((JTextArea) o); - continue; } } @@ -614,7 +613,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E ListCellRenderer<? super AbstractReference<D>> renderer = selectedList.getCellRenderer(); selectedList.setCellRenderer(new ReferentielListCellRenderer<>(renderer)); - list.getUniverseList().setCellRenderer(new ReferentielListCellRenderer<>(renderer)); + list.getUniverseList().setCellRenderer(new ReferentielListCellRenderer<>((ListCellRenderer<? super AbstractReference<IdDto>>) renderer)); } @@ -640,7 +639,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E ListCellRenderer<? super AbstractReference<D>> renderer = selectedList.getCellRenderer(); selectedList.setCellRenderer(new ReferentielListCellRenderer<>(renderer)); - list.getUniverseList().setCellRenderer(new ReferentielListCellRenderer<>(renderer)); + list.getUniverseList().setCellRenderer(new ReferentielListCellRenderer<>((ListCellRenderer<? super AbstractReference<IdDto>>) renderer)); } @@ -660,7 +659,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E list.putClientProperty("decorator", decorator); - list.init(decorator, Collections.<DataReference<D>>emptyList()); + list.init(decorator, Collections.emptyList()); JList<AbstractReference<D>> list1 = list.getList(); ListCellRenderer<? super AbstractReference<D>> renderer = list1.getCellRenderer(); @@ -684,7 +683,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E list.putClientProperty("decorator", decorator); - list.init(decorator, Collections.<ReferentialReference<D>>emptyList()); + list.init(decorator, Collections.emptyList()); JList<AbstractReference<D>> list1 = list.getList(); ListCellRenderer<? super AbstractReference<D>> renderer = list1.getCellRenderer(); @@ -702,7 +701,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E DataReferenceDecorator<D> decorator = decoratorService.getDataReferenceDecorator(dtoClass); - comboBox.init(decorator, Collections.<DataReference<D>>emptyList()); + comboBox.init(decorator, Collections.emptyList()); JComboBox<DataReference<D>> combobox = comboBox.getCombobox(); @@ -724,7 +723,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E ReferentialReferenceDecorator<D> decorator = decoratorService.getReferentialReferenceDecorator(dtoClass); - comboBox.init(decorator, Collections.<ReferentialReference<D>>emptyList()); + comboBox.init(decorator, Collections.emptyList()); JComboBox<ReferentialReference<D>> combobox = comboBox.getCombobox(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java index 4d8cbe6..cd56aea 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content; */ import fr.ird.observe.db.DataContext; - import fr.ird.observe.db.ObserveSwingDataSource; import fr.ird.observe.services.dto.IdDto; import jaxx.runtime.JAXXObject; @@ -57,11 +56,11 @@ public interface ObserveContentUI<E extends IdDto> extends JAXXObject { void setContentIcon(Icon icon); - void init() throws Exception; + void init(); - void open() throws Exception; + void open(); - boolean close() throws Exception; + boolean close(); void stopEdit(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java index b695eb1..309d844 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/BranchlineUIHandler.java @@ -53,7 +53,7 @@ import java.util.Set; public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { /** Logger */ - static private Log log = LogFactory.getLog(BranchlineUIHandler.class); + private static final Log log = LogFactory.getLog(BranchlineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -141,7 +141,7 @@ public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { } @Override - public void initUI() throws Exception { + public void initUI() { branchlineDecorator = getDecoratorService().getDecoratorByType(BranchlineDto.class); super.initUI(); @@ -149,7 +149,7 @@ public class BranchlineUIHandler extends ContentUIHandler<BranchlineDto> { } @Override - public void openUI() throws Exception { + public void openUI() { if (log.isInfoEnabled()) { log.info("OpenUI: " + getModel()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java index b422328..6cefcfa 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIHandler.java @@ -23,7 +23,6 @@ package fr.ird.observe.ui.content.impl.longline; */ import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; @@ -63,6 +62,7 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; +import static com.google.common.collect.Lists.newArrayList; import static org.nuiton.i18n.I18n.t; /** @@ -76,7 +76,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong static final String SECTION_TEMPLATES_EDITOR = "sectionTemplatesEditor"; /** Logger */ - static private Log log = LogFactory.getLog(LonglineDetailCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(LonglineDetailCompositionUIHandler.class); private final PropertyChangeListener sectionTemplatesTableModelModified; @@ -144,7 +144,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong */ private boolean onOpen; - private JVetoableTabbedPane.ChangeSelectedIndex tabbedPaneWillChanged; + private final JVetoableTabbedPane.ChangeSelectedIndex tabbedPaneWillChanged; public LonglineDetailCompositionUIHandler(LonglineDetailCompositionUI ui) { super(ui, DataContextType.ActivityLongline, DataContextType.SetLongline); @@ -270,7 +270,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong } @Override - public void initUI() throws Exception { + public void initUI() { this.sectionDecorator = getDecoratorService().getDecoratorByType(SectionDto.class); this.basketDecorator = getDecoratorService().getDecoratorByType(BasketDto.class); @@ -332,7 +332,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong } @Override - public void openUI() throws Exception { + public void openUI() { UIHelper.stopEditing(getUi().getSectionTemplatesTable()); UIHelper.stopEditing(getUi().getSectionsTable()); @@ -383,7 +383,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong getModel().setCanGenerate(bean.isSectionEmpty()); // TODO Use a cache of templates on setLongline (session scope) - getSectionTemplatesTableModel().setData(Lists.<SectionTemplate>newArrayList()); + getSectionTemplatesTableModel().setData(new ArrayList<>()); BranchlineUI branchlineDetailUI = getUi().getBranchlineDetailUI(); branchlineDetailUI.edit(null); @@ -564,8 +564,8 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong sectionsTableModel.setData(sections); List<SectionDto> sectionDtos = sections.stream() - .map(SectionWithTemplate::getDelegate) - .collect(Collectors.toList()); + .map(SectionWithTemplate::getDelegate) + .collect(Collectors.toList()); getBean().addAllSection(sectionDtos); @@ -611,7 +611,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong t("observe.sections.delete.message"), JOptionPane.WARNING_MESSAGE, new Object[]{t("observe.choice.confirm.delete"), - t("observe.choice.cancel")}, + t("observe.choice.cancel")}, 1); if (response != 0) { @@ -628,7 +628,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong try { - getSectionsTableModel().setData(Lists.<SectionWithTemplate>newArrayList()); + getSectionsTableModel().setData(new ArrayList<>()); getBean().getSection().clear(); getModel().setModified(true); @@ -660,7 +660,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong t("observe.sectionTemplate.delete.message"), JOptionPane.WARNING_MESSAGE, new Object[]{t("observe.choice.confirm.delete"), - t("observe.choice.cancel")}, + t("observe.choice.cancel")}, 1); if (response != 0) { @@ -737,7 +737,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong SectionWithTemplate newSectionWithTemplate = tableModel.getSelectedRow(); int selectedRowIndex = tableModel.getSelectedRowIndex(); - List<SectionDto> sections = Lists.newArrayList(getBean().getSection()); + List<SectionDto> sections = newArrayList(getBean().getSection()); sections.add(selectedRowIndex, newSectionWithTemplate.getDelegate()); getBean().getSection().clear(); getBean().addAllSection(sections); @@ -762,7 +762,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong SectionWithTemplate newSectionWithTemplate = tableModel.getSelectedRow(); int selectedRowIndex = tableModel.getSelectedRowIndex(); - List<SectionDto> sections = Lists.newArrayList(getBean().getSection()); + List<SectionDto> sections = newArrayList(getBean().getSection()); sections.add(selectedRowIndex, newSectionWithTemplate.getDelegate()); getBean().getSection().clear(); getBean().addAllSection(sections); @@ -842,9 +842,9 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong int selectedRowIndex = tableModel.getSelectedRowIndex(); SectionWithTemplate selectedSection = getSectionsTableModel().getSelectedRow(); if (selectedSection.isBasketEmpty()) { - selectedSection.setBasket(Sets.<BasketDto>newLinkedHashSet()); + selectedSection.setBasket(new LinkedHashSet<>()); } - List<BasketDto> baskets = Lists.newArrayList(selectedSection.getBasket()); + List<BasketDto> baskets = newArrayList(selectedSection.getBasket()); baskets.add(selectedRowIndex, newBasket); selectedSection.getBasket().clear(); selectedSection.addAllBasket(baskets); @@ -871,9 +871,9 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong int selectedRowIndex = tableModel.getSelectedRowIndex(); SectionWithTemplate selectedSection = getSectionsTableModel().getSelectedRow(); if (selectedSection.isBasketEmpty()) { - selectedSection.setBasket(Sets.<BasketDto>newLinkedHashSet()); + selectedSection.setBasket(new LinkedHashSet<>()); } - List<BasketDto> baskets = Lists.newArrayList(selectedSection.getBasket()); + List<BasketDto> baskets = newArrayList(selectedSection.getBasket()); baskets.add(selectedRowIndex, newBasket); selectedSection.getBasket().clear(); selectedSection.addAllBasket(baskets); @@ -951,10 +951,10 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong int selectedRowIndex = tableModel.getSelectedRowIndex(); BasketDto selectedBasket = getBasketsTableModel().getSelectedRow(); if (selectedBasket.isBranchlineEmpty()) { - selectedBasket.setBranchline(Sets.<BranchlineDto>newLinkedHashSet()); + selectedBasket.setBranchline(new LinkedHashSet<>()); } - List<BranchlineDto> branchlines = Lists.newArrayList(selectedBasket.getBranchline()); + List<BranchlineDto> branchlines = newArrayList(selectedBasket.getBranchline()); branchlines.add(selectedRowIndex, newBranchline); selectedBasket.getBranchline().clear(); selectedBasket.addAllBranchline(branchlines); @@ -981,9 +981,9 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong int selectedRowIndex = tableModel.getSelectedRowIndex(); BasketDto selectedBasket = getBasketsTableModel().getSelectedRow(); if (selectedBasket.isBranchlineEmpty()) { - selectedBasket.setBranchline(Sets.<BranchlineDto>newLinkedHashSet()); + selectedBasket.setBranchline(new LinkedHashSet<>()); } - List<BranchlineDto> branchlines = Lists.newArrayList(selectedBasket.getBranchline()); + List<BranchlineDto> branchlines = newArrayList(selectedBasket.getBranchline()); branchlines.add(selectedRowIndex, newBranchline); selectedBasket.getBranchline().clear(); selectedBasket.addAllBranchline(branchlines); @@ -1059,7 +1059,7 @@ public class LonglineDetailCompositionUIHandler extends ContentUIHandler<SetLong } - List<BasketDto> baskets = newSection == null ? Lists.<BasketDto>newArrayList() : Lists.newArrayList(newSection.getBasket()); + List<BasketDto> baskets = newSection == null ? new ArrayList<>() : newArrayList(newSection.getBasket()); getBasketsTableModel().setData(baskets); } finally { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIInitializer.java index 92d185e..25cf484 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIInitializer.java @@ -57,7 +57,7 @@ public class LonglineDetailCompositionUIInitializer extends ContentUIInitializer } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); LonglineDetailCompositionUIModel model = ui.getModel(); @@ -107,7 +107,7 @@ public class LonglineDetailCompositionUIInitializer extends ContentUIInitializer Decorator<SectionTemplate> sectionTemplateDecorator = decoratorService.getDecoratorByType(SectionTemplate.class); JComboBox comboBox = new JComboBox(); table.putClientProperty(LonglineDetailCompositionUIHandler.SECTION_TEMPLATES_EDITOR, comboBox); - ComboBoxCellEditor editor = newDataColumnEditor(comboBox, Collections.<SectionTemplate>emptyList(), sectionTemplateDecorator); + ComboBoxCellEditor editor = newDataColumnEditor(comboBox, Collections.emptyList(), sectionTemplateDecorator); UIHelper.setTableColumnEditor(table, 2, editor); SectionsTableModel tableModel = model.getSectionsTableModel(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java index ef26032..1c2061d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionUIValidationHelper.java @@ -382,7 +382,7 @@ public class LonglineDetailCompositionUIValidationHelper { public void addMessage(SwingValidator validator, NuitonValidatorScope scope, String field, String messageToAdd) { - String propertyLabel = decoratorService.getPropertyLabel(field); + String propertyLabel = DecoratorService.getPropertyLabel(field); SwingValidatorMessage message = new SwingValidatorMessage( validator, contextLabel + " - " + t(propertyLabel), diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java index 41f46fd..1eb5212 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/LonglineGlobalCompositionUIHandler.java @@ -57,7 +57,7 @@ import static org.nuiton.i18n.I18n.t; public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLonglineGlobalCompositionDto> { /** Logger */ - static private Log log = LogFactory.getLog(LonglineGlobalCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(LonglineGlobalCompositionUIHandler.class); public LonglineGlobalCompositionUIHandler(LonglineGlobalCompositionUI ui) { super(ui, DataContextType.ActivityLongline, DataContextType.SetLongline); @@ -93,7 +93,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); { // init floatlinesComposition tab @@ -130,7 +130,7 @@ public class LonglineGlobalCompositionUIHandler extends ContentUIHandler<SetLong } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); String activityId = getSelectedParentId(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java index dc8d10a..62b3347 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/longline/SetLonglineUIHandler.java @@ -64,7 +64,7 @@ import static org.nuiton.i18n.I18n.t; public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { /** Logger */ - static private Log log = LogFactory.getLog(SetLonglineUIHandler.class); + private static final Log log = LogFactory.getLog(SetLonglineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -154,7 +154,7 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -174,7 +174,7 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { @Override - public void openUI() throws Exception { + public void openUI() { getUi().getSettingStartCoordinates().resetModel(); getUi().getSettingEndCoordinates().resetModel(); @@ -372,7 +372,7 @@ public class SetLonglineUIHandler extends ContentUIHandler<SetLonglineDto> { } @Override - protected boolean doDelete(SetLonglineDto bean) throws Exception { + protected boolean doDelete(SetLonglineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIHandler.java index 4c0f636..a4d2e79 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIHandler.java @@ -44,7 +44,7 @@ import static org.nuiton.i18n.I18n.t; public class ActivitySeineObservedSystemUIHandler extends ContentUIHandler<ActivitySeineObservedSystemDto> { /** Logger */ - static private Log log = LogFactory.getLog(ActivitySeineObservedSystemUIHandler.class); + private static final Log log = LogFactory.getLog(ActivitySeineObservedSystemUIHandler.class); public ActivitySeineObservedSystemUIHandler(ActivitySeineObservedSystemUI ui) { super(ui, DataContextType.ActivitySeine, null); @@ -76,7 +76,7 @@ public class ActivitySeineObservedSystemUIHandler extends ContentUIHandler<Activ } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); String activityId = getSelectedParentId(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIModel.java index 1cf900c..6f10c45 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/ActivitySeineObservedSystemUIModel.java @@ -22,10 +22,8 @@ package fr.ird.observe.ui.content.impl.seine; * #L% */ -import fr.ird.observe.ObserveSwingBinderService; import fr.ird.observe.services.dto.seine.ActivitySeineObservedSystemDto; import fr.ird.observe.ui.content.ContentUIModel; -import org.nuiton.util.beans.BinderModelBuilder; /** * Created on 9/28/14. diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java index f6bfced..618ef5f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectTransmittingBuoyOperationUIHandler.java @@ -61,7 +61,7 @@ import static org.nuiton.i18n.I18n.t; public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIHandler<FloatingObjectTransmittingBuoyDto> { /** Logger */ - static private Log log = LogFactory.getLog(FloatingObjectTransmittingBuoyOperationUIHandler.class); + private static final Log log = LogFactory.getLog(FloatingObjectTransmittingBuoyOperationUIHandler.class); public FloatingObjectTransmittingBuoyOperationUIHandler(FloatingObjectTransmittingBuoyOperationUI ui) { super(ui, DataContextType.FloatingObject, null); @@ -101,7 +101,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); ContentMode mode = computeContentMode(); @@ -347,7 +347,7 @@ public class FloatingObjectTransmittingBuoyOperationUIHandler extends ContentUIH FloatingObjectTransmittingBuoyDto bean = getBean(); if (bean.getTransmittingBuoy() == null) { - bean.setTransmittingBuoy(Lists.<TransmittingBuoyDto>newArrayList()); + bean.setTransmittingBuoy(Lists.newArrayList()); } bean.getTransmittingBuoy().add(editBean); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java index 425303c..9e51cbc 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/FloatingObjectUIHandler.java @@ -50,7 +50,7 @@ import static org.nuiton.i18n.I18n.t; public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> { /** Logger */ - static private Log log = LogFactory.getLog(FloatingObjectUIHandler.class); + private static final Log log = LogFactory.getLog(FloatingObjectUIHandler.class); public FloatingObjectUIHandler(FloatingObjectUI ui) { super(ui, DataContextType.ActivitySeine, DataContextType.FloatingObject); @@ -96,7 +96,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); String activityId = getSelectedParentId(); @@ -205,7 +205,7 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto> } @Override - protected boolean doDelete(FloatingObjectDto bean) throws Exception { + protected boolean doDelete(FloatingObjectDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java index 4611e2c..bf32e9a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/impl/seine/SetSeineUIHandler.java @@ -65,7 +65,7 @@ import static org.nuiton.i18n.I18n.t; public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { /** Logger */ - static private Log log = LogFactory.getLog(SetSeineUIHandler.class); + private static final Log log = LogFactory.getLog(SetSeineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -132,7 +132,7 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -148,7 +148,7 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); String activityId = getSelectedParentId(); @@ -280,7 +280,7 @@ public class SetSeineUIHandler extends ContentUIHandler<SetSeineDto> { } } - protected boolean doDelete(SetSeineDto bean) throws Exception { + protected boolean doDelete(SetSeineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java index 6581a0e..24184b0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/ContentListUIHandler.java @@ -57,7 +57,7 @@ import static org.nuiton.i18n.I18n.t; public abstract class ContentListUIHandler<E extends IdDto, C extends DataDto> extends ContentUIHandler<E> { /** Logger */ - static private Log log = LogFactory.getLog(ContentListUIHandler.class); + private static final Log log = LogFactory.getLog(ContentListUIHandler.class); public ContentListUIHandler(ContentListUI<E, C> ui, DataContextType parentType, @@ -90,7 +90,7 @@ public abstract class ContentListUIHandler<E extends IdDto, C extends DataDto> e } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); // on installe un renderer sur la liste pour afficher les couleurs + @@ -98,14 +98,13 @@ public abstract class ContentListUIHandler<E extends IdDto, C extends DataDto> e ListCellRenderer renderer = getUi().getList().getCellRenderer(); ObserveTreeHelper treeHelper = getTreeHelper(getUi()); - ListCellRenderer renderer2 = - new EntityListCellRenderer(renderer, treeHelper); + ListCellRenderer renderer2 = new EntityListCellRenderer(renderer, treeHelper); getUi().getList().setCellRenderer(renderer2); } @Override - public final void openUI() throws Exception { + public final void openUI() { super.openUI(); @@ -205,11 +204,11 @@ public abstract class ContentListUIHandler<E extends IdDto, C extends DataDto> e private static final long serialVersionUID = 1L; - protected ListCellRenderer delegate; + protected final transient ListCellRenderer delegate; - protected ObserveTreeHelper treeHelper; + protected final transient ObserveTreeHelper treeHelper; - protected AbstractObserveTreeCellRenderer treeRenderer; + protected final AbstractObserveTreeCellRenderer treeRenderer; protected ObserveNode containerNode; @@ -217,7 +216,7 @@ public abstract class ContentListUIHandler<E extends IdDto, C extends DataDto> e ObserveTreeHelper treeHelper) { this.delegate = delegate; this.treeHelper = treeHelper; - treeRenderer = treeHelper.getTreeCellRenderer(); + this.treeRenderer = treeHelper.getTreeCellRenderer(); } public void init() { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java index 11e6a09..5ed8f08 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/longline/ActivityLonglinesUIHandler.java @@ -49,7 +49,7 @@ import static org.nuiton.i18n.I18n.n; public class ActivityLonglinesUIHandler extends ContentListUIHandler<TripLonglineDto, ActivityLonglineDto> { /** Logger */ - static private Log log = LogFactory.getLog(ActivityLonglinesUIHandler.class); + private static final Log log = LogFactory.getLog(ActivityLonglinesUIHandler.class); public ActivityLonglinesUIHandler(ActivityLonglinesUI ui) { super(ui, DataContextType.TripLongline, DataContextType.ActivityLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java index 36c54fe..d1b9adb 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/ActivitySeinesUIHandler.java @@ -46,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; public class ActivitySeinesUIHandler extends ContentListUIHandler<RouteDto, ActivitySeineDto> { /** Logger */ - static private Log log = LogFactory.getLog(ActivitySeinesUIHandler.class); + private static final Log log = LogFactory.getLog(ActivitySeinesUIHandler.class); public ActivitySeinesUIHandler(ActivitySeinesUI ui) { super(ui, DataContextType.Route, DataContextType.ActivitySeine); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java index f68f479..852a727 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/list/impl/seine/RoutesUIHandler.java @@ -46,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; public class RoutesUIHandler extends ContentListUIHandler<TripSeineDto, RouteDto> { /** Logger */ - static private Log log = LogFactory.getLog(RoutesUIHandler.class); + private static final Log log = LogFactory.getLog(RoutesUIHandler.class); public RoutesUIHandler(RoutesUI ui) { super(ui, DataContextType.TripSeine, DataContextType.Route); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java index c4aba45..6f3f2d3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/ActivityLonglineUIHandler.java @@ -52,7 +52,7 @@ import static org.nuiton.i18n.I18n.t; public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<ActivityLonglineDto> { /** Logger */ - static private Log log = LogFactory.getLog(ActivityLonglineUIHandler.class); + private static final Log log = LogFactory.getLog(ActivityLonglineUIHandler.class); static { @@ -142,14 +142,14 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity } // @Override -// public void initUI() throws Exception { +// public void initUI() { // super.initUI(); // getBean().removePropertyChangeListener(logCoordinatesChanges); // getBean().addPropertyChangeListener(logCoordinatesChanges); // } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); getUi().getCoordinatesEditor().resetModel(); @@ -280,7 +280,7 @@ public class ActivityLonglineUIHandler extends ContentOpenableUIHandler<Activity } @Override - protected boolean doDelete(ActivityLonglineDto bean) throws Exception { + protected boolean doDelete(ActivityLonglineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java index 113daa5..ed4a126 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/longline/TripLonglineUIHandler.java @@ -89,7 +89,7 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); TripLonglineUI ui = getUi(); @@ -126,7 +126,7 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); ContentMode mode = computeContentMode(); @@ -297,7 +297,7 @@ public class TripLonglineUIHandler extends ContentOpenableUIHandler<TripLongline } @Override - protected boolean doDelete(TripLonglineDto bean) throws Exception { + protected boolean doDelete(TripLonglineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java index 4e52fbd..822d36c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/ActivitySeineUIHandler.java @@ -56,7 +56,7 @@ import static org.nuiton.i18n.I18n.t; public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySeineDto> { /** Logger */ - static private Log log = LogFactory.getLog(ActivitySeineUIHandler.class); + private static final Log log = LogFactory.getLog(ActivitySeineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -157,7 +157,7 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -171,7 +171,7 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); getUi().getCoordinatesEditor().resetModel(); @@ -308,7 +308,7 @@ public class ActivitySeineUIHandler extends ContentOpenableUIHandler<ActivitySei } @Override - protected boolean doDelete(ActivitySeineDto bean) throws Exception { + protected boolean doDelete(ActivitySeineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java index fa3fa38..f57e9ea 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/RouteUIHandler.java @@ -58,7 +58,7 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { public static final String UPDATE_MAREE_NODE = "updateTripNode"; /** Logger */ - static private Log log = LogFactory.getLog(RouteUIHandler.class); + private static final Log log = LogFactory.getLog(RouteUIHandler.class); public RouteUIHandler(RouteUI ui) { super(ui, @@ -110,7 +110,7 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); @@ -243,7 +243,7 @@ public class RouteUIHandler extends ContentOpenableUIHandler<RouteDto> { } @Override - protected boolean doDelete(RouteDto bean) throws Exception { + protected boolean doDelete(RouteDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java index b466d5b..1a15566 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/open/impl/seine/TripSeineUIHandler.java @@ -87,7 +87,7 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); TripSeineUI ui = getUi(); @@ -124,7 +124,7 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); ContentMode mode = computeContentMode(); @@ -295,7 +295,7 @@ public class TripSeineUIHandler extends ContentOpenableUIHandler<TripSeineDto> { } @Override - protected boolean doDelete(TripSeineDto bean) throws Exception { + protected boolean doDelete(TripSeineDto bean) { if (askToDelete(bean)) { return false; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index f8d412d..e837fef 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -415,7 +415,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } @Override - public void initUI() throws Exception { + public void initUI() { uiInitializer.initUI(); @@ -428,7 +428,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); ContentReferenceUIModel<E> model = getModel(); @@ -732,7 +732,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } @Override - protected boolean doDelete(E bean) throws Exception { + protected boolean doDelete(E bean) { ContentReferenceUI<E> ui = getUi(); ContentReferenceUIModel<E> model = getModel(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/UniqueKeyTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/UniqueKeyTableModel.java index adfa54d..8775dd5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/UniqueKeyTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/UniqueKeyTableModel.java @@ -40,9 +40,9 @@ public class UniqueKeyTableModel extends AbstractTableModel { private static final long serialVersionUID = 1L; - protected String[] columns; + protected final String[] columns; - protected List<Object[]> datas; + protected final List<Object[]> datas; protected transient DecoratorService decoratorService; @@ -82,6 +82,6 @@ public class UniqueKeyTableModel extends AbstractTableModel { @Override public String getColumnName(int column) { String property = columns[column]; - return t(getDecoratorService().getPropertyLabel(property)); + return t(DecoratorService.getPropertyLabel(property)); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java index 1670939..599803b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/GearUIHandler.java @@ -56,7 +56,7 @@ public class GearUIHandler extends ContentReferenceUIHandler<GearDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java index 02321e3..f3cb36c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/LengthWeightParameterUIHandler.java @@ -56,7 +56,7 @@ public class LengthWeightParameterUIHandler extends ContentReferenceUIHandler<Le } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java index 8b66371..d45819b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ProgramUIHandler.java @@ -56,7 +56,7 @@ public class ProgramUIHandler extends ContentReferenceUIHandler<ProgramDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java index a2e36e9..2951983 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesListUIHandler.java @@ -56,7 +56,7 @@ public class SpeciesListUIHandler extends ContentReferenceUIHandler<SpeciesListD } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java index 5e33dbc..1928b3a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUIHandler.java @@ -56,7 +56,7 @@ public class SpeciesUIHandler extends ContentReferenceUIHandler<SpeciesDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java index 593d502..f00cb0e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/VesselUIHandler.java @@ -56,7 +56,7 @@ public class VesselUIHandler extends ContentReferenceUIHandler<VesselDto> { } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java index 100bb68..0dcdecd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableMeta.java @@ -25,6 +25,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.nuiton.util.ObjectUtil; import org.nuiton.util.beans.BeanUtil; @@ -42,20 +44,23 @@ import java.util.Set; */ public class ContentTableMeta<B> implements Serializable { + /** Logger. */ + private static final Log log = LogFactory.getLog(ContentTableMeta.class); + private static final long serialVersionUID = 1L; /** le lastName de la meta (c'est le nom de la colonne) */ - protected String name; + protected final String name; /** le type de la meta (c'estle type de la colonne) */ - protected Class<B> klass; + protected final Class<B> klass; /** * un drapeau pour savoir si on peut modifier cette méta lorsque l'objet * encapsulé existe déjà en base (pour pouvoir gérer les clefs métiers non * mutable) */ - protected boolean unmodiableWhenExisting; + protected final boolean unmodiableWhenExisting; /** * le descripteur de la méta (pour pouvoir récupérer et modifier la @@ -69,9 +74,8 @@ public class ContentTableMeta<B> implements Serializable { this.name = name; this.klass = klass; this.unmodiableWhenExisting = unmodiableWhenExisting; - if (ContentTableModel.log.isDebugEnabled()) { - ContentTableModel.log.debug(this + " : " + name + " : " + - getType().getName()); + if (log.isDebugEnabled()) { + log.debug(this + " : " + name + " : " + getType().getName()); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java index 3a18e97..5a41382 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableModel.java @@ -92,7 +92,7 @@ public abstract class ContentTableModel<P extends IdDto, B extends IdDto> extend private static final long serialVersionUID = 1L; /** Logger */ - protected static Log log = LogFactory.getLog(ContentTableModel.class); + private static final Log log = LogFactory.getLog(ContentTableModel.class); /** la liste des métas du modèle */ protected final List<ContentTableMeta<B>> metas; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java index 86764d1..c582d6c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIHandler.java @@ -69,7 +69,7 @@ import static org.nuiton.i18n.I18n.t; public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> extends ContentUIHandler<E> { /** Logger */ - private static Log log = LogFactory.getLog(ContentTableUIHandler.class); + private static final Log log = LogFactory.getLog(ContentTableUIHandler.class); protected ContentTableUIHandler(ObserveContentTableUI<E, D> ui, DataContextType dataContextType) { super(ui, dataContextType, null); @@ -244,7 +244,7 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex // } @Override - public void initUI() throws Exception { + public void initUI() { final ContentTableUIInitializer<E, D, ObserveContentTableUI<E, D>> uiInitializer = new ContentTableUIInitializer<>(getUi()); @@ -255,7 +255,7 @@ public abstract class ContentTableUIHandler<E extends IdDto, D extends IdDto> ex } @Override - public void openUI() throws Exception { + public void openUI() { super.openUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java index 4b3cf1a..1e47a6d 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIInitializer.java @@ -76,7 +76,7 @@ public class ContentTableUIInitializer<E extends IdDto, D extends IdDto, UI exte } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIModel.java index ea1a42c..778a655 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/ContentTableUIModel.java @@ -53,7 +53,7 @@ public abstract class ContentTableUIModel<E extends IdDto, D extends IdDto> exte private static final long serialVersionUID = 1L; /** Logger */ - private static Log log = LogFactory.getLog(ContentTableUIModel.class); + private static final Log log = LogFactory.getLog(ContentTableUIModel.class); protected final Class<D> childType; @@ -61,7 +61,7 @@ public abstract class ContentTableUIModel<E extends IdDto, D extends IdDto> exte protected final String[] childProperties; - private final ListSelectionModel selectionModel; + private final transient ListSelectionModel selectionModel; protected D tableEditBean; @@ -157,15 +157,14 @@ public abstract class ContentTableUIModel<E extends IdDto, D extends IdDto> exte } public final D newTableEditBean() { - D result = null; try { - result = getChildType().getConstructor().newInstance(); + + D result = getChildType().getConstructor().newInstance(); + return result; } catch (Exception ex) { throw new RuntimeException(ex); - } finally { - return result; } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java index 01ba8a9..d1aa5c4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIHandler.java @@ -46,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; public class BaitsCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, BaitsCompositionDto> { /** Logger */ - static private Log log = LogFactory.getLog(BaitsCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(BaitsCompositionUIHandler.class); public BaitsCompositionUIHandler(BaitsCompositionUI ui) { super(ui, DataContextType.SetLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java index 0e9797e..c83b88b 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BaitsCompositionUIModel.java @@ -73,6 +73,8 @@ public class BaitsCompositionUIModel extends ContentTableUIModel<SetLonglineGlob List<ContentTableMeta<BaitsCompositionDto>> contentTableMetas) { return new ContentTableModel<SetLonglineGlobalCompositionDto, BaitsCompositionDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; + @Override protected Collection<BaitsCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { return bean.getBaitsComposition(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java index ff6c9bf..cde391e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIHandler.java @@ -46,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; public class BranchlinesCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto> { /** Logger */ - static private Log log = LogFactory.getLog(BranchlinesCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(BranchlinesCompositionUIHandler.class); public BranchlinesCompositionUIHandler(BranchlinesCompositionUI ui) { super(ui, DataContextType.SetLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java index 94e0f0a..7520cd5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/BranchlinesCompositionUIModel.java @@ -72,6 +72,8 @@ public class BranchlinesCompositionUIModel extends ContentTableUIModel<SetLongli List<ContentTableMeta<BranchlinesCompositionDto>> contentTableMetas) { return new ContentTableModel<SetLonglineGlobalCompositionDto, BranchlinesCompositionDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; + @Override protected Collection<BranchlinesCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { return bean.getBranchlinesComposition(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchAcquisitionModeEnum.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchAcquisitionModeEnum.java index 01ff486..2292198 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchAcquisitionModeEnum.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchAcquisitionModeEnum.java @@ -37,7 +37,7 @@ public enum CatchAcquisitionModeEnum { GROUPED(n("observe.catchAcquisitionModeEnum.GROUPED")); - private String i18nKey; + private final String i18nKey; CatchAcquisitionModeEnum(String i18nKey) { this.i18nKey = i18nKey; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineTableModel.java index b400b17..f2a0b06 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineTableModel.java @@ -30,6 +30,8 @@ import fr.ird.observe.services.dto.longline.WeightMeasureDto; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.Collection; import java.util.List; @@ -43,6 +45,9 @@ import java.util.stream.Collectors; */ public class CatchLonglineTableModel extends ContentTableModel<SetLonglineCatchDto, CatchLonglineDto> { + /** Logger. */ + private static final Log log = LogFactory.getLog(CatchLonglineTableModel.class); + private static final long serialVersionUID = 1L; public CatchLonglineTableModel(ObserveContentTableUI<SetLonglineCatchDto, CatchLonglineDto> context, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java index c22d055..a012593 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/CatchLonglineUIHandler.java @@ -90,7 +90,7 @@ import static org.nuiton.i18n.I18n.t; public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCatchDto, CatchLonglineDto> { /** Logger */ - static private Log log = LogFactory.getLog(CatchLonglineUIHandler.class); + private static final Log log = LogFactory.getLog(CatchLonglineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -105,7 +105,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat private final PropertyChangeListener weightTableModelModified; - JAXXContextEntryDef<LonglinePositionHelper<CatchLonglineDto>> POSITION_HELPER_ENTRY = + private final JAXXContextEntryDef<LonglinePositionHelper<CatchLonglineDto>> POSITION_HELPER_ENTRY = UIHelper.newContextEntryDef("CatchLonglineUI-positionHelper", LonglinePositionHelper.class); public CatchLonglineUIHandler(CatchLonglineUI ui) { @@ -134,7 +134,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat } @Override - public void initUI() throws Exception { + public void initUI() { final CatchLonglineContentTableUIInitializer uiInitializer = new CatchLonglineContentTableUIInitializer(getUi()); uiInitializer.initUI(); @@ -164,7 +164,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat } @Override - public void openUI() throws Exception { + public void openUI() { if (log.isInfoEnabled()) { log.info("OpenUI: " + getModel()); @@ -303,7 +303,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat // load size measures SizeMeasuresTableModel sizeMeasuresTableModel = model.getSizeMeasuresTableModel(); - List<SizeMeasureDto> sizes = emptySelection ? Collections.<SizeMeasureDto>emptyList() : sizeMeasuresTableModel.getCacheForRow(editingRow); + List<SizeMeasureDto> sizes = emptySelection ? Collections.emptyList() : sizeMeasuresTableModel.getCacheForRow(editingRow); if (sizes == null) { if (log.isInfoEnabled()) { @@ -345,7 +345,7 @@ public class CatchLonglineUIHandler extends ContentTableUIHandler<SetLonglineCat // load weight measures WeightMeasuresTableModel weightMeasuresTableModel = model.getWeightMeasuresTableModel(); - List<WeightMeasureDto> weights = emptySelection ? Collections.<WeightMeasureDto>emptyList() : weightMeasuresTableModel.getCacheForRow(editingRow); + List<WeightMeasureDto> weights = emptySelection ? Collections.emptyList() : weightMeasuresTableModel.getCacheForRow(editingRow); if (weights == null) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java index 7cfb8f7..97e6b00 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIHandler.java @@ -59,7 +59,7 @@ import static org.nuiton.i18n.I18n.n; public class EncounterUIHandler extends ContentTableUIHandler<ActivityLonglineEncounterDto, EncounterDto> { /** Logger */ - static private Log log = LogFactory.getLog(EncounterUIHandler.class); + private static final Log log = LogFactory.getLog(EncounterUIHandler.class); public EncounterUIHandler(EncounterUI ui) { super(ui, DataContextType.ActivityLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIModel.java index 3ae0187..5fbdf08 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/EncounterUIModel.java @@ -71,6 +71,8 @@ public class EncounterUIModel extends ContentTableUIModel<ActivityLonglineEncoun ObserveContentTableUI<ActivityLonglineEncounterDto, EncounterDto> ui, List<ContentTableMeta<EncounterDto>> contentTableMetas) { return new ContentTableModel<ActivityLonglineEncounterDto, EncounterDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; + @Override protected Collection<EncounterDto> getChilds(ActivityLonglineEncounterDto bean) { return bean.getEncounter(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java index db19fbd..e146c41 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIHandler.java @@ -45,7 +45,7 @@ import static org.nuiton.i18n.I18n.n; public class FloatlinesCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto> { /** Logger */ - static private Log log = LogFactory.getLog(FloatlinesCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(FloatlinesCompositionUIHandler.class); public FloatlinesCompositionUIHandler(FloatlinesCompositionUI ui) { super(ui, DataContextType.SetLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java index 0a2f9ed..ac88c62 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/FloatlinesCompositionUIModel.java @@ -70,6 +70,7 @@ public class FloatlinesCompositionUIModel extends ContentTableUIModel<SetLonglin List<ContentTableMeta<FloatlinesCompositionDto>> contentTableMetas) { return new ContentTableModel<SetLonglineGlobalCompositionDto, FloatlinesCompositionDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<FloatlinesCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { return bean.getFloatlinesComposition(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineTableModel.java index bc2c615..ae3ba85 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineTableModel.java @@ -33,6 +33,8 @@ import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.Collection; import java.util.List; @@ -45,9 +47,12 @@ import java.util.List; */ public class GearUseFeaturesLonglineTableModel extends ContentTableModel<TripLonglineGearUseDto, GearUseFeaturesLonglineDto> { + /** Logger. */ + private static final Log log = LogFactory.getLog(GearUseFeaturesLonglineTableModel.class); + private static final long serialVersionUID = 1L; - private GearUseFeaturesLonglineUIHandler gearUseFeaturesLonglineUIHandler; + private transient GearUseFeaturesLonglineUIHandler gearUseFeaturesLonglineUIHandler; public GearUseFeaturesLonglineTableModel(ObserveContentTableUI<TripLonglineGearUseDto, GearUseFeaturesLonglineDto> context, List<ContentTableMeta<GearUseFeaturesLonglineDto>> contentTableMetas) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java index 0ecce5e..99ebe34 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/GearUseFeaturesLonglineUIHandler.java @@ -80,7 +80,7 @@ import static org.nuiton.i18n.I18n.t; public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<TripLonglineGearUseDto, GearUseFeaturesLonglineDto> { /** Logger */ - static private Log log = LogFactory.getLog(GearUseFeaturesLonglineUIHandler.class); + private static final Log log = LogFactory.getLog(GearUseFeaturesLonglineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -109,7 +109,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -125,7 +125,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip } @Override - public void openUI() throws Exception { + public void openUI() { if (log.isInfoEnabled()) { log.info("OpenUI: " + getModel()); @@ -236,7 +236,7 @@ public class GearUseFeaturesLonglineUIHandler extends ContentTableUIHandler<Trip // load size measures GearUseFeaturesMeasurementLonglinesTableModel measurementsTableModel = model.getMeasurementsTableModel(); - List<GearUseFeaturesMeasurementLonglineDto> measurements = emptySelection ? Collections.<GearUseFeaturesMeasurementLonglineDto>emptyList() : measurementsTableModel.getCacheForRow(editingRow); + List<GearUseFeaturesMeasurementLonglineDto> measurements = emptySelection ? Collections.emptyList() : measurementsTableModel.getCacheForRow(editingRow); if (measurements == null) { if (log.isInfoEnabled()) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java index cf8ea37..18f576e 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIHandler.java @@ -46,7 +46,7 @@ import static org.nuiton.i18n.I18n.n; public class HooksCompositionUIHandler extends ContentTableUIHandler<SetLonglineGlobalCompositionDto, HooksCompositionDto> { /** Logger */ - static private Log log = LogFactory.getLog(HooksCompositionUIHandler.class); + private static final Log log = LogFactory.getLog(HooksCompositionUIHandler.class); public HooksCompositionUIHandler(HooksCompositionUI ui) { super(ui, DataContextType.SetLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java index e14ca52..cc29463 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/HooksCompositionUIModel.java @@ -72,6 +72,7 @@ public class HooksCompositionUIModel extends ContentTableUIModel<SetLonglineGlob List<ContentTableMeta<HooksCompositionDto>> contentTableMetas) { return new ContentTableModel<SetLonglineGlobalCompositionDto, HooksCompositionDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<HooksCompositionDto> getChilds(SetLonglineGlobalCompositionDto bean) { return bean.getHooksComposition(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java index d1ef627..3f8ffc8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/LonglinePositionHelper.java @@ -188,10 +188,10 @@ public class LonglinePositionHelper<D extends LonglinePositionAwareDto> { dto.setBranchline(null); // on vide l'ensemble des paniers - uiBasket.setData(Collections.<DataReference<BasketDto>>emptyList()); + uiBasket.setData(Collections.emptyList()); // on vide l'ensemble des avançons - uiBranchline.setData(Collections.<DataReference<BranchlineDto>>emptyList()); + uiBranchline.setData(Collections.emptyList()); if (newValue != null) { @@ -239,7 +239,7 @@ public class LonglinePositionHelper<D extends LonglinePositionAwareDto> { dto.setBranchline(null); // on vide l'ensemble des avançons - uiBranchline.setData(Collections.<DataReference<BranchlineDto>>emptyList()); + uiBranchline.setData(Collections.emptyList()); if (newValue != null) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java index 4aa271e..1096aa5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIHandler.java @@ -62,7 +62,7 @@ import static org.nuiton.i18n.I18n.t; public class SensorUsedUIHandler extends ContentTableUIHandler<ActivityLonglineSensorUsedDto, SensorUsedDto> { /** Logger */ - static private Log log = LogFactory.getLog(SensorUsedUIHandler.class); + private static final Log log = LogFactory.getLog(SensorUsedUIHandler.class); public SensorUsedUIHandler(SensorUsedUI ui) { super(ui, DataContextType.ActivityLongline); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIModel.java index d133125..ebcd761 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/SensorUsedUIModel.java @@ -76,6 +76,7 @@ public class SensorUsedUIModel extends ContentTableUIModel<ActivityLonglineSenso List<ContentTableMeta<SensorUsedDto>> contentTableMetas) { return new ContentTableModel<ActivityLonglineSensorUsedDto, SensorUsedDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<SensorUsedDto> getChilds(ActivityLonglineSensorUsedDto bean) { return bean.getSensorUsed(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java index 159cc0f..6c72d8c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIHandler.java @@ -80,7 +80,7 @@ import static org.nuiton.i18n.I18n.t; public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDto> { /** Logger */ - static private Log log = LogFactory.getLog(TdrUIHandler.class); + private static final Log log = LogFactory.getLog(TdrUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -90,7 +90,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt protected boolean toogleTimeEditorSliderIsChanging; - JAXXContextEntryDef<LonglinePositionHelper<TdrDto>> POSITION_HELPER_ENTRY = + private static final JAXXContextEntryDef<LonglinePositionHelper<TdrDto>> POSITION_HELPER_ENTRY = UIHelper.newContextEntryDef("TdrUI-positionHelper", LonglinePositionHelper.class); public TdrUIHandler(TdrUI ui) { @@ -190,7 +190,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -210,7 +210,7 @@ public class TdrUIHandler extends ContentTableUIHandler<SetLonglineTdrDto, TdrDt } @Override - public void openUI() throws Exception { + public void openUI() { if (log.isInfoEnabled()) { log.info("OpenUI: " + getModel()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIModel.java index f2f7724..fdc86e5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/longline/TdrUIModel.java @@ -162,6 +162,7 @@ public class TdrUIModel extends ContentTableUIModel<SetLonglineTdrDto, TdrDto> { ObserveContentTableUI<SetLonglineTdrDto, TdrDto> ui, List<ContentTableMeta<TdrDto>> contentTableMetas) { return new ContentTableModel<SetLonglineTdrDto, TdrDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<TdrDto> getChilds(SetLonglineTdrDto bean) { return bean.getTdr(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeatureMeasurementCellEditor.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeatureMeasurementCellEditor.java index 05c5217..94d73b8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeatureMeasurementCellEditor.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeatureMeasurementCellEditor.java @@ -46,9 +46,7 @@ import java.util.TreeMap; */ public class GearUseFeatureMeasurementCellEditor implements TableCellEditor { - private static final long serialVersionUID = 1L; - - protected int caracteristicColumn; + protected final int caracteristicColumn; protected TableCellEditor editor; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineTableModel.java index a585b3e..7bcfb7c 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineTableModel.java @@ -33,6 +33,8 @@ import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.util.Collection; import java.util.List; @@ -45,9 +47,12 @@ import java.util.List; */ public class GearUseFeaturesSeineTableModel extends ContentTableModel<TripSeineGearUseDto, GearUseFeaturesSeineDto> { + /** Logger. */ + private static final Log log = LogFactory.getLog(GearUseFeaturesSeineTableModel.class); + private static final long serialVersionUID = 1L; - private GearUseFeaturesSeineUIHandler gearUseFeaturesSeineUIHandler; + private transient GearUseFeaturesSeineUIHandler gearUseFeaturesSeineUIHandler; public GearUseFeaturesSeineTableModel(ObserveContentTableUI<TripSeineGearUseDto, GearUseFeaturesSeineDto> context, List<ContentTableMeta<GearUseFeaturesSeineDto>> contentTableMetas) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java index c0f8b43..f3c55b3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/GearUseFeaturesSeineUIHandler.java @@ -78,7 +78,7 @@ import static org.nuiton.i18n.I18n.t; public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSeineGearUseDto, GearUseFeaturesSeineDto> { /** Logger */ - static private Log log = LogFactory.getLog(GearUseFeaturesSeineUIHandler.class); + private static final Log log = LogFactory.getLog(GearUseFeaturesSeineUIHandler.class); // Compute valid state of tab from the error table protected final TableModelListener computeTabValidStateListener; @@ -107,7 +107,7 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); @@ -123,7 +123,7 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei } @Override - public void openUI() throws Exception { + public void openUI() { if (log.isInfoEnabled()) { log.info("OpenUI: " + getModel()); @@ -235,7 +235,7 @@ public class GearUseFeaturesSeineUIHandler extends ContentTableUIHandler<TripSei // load size measures GearUseFeaturesMeasurementSeinesTableModel measurementsTableModel = model.getMeasurementsTableModel(); - List<GearUseFeaturesMeasurementSeineDto> measurements = emptySelection ? Collections.<GearUseFeaturesMeasurementSeineDto>emptyList() : measurementsTableModel.getCacheForRow(editingRow); + List<GearUseFeaturesMeasurementSeineDto> measurements = emptySelection ? Collections.emptyList() : measurementsTableModel.getCacheForRow(editingRow); if (measurements == null) { if (log.isInfoEnabled()) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ModeSaisieEchantillonEnum.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ModeSaisieEchantillonEnum.java index 068f3aa..3239ca3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ModeSaisieEchantillonEnum.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ModeSaisieEchantillonEnum.java @@ -47,7 +47,7 @@ public enum ModeSaisieEchantillonEnum { */ byIndividu(n("observe.modeSaisieEchantillonEnum.byIndividu")); - private String i18nKey; + private final String i18nKey; ModeSaisieEchantillonEnum(String i18nKey) { this.i18nKey = i18nKey; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java index 025a509..2207293 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIHandler.java @@ -69,7 +69,7 @@ import static org.nuiton.i18n.I18n.t; public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetSeineNonTargetCatchDto, NonTargetCatchDto> { /** Logger */ - static private Log log = LogFactory.getLog(NonTargetCatchUIHandler.class); + private static final Log log = LogFactory.getLog(NonTargetCatchUIHandler.class); /** * Ecoute les modifications de la propriété {@link NonTargetCatchDto#getTotalCount()}, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIModel.java index 3f6f79c..d02baf1 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetCatchUIModel.java @@ -84,6 +84,7 @@ public class NonTargetCatchUIModel extends ContentTableUIModel<SetSeineNonTarget List<ContentTableMeta<NonTargetCatchDto>> contentTableMetas) { return new ContentTableModel<SetSeineNonTargetCatchDto, NonTargetCatchDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<NonTargetCatchDto> getChilds(SetSeineNonTargetCatchDto bean) { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java index 869a802..1e25c13 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIHandler.java @@ -63,7 +63,7 @@ import static org.nuiton.i18n.I18n.t; public class NonTargetSampleUIHandler extends ContentTableUIHandler<NonTargetSampleDto, NonTargetLengthDto> { /** Logger */ - static private Log log = LogFactory.getLog(NonTargetSampleUIHandler.class); + private static final Log log = LogFactory.getLog(NonTargetSampleUIHandler.class); /** * Ecoute les modifications de la propriété {@link NonTargetLengthDto#getWeight()}, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIModel.java index 5219102..9aa7bd6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/NonTargetSampleUIModel.java @@ -86,6 +86,7 @@ public class NonTargetSampleUIModel extends ContentTableUIModel<NonTargetSampleD @Override protected ContentTableModel<NonTargetSampleDto, NonTargetLengthDto> createTableModel(ObserveContentTableUI<NonTargetSampleDto, NonTargetLengthDto> ui, List<ContentTableMeta<NonTargetLengthDto>> contentTableMetas) { return new ContentTableModel<NonTargetSampleDto, NonTargetLengthDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<NonTargetLengthDto> getChilds(NonTargetSampleDto bean) { return bean.getNonTargetLength(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java index e43f56f..ade5863 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIHandler.java @@ -57,8 +57,7 @@ import static org.nuiton.i18n.I18n.n; public class ObjectObservedSpeciesUIHandler extends ContentTableUIHandler<FloatingObjectObservedSpeciesDto, ObjectObservedSpeciesDto> { /** Logger */ - static private Log log = - LogFactory.getLog(ObjectObservedSpeciesUIHandler.class); + private static final Log log = LogFactory.getLog(ObjectObservedSpeciesUIHandler.class); public ObjectObservedSpeciesUIHandler(ObjectObservedSpeciesUI ui) { super(ui, DataContextType.SetSeine); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIModel.java index 023ae0d..7e802f3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectObservedSpeciesUIModel.java @@ -72,6 +72,7 @@ public class ObjectObservedSpeciesUIModel extends ContentTableUIModel<FloatingOb List<ContentTableMeta<ObjectObservedSpeciesDto>> contentTableMetas) { return new ContentTableModel<FloatingObjectObservedSpeciesDto, ObjectObservedSpeciesDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<ObjectObservedSpeciesDto> getChilds(FloatingObjectObservedSpeciesDto bean) { return bean.getObjectObservedSpecies(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java index c99d39e..72d0d89 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIHandler.java @@ -56,7 +56,7 @@ public class ObjectSchoolEstimateUIHandler extends ContentTableUIHandler<Floatin /** Logger */ - static private Log log = LogFactory.getLog(ObjectSchoolEstimateUIHandler.class); + private static final Log log = LogFactory.getLog(ObjectSchoolEstimateUIHandler.class); public ObjectSchoolEstimateUIHandler(ObjectSchoolEstimateUI ui) { super(ui, DataContextType.SetSeine); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIModel.java index dd6d814..5456579 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/ObjectSchoolEstimateUIModel.java @@ -70,6 +70,7 @@ public class ObjectSchoolEstimateUIModel extends ContentTableUIModel<FloatingObj List<ContentTableMeta<ObjectSchoolEstimateDto>> contentTableMetas) { return new ContentTableModel<FloatingObjectSchoolEstimateDto, ObjectSchoolEstimateDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<ObjectSchoolEstimateDto> getChilds(FloatingObjectSchoolEstimateDto bean) { return bean.getObjectSchoolEstimate(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java index 4987006..4a2a299 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIHandler.java @@ -60,7 +60,7 @@ import static org.nuiton.i18n.I18n.n; public class SchoolEstimateUIHandler extends ContentTableUIHandler<SetSeineSchoolEstimateDto, SchoolEstimateDto> { /** Logger */ - static private Log log = LogFactory.getLog(SchoolEstimateUIHandler.class); + private static final Log log = LogFactory.getLog(SchoolEstimateUIHandler.class); public SchoolEstimateUIHandler(SchoolEstimateUI ui) { super(ui, DataContextType.SetSeine); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIModel.java index c210868..286062a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/SchoolEstimateUIModel.java @@ -72,6 +72,7 @@ public class SchoolEstimateUIModel extends ContentTableUIModel<SetSeineSchoolEst List<ContentTableMeta<SchoolEstimateDto>> contentTableMetas) { return new ContentTableModel<SetSeineSchoolEstimateDto, SchoolEstimateDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<SchoolEstimateDto> getChilds(SetSeineSchoolEstimateDto bean) { return bean.getSchoolEstimate(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index 05427ed..f23dbd2 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -80,7 +80,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); // lors de la modification d'une species (sur une entree non sauvee) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java index e5c3262..976ccce 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java @@ -78,6 +78,7 @@ public class TargetCatchUIModel extends ContentTableUIModel<SetSeineTargetCatchD ObserveContentTableUI<SetSeineTargetCatchDto, TargetCatchDto> ui, List<ContentTableMeta<TargetCatchDto>> contentTableMetas) { return new ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<TargetCatchDto> getChilds(SetSeineTargetCatchDto bean) { return bean.getTargetCatch(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index e11f990..f50a7ef 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -71,7 +71,7 @@ import static org.nuiton.i18n.I18n.t; public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCatchDto, TargetCatchDto> { /** Logger */ - static private Log log = LogFactory.getLog(TargetDiscardCatchUIHandler.class); + private static final Log log = LogFactory.getLog(TargetDiscardCatchUIHandler.class); public TargetDiscardCatchUIHandler(TargetDiscardCatchUI ui) { super(ui, DataContextType.SetSeine); @@ -108,7 +108,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineT } @Override - public void initUI() throws Exception { + public void initUI() { super.initUI(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java index 7115cb9..1c22ad0 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java @@ -78,6 +78,7 @@ public class TargetDiscardCatchUIModel extends ContentTableUIModel<SetSeineTarge List<ContentTableMeta<TargetCatchDto>> contentTableMetas) { return new ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<TargetCatchDto> getChilds(SetSeineTargetCatchDto bean) { return bean.getTargetCatch(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java index 990af33..3b3ef8f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIHandler.java @@ -61,7 +61,7 @@ import static org.nuiton.i18n.I18n.t; public class TargetSampleUIHandler extends ContentTableUIHandler<TargetSampleDto, TargetLengthDto> { /** Logger */ - static private Log log = LogFactory.getLog(TargetSampleUIHandler.class); + private static final Log log = LogFactory.getLog(TargetSampleUIHandler.class); /** * Pour différencier positionner l'invariant de l'écran diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIModel.java index f116c8e..73d392a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetSampleUIModel.java @@ -79,6 +79,7 @@ public class TargetSampleUIModel extends ContentTableUIModel<TargetSampleDto, Ta ObserveContentTableUI<TargetSampleDto, TargetLengthDto> ui, List<ContentTableMeta<TargetLengthDto>> contentTableMetas) { return new ContentTableModel<TargetSampleDto, TargetLengthDto>(ui, contentTableMetas) { + private static final long serialVersionUID = 1L; @Override protected Collection<TargetLengthDto> getChilds(TargetSampleDto bean) { return bean.getTargetLength(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/ObstunaAdminAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/ObstunaAdminAction.java index 964f01f..6c2fd97 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/ObstunaAdminAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/ObstunaAdminAction.java @@ -188,7 +188,7 @@ public enum ObstunaAdminAction { } @Override - protected void applySecurity() throws Exception { + protected void applySecurity() { if (log.isInfoEnabled()) { log.info("Apply security..."); } @@ -249,7 +249,7 @@ public enum ObstunaAdminAction { } @Override - protected void applySecurity() throws Exception { + protected void applySecurity() { if (log.isInfoEnabled()) { log.info("Apply security..."); } @@ -299,7 +299,7 @@ public enum ObstunaAdminAction { } @Override - protected void applySecurity() throws Exception { + protected void applySecurity() { if (log.isInfoEnabled()) { log.info("Apply security..."); } @@ -310,7 +310,7 @@ public enum ObstunaAdminAction { }; /** Logger */ - static private Log log = LogFactory.getLog(ObstunaAdminAction.class); + private static final Log log = LogFactory.getLog(ObstunaAdminAction.class); private final String label; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java index de1e08d..86ead38 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/RemoteUILauncher.java @@ -42,7 +42,7 @@ import java.util.List; public abstract class RemoteUILauncher extends StorageUILauncher { /** Logger */ - static private Log log = LogFactory.getLog(RemoteUILauncher.class); + private static final Log log = LogFactory.getLog(RemoteUILauncher.class); protected ObstunaAdminAction action; @@ -137,6 +137,6 @@ public abstract class RemoteUILauncher extends StorageUILauncher { protected void execute() throws Exception { } - protected void applySecurity() throws Exception { + protected void applySecurity() { } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java index 074cbbf..abbddfe 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageBackupUILauncher.java @@ -46,7 +46,7 @@ public class StorageBackupUILauncher extends StorageUILauncher { /** * Logger */ - static private Log log = LogFactory.getLog(StorageBackupUILauncher.class); + private static final Log log = LogFactory.getLog(StorageBackupUILauncher.class); public StorageBackupUILauncher(JAXXContext context, Window frame, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java index 1c29079..6096c18 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIHandler.java @@ -111,8 +111,6 @@ public class StorageUIHandler { @Override public void onOpened(ObserveSwingDataSourceEvent event) { - ObserveSwingDataSource source = event.getSource(); - ObserveSwingApplicationContext context = ObserveSwingApplicationContext.get(); // la base locale existe desormais context.getConfig().setLocalStorageExist(true); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUILauncher.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUILauncher.java index c6be8a2..12584be 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUILauncher.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUILauncher.java @@ -53,7 +53,7 @@ public class StorageUILauncher extends WizardUILancher<StorageStep, StorageUIMod /** Logger */ private static final Log log = LogFactory.getLog(StorageUILauncher.class); - protected String title; + protected final String title; public StorageUILauncher(JAXXContext context, Window frame, diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java index 8fda354..eddc5d8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/StorageUIModel.java @@ -1245,7 +1245,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { setRemoteLogin(restConfig.getLogin()); setRemoteUrl(restConfig.getServerUrl() == null ? "" : restConfig.getServerUrl().toString()); setRemotePassword(restConfig.getPassword()); - setServerDatabase(restConfig.getOptionalDatabaseName().orNull()); + setServerDatabase(restConfig.getOptionalDatabaseName().orElse(null)); } } @@ -1430,7 +1430,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { } public String getServerDatabase() { - return restConfig.getOptionalDatabaseName().orNull(); + return restConfig.getOptionalDatabaseName().orElse(null); } public ConnexionStatus getConnexionStatus() { @@ -1455,7 +1455,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { public void setRemoteLogin(String remoteLogin) { - String oldValue = getRemoteLogin(); +// String oldValue = getRemoteLogin(); if (isEditRemoteConfig()) { @@ -1471,7 +1471,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { } public void setRemotePassword(char[] remotePassword) { - char[] oldValue = getRemotePassword(); +// char[] oldValue = getRemotePassword(); if (isEditRemoteConfig()) { @@ -1655,7 +1655,7 @@ public class StorageUIModel extends WizardModel<StorageStep> { restConfig.getServerUrl(), restConfig.getLogin(), restConfig.getPassword(), - restConfig.getOptionalDatabaseName().orNull(), + restConfig.getOptionalDatabaseName().orElse(null), restConfig.getModelVersion() ); return result; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java index 2fd9b00..c4bc8e5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/DataSelectionModel.java @@ -38,7 +38,6 @@ import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialDtos; import fr.ird.observe.services.dto.referential.ReferentialReference; import fr.ird.observe.services.dto.seine.TripSeineDto; -import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.services.service.longline.TripLonglineService; import fr.ird.observe.services.service.seine.TripSeineService; import org.apache.commons.collections4.CollectionUtils; @@ -63,14 +62,12 @@ import java.util.stream.Collectors; */ public class DataSelectionModel implements Serializable { - public static void populate(DataSelectionModel model, - ObserveSwingDataSource source) throws Exception { + public static void populate(DataSelectionModel model, ObserveSwingDataSource source) { Preconditions.checkState(source.isOpen()); Map<ReferentialReference<ProgramDto>, List<DataReference>> datas = Maps.newHashMap(); - ReferentialService referentialService = source.newService(ReferentialService.class); TripSeineService tripSeineService = source.newService(TripSeineService.class); TripLonglineService tripLonglineService = source.newService(TripLonglineService.class); @@ -162,7 +159,7 @@ public class DataSelectionModel implements Serializable { protected final PropertyChangeSupport pcs; - public void populate() throws Exception { + public void populate() { throw new UnsupportedOperationException(); } @@ -217,7 +214,7 @@ public class DataSelectionModel implements Serializable { } public int selectDataSize() { - return selectedData == null ? 0 :selectedData.size(); + return selectedData == null ? 0 : selectedData.size(); } public Set<Class<? extends ReferentialDto>> getSelectedReferentiel() { @@ -289,8 +286,8 @@ public class DataSelectionModel implements Serializable { } List<DataReference> result = datas.get(program).stream() - .filter(trip -> selectedData.contains(trip)) - .collect(Collectors.toList()); + .filter(trip -> selectedData.contains(trip)) + .collect(Collectors.toList()); return result; } @@ -504,7 +501,7 @@ public class DataSelectionModel implements Serializable { if (!referentiel.contains(type)) { throw new IllegalArgumentException( "given <" + type + "> is not in referentiel universe : " + - referentiel); + referentiel); } } @@ -524,7 +521,7 @@ public class DataSelectionModel implements Serializable { } public List<DataReference> getDatas(String programId) { - Optional<ReferentialReference<ProgramDto>> programRefOptional = Iterables.tryFind(getDatas().keySet(), ReferentialReference.newIdPredicate(programId)); + Optional<ReferentialReference<ProgramDto>> programRefOptional = Iterables.tryFind(getDatas().keySet(), ReferentialReference.newIdPredicate(programId)::apply); List<DataReference> result; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/SecurityModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/SecurityModel.java index 96b3fa0..ab4b170 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/SecurityModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/storage/tabs/SecurityModel.java @@ -21,7 +21,6 @@ */ package fr.ird.observe.ui.storage.tabs; -import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -53,18 +52,11 @@ public class SecurityModel implements Serializable { private static final long serialVersionUID = 1L; - public static final Function<String, String> ESCAPE_STRING = new Function<String, String>() { - @Override - public String apply(String input) { - return "\"" + input + "\""; - } - }; - protected ObserveDbUserDto administrateur; - protected Set<ObserveDbUserDto> users; + protected final Set<ObserveDbUserDto> users; - protected PropertyChangeSupport pcs = new PropertyChangeSupport(this); + protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); public SecurityModel() { users = Sets.newHashSet(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java index ef2df02..c2c3f30 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/DataSelectionTreeSelectionModel.java @@ -79,7 +79,7 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop protected TreePath[] selection; /** Event listener list. */ - protected EventListenerList listenerList = new EventListenerList(); + protected final EventListenerList listenerList = new EventListenerList(); /** Last path that was added. */ protected TreePath leadPath; @@ -641,7 +641,7 @@ public class DataSelectionTreeSelectionModel implements TreeSelectionModel, Prop // recalcule de la selection List<TreePath> oldSelection = isSelectionEmpty() ? - Collections.<TreePath>emptyList() : + Collections.emptyList() : Arrays.asList(selection); List<TreePath> newSelection = new ArrayList<>(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeBridge.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeBridge.java index a6139de..72f53df 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeBridge.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeBridge.java @@ -46,7 +46,7 @@ public class ObserveTreeBridge extends NavTreeBridge<ObserveNode> { protected JTree ui; - protected List<String> pathToSelect; + protected final List<String> pathToSelect; public ObserveTreeBridge() { pathToSelect = new ArrayList<>(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java index e0b5e52..6da0450 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/ObserveTreeHelper.java @@ -501,7 +501,7 @@ public class ObserveTreeHelper extends NavTreeHelper<ObserveNode> { return result; } - public ObserveNode addProgram(ReferentialReference<ProgramDto> bean) throws Exception { + public ObserveNode addProgram(ReferentialReference<ProgramDto> bean) { Set<ReferentialReference<ProgramDto>> programs = getDataProvider().getDataSource().getReferentialReferences(ProgramDto.class); List data = Lists.newArrayList(programs); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java index 2630d0b..7259ef5 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/tree/loadors/RootNodeChildLoador.java @@ -22,11 +22,9 @@ package fr.ird.observe.ui.tree.loadors; import com.google.common.collect.Lists; -import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.services.dto.constants.GearType; import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialReference; -import fr.ird.observe.services.service.ReferentialService; import fr.ird.observe.ui.storage.tabs.DataSelectionModel; import fr.ird.observe.ui.tree.ObserveNode; import fr.ird.observe.ui.tree.ObserveTreeHelper; @@ -85,7 +83,6 @@ public class RootNodeChildLoador extends AbstractNodeChildLoador<ReferentialRefe if (selectionModel != null) { data = Lists.newArrayList(selectionModel.getDatas().keySet()); } else { - ReferentialService service = ObserveSwingApplicationContext.get().newService(ReferentialService.class); Set<ReferentialReference<ProgramDto>> referentialReferenceSet = getDataSource(dataProvider).getReferentialReferences(ProgramDto.class); data = new ArrayList<>(referentialReferenceSet); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSwingValidatorMessageTableModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSwingValidatorMessageTableModel.java index 8b91b0b..f5e3410 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSwingValidatorMessageTableModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/ObserveSwingValidatorMessageTableModel.java @@ -22,7 +22,6 @@ package fr.ird.observe.ui.util; * #L% */ -import com.google.common.base.Predicate; import jaxx.runtime.validator.swing.SwingValidatorMessage; import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel; import org.nuiton.validator.NuitonValidatorScope; @@ -30,6 +29,7 @@ import org.nuiton.validator.NuitonValidatorScope; import javax.swing.JComponent; import java.util.Collection; import java.util.Collections; +import java.util.function.Predicate; /** * Created on 3/18/15. @@ -61,7 +61,7 @@ public class ObserveSwingValidatorMessageTableModel extends SwingValidatorMessag for (int i = getRowCount() - 1; i > -1; i--) { SwingValidatorMessage error = data.get(i); - if (predicate.apply(error)) { + if (predicate.test(error)) { // remove the message data.remove(i); fireTableRowsDeleted(i, i); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/AbstractSelectTableAction.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/AbstractSelectTableAction.java index f31f952..7959d50 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/AbstractSelectTableAction.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/AbstractSelectTableAction.java @@ -28,7 +28,6 @@ import org.apache.commons.logging.LogFactory; import javax.swing.AbstractAction; import javax.swing.JTable; -import java.io.Serializable; /** * Abstract action to select a cell in a table. @@ -81,7 +80,7 @@ public abstract class AbstractSelectTableAction<M extends EditableTableModelSupp protected boolean isCellEditable(int rowIndex, int columnIndex) { boolean result = rowIndex > -1 && columnIndex > -1 && - table.isCellEditable(rowIndex, columnIndex); + table.isCellEditable(rowIndex, columnIndex); return result; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableList.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableList.java index 19b2c35..5b7dad3 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableList.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableList.java @@ -60,6 +60,6 @@ public class EditableList<E extends Serializable> implements Serializable { } public void reset() { - setData(Collections.<E>emptyList()); + setData(Collections.emptyList()); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java index d9ed766..bd416fd 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/EditableTableModelSupport.java @@ -90,7 +90,7 @@ public abstract class EditableTableModelSupport<E extends Serializable> extends protected int selectedRowIndex = -1; /* -1 = pas de selection */ /** la liste des données du modèle */ - protected List<E> data = new ArrayList<>(); + protected final List<E> data = new ArrayList<>(); private JTable table; @@ -279,7 +279,7 @@ public abstract class EditableTableModelSupport<E extends Serializable> extends public void clear() { setSelectedRowIndex(-1); - setData(Collections.<E>emptyList()); + setData(Collections.emptyList()); validate(); setModified(false); fireEmpty(); @@ -468,7 +468,7 @@ public abstract class EditableTableModelSupport<E extends Serializable> extends NumberCellEditor editor = (NumberCellEditor) cellEditor; editor.getNumberEditor().getTextField().addFocusListener(focusAdapter); } else if (cellEditor instanceof ComboBoxCellEditor) { - ComboBoxCellEditor editor = (ComboBoxCellEditor) cellEditor; +// ComboBoxCellEditor editor = (ComboBoxCellEditor) cellEditor; //FIXME should also use the focus listener here } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/ObserveBooleanTableCellRenderer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/ObserveBooleanTableCellRenderer.java index fd47031..a4a04fe 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/ObserveBooleanTableCellRenderer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/table/ObserveBooleanTableCellRenderer.java @@ -22,8 +22,6 @@ package fr.ird.observe.ui.util.table; * #L% */ -import com.google.common.base.Predicate; - import javax.swing.Icon; import javax.swing.JCheckBox; import javax.swing.JComponent; @@ -32,6 +30,7 @@ import javax.swing.JTable; import javax.swing.table.TableCellRenderer; import java.awt.Color; import java.awt.Component; +import java.util.function.Predicate; /** * TODO A remonter dans JAXX. @@ -49,13 +48,7 @@ public class ObserveBooleanTableCellRenderer extends JCheckBox implements TableC private final Predicate predicate; - private static final Predicate<Object> DEFAULT_PREDICATE = new Predicate<Object>() { - - @Override - public boolean apply(Object input) { - return (input != null && (Boolean) input); - } - }; + private static final Predicate<?> DEFAULT_PREDICATE = input -> (input != null && (Boolean) input); public ObserveBooleanTableCellRenderer(TableCellRenderer delegate, Predicate<?> predicate) { this(delegate, null, predicate); @@ -91,7 +84,7 @@ public class ObserveBooleanTableCellRenderer extends JCheckBox implements TableC } } - boolean selectCheckBox = predicate.apply(value); + boolean selectCheckBox = predicate.test(value); setSelected(selectCheckBox); setBorder(render.getBorder()); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserveMapPane.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserveMapPane.java index ea0164c..3db6f45 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserveMapPane.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserveMapPane.java @@ -53,6 +53,7 @@ import static org.nuiton.i18n.I18n.t; */ public class ObserveMapPane extends JMapPane { + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(ObserveMapPane.class); protected static final int MARGIN = 10; @@ -169,11 +170,11 @@ public class ObserveMapPane extends JMapPane { for (CardinalPoint cardinalPoint : CardinalPoint.values()) { - Point2D direction = cardinalPoint.getDirection(rotation, (int) (AXIS_LENGTH), center); + Point2D direction = cardinalPoint.getDirection(rotation, AXIS_LENGTH, center); - Point2D sommet1 = cardinalPoint.getDirection(rotation - Math.PI / 4, (int) (SUB_AXIS_LENGTH), center); + Point2D sommet1 = cardinalPoint.getDirection(rotation - Math.PI / 4, SUB_AXIS_LENGTH, center); - Point2D sommet2 = cardinalPoint.getDirection(rotation + Math.PI / 4, (int) (SUB_AXIS_LENGTH), center); + Point2D sommet2 = cardinalPoint.getDirection(rotation + Math.PI / 4, SUB_AXIS_LENGTH, center); Polygon polygon = new Polygon(); @@ -189,7 +190,7 @@ public class ObserveMapPane extends JMapPane { // on cherche la ditance entre le centre du text et sa bordure dans le direction donné double l = cardinalPoint.distanceCenterBorder(rotation, textArea); - Point2D textCenter = cardinalPoint.getDirection(rotation, (int) (AXIS_LENGTH + INTER_AXIS_TEXT) + l, center); + Point2D textCenter = cardinalPoint.getDirection(rotation, AXIS_LENGTH + INTER_AXIS_TEXT + l, center); graphics.drawString( cardinalPoint.getLabel(), diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserverMapPanLegendDrawer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserverMapPanLegendDrawer.java index ff728eb..8003536 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserverMapPanLegendDrawer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/ObserverMapPanLegendDrawer.java @@ -22,19 +22,13 @@ package fr.ird.observe.ui.util.tripMap; * #L% */ -import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.LineString; -import com.vividsolutions.jts.geom.LinearRing; -import com.vividsolutions.jts.geom.Point; import org.geotools.geometry.jts.LiteShape; import org.geotools.legend.Drawer; import org.geotools.styling.LineSymbolizer; -import org.geotools.styling.PointSymbolizer; import org.geotools.styling.Rule; import org.geotools.styling.SLD; import org.geotools.styling.Symbolizer; -import org.geotools.styling.TextSymbolizer; import org.opengis.feature.simple.SimpleFeature; import java.awt.BasicStroke; @@ -48,9 +42,9 @@ import java.awt.image.BufferedImage; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ -public class ObserverMapPanLegendDrawer { +public class ObserverMapPanLegendDrawer { - protected Drawer drawer; + protected final Drawer drawer; public ObserverMapPanLegendDrawer() { @@ -58,11 +52,11 @@ public class ObserverMapPanLegendDrawer { } - public void drawDirect(BufferedImage bi, SimpleFeature feature, Rule rule){ + public void drawDirect(BufferedImage bi, SimpleFeature feature, Rule rule) { AffineTransform affineTransform = new AffineTransform(); LiteShape shape = new LiteShape(null, affineTransform, false); - for(Symbolizer symbolizer : rule.getSymbolizers()) { + for (Symbolizer symbolizer : rule.getSymbolizers()) { if (symbolizer instanceof LineSymbolizer) { LineSymbolizer lineSymbolizer = (LineSymbolizer) symbolizer; @@ -76,20 +70,20 @@ public class ObserverMapPanLegendDrawer { Color c = SLD.color(lineSymbolizer); - int w = SLD.width( lineSymbolizer ); + int w = SLD.width(lineSymbolizer); float[] lineDash = SLD.lineDash(lineSymbolizer); - if( c != null && w > 0 ){ - g.setColor( c ); + if (c != null && w > 0) { + g.setColor(c); Stroke str = new BasicStroke( w, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, lineDash, 0.0f - ); + ); g.setStroke(str); - g.draw( shape ); + g.draw(shape); } } } else { diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java index 77eaa56..2458001 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapContentBuilder.java @@ -97,8 +97,8 @@ public class TripMapContentBuilder { public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM"); protected StyledLayerDescriptor styledLayerDescriptor; - protected MapContent mapContent; - protected List<ObserveMapPaneLegendItem> legendItems; + protected final MapContent mapContent; + protected final List<ObserveMapPaneLegendItem> legendItems; public TripMapContentBuilder() { mapContent = new MapContent(); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java index 7c2319c..73e0b8f 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tripMap/TripMapUIHandler.java @@ -68,7 +68,7 @@ public class TripMapUIHandler { private static final Log log = LogFactory.getLog(TripMapUIHandler.class); - protected TripMapUI view; + protected final TripMapUI view; private ObserveSwingApplicationConfig config; protected ReferencedEnvelope tripArea; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationMessageDetector.java b/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationMessageDetector.java deleted file mode 100644 index 0cc7206..0000000 --- a/observe-application-swing/src/main/java/fr/ird/observe/validation/ValidationMessageDetector.java +++ /dev/null @@ -1,560 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.validation; - -import fr.ird.observe.ObserveSwingApplicationContext; -import fr.ird.observe.db.DataContext; -import fr.ird.observe.services.dto.IdDto; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.validator.bean.simple.SimpleBeanValidator; -import org.nuiton.validator.bean.simple.SimpleBeanValidatorEvent; -import org.nuiton.validator.bean.simple.SimpleBeanValidatorListener; -import org.nuiton.validator.bean.simple.SimpleBeanValidatorMessage; - -import java.util.Collection; -import java.util.Deque; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Set; - -/** - * Le detecteur de messages de validation. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.3 - */ -public class ValidationMessageDetector implements SimpleBeanValidatorListener { - - /** Logger */ - private static final Log log = - LogFactory.getLog(ValidationMessageDetector.class); - - public static final String SEPARATOR = "/"; - - /** le path courant depuis le depart */ - protected Deque<IdDto> path; - - /** le dictionnaire des paths d'entites detectees */ -// protected SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> refs; - - protected StringBuilder accessorExpression; - - protected IdDto root; - -// protected TopiaEntityRef currentRef; - - protected Set<IdDto> explored; - - /** le dictionnaire des validateurs utilisables */ - protected final ValidatorsMap validators; - - protected ValidationContext context; - - public ValidationContext getContext() { - if (context == null) { - ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get(); - context = applicationContext.getValidationContext(); - } - return context; - } - - public ValidationMessageDetector(ValidatorsMap validators) { - this.validators = validators; - path = new LinkedList<>(); - explored = new HashSet<>(); - //FIXME -// refs = new TreeMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>>(); - accessorExpression = new StringBuilder(); - for (SimpleBeanValidator<?> v : validators.values()) { - v.setBean(null); - } - } - - public void detectMessages(IdDto... entities) { -// try { - // on reinitialise tous les validateurs -// for (BeanValidator<?> v : validators.values()) { -// v.setBean(null); -//// v.setContextName(contextName); -// } - for (IdDto e : entities) { - if (log.isDebugEnabled()) { - log.debug("start for entity " + e.getId()); - } - // détection sur l'entité e - //FIXME -// try { -// e.accept(this); -// } catch (TopiaException e1) { -// throw new RuntimeException("could not vist entity " + e.getTopiaId(), e1); -// } - } - } - -// @Override - public void start(IdDto e) { - if (root == null) { - // start come in start method since - // last clear method invocation - root = e; - addPath(e, "$root", -1); - } - explored.add(e); - SimpleBeanValidator<IdDto> validator = getValidator(e); - if (log.isDebugEnabled()) { - log.debug("with entity " + e.getId() + " : " + accessorExpression); - } - if (validator != null) { - validator.addSimpleBeanValidatorListener(this); - addEntityInContext(e); - //FIXME -// try { -// currentRef = new TopiaEntityRef( -// root, -// e, -// accessorExpression.toString(), -// path.toArray(new TopiaEntity[path.size()])); -// validator.setBean(e); -// } finally { -// validator.removeSimpleBeanValidatorListener(this); -// validator.setBean(null); -// } - } - } - -// @Override - public void end(IdDto e) { - if (root != null && root.equals(e)) { - // global visit is done - root = null; - removePath(); - } - removeEntityFromContext(e); - } - - private void addEntityInContext(IdDto e) { - - DataContext context = getContext().getDataContext(); - - //FIXME -// ObserveEntityEnum anEnum = ObserveEntityEnum.valueOf(e); -// switch (anEnum) { -// case Route: -// context.setSelectedRouteId(e.getTopiaId()); -// break; -// case TripSeine: { -// context.setSelectedTripId(e.getTopiaId()); -// Program program = ((TripSeine) e).getProgram(); -// if (program != null) { -// context.setSelectedProgramId(program.getTopiaId()); -// } else { -// context.setSelectedProgramId(null); -// } -// } -// break; -// case ActivitySeine: -// context.setSelectedActivityId(e.getTopiaId()); -// break; -// case SetSeine: -// context.setSelectedSetId(e.getTopiaId()); -// break; -// case TripLongline: { -// context.setSelectedTripId(e.getTopiaId()); -// Program program = ((TripLongline) e).getProgram(); -// if (program != null) { -// context.setSelectedProgramId(program.getTopiaId()); -// } else { -// context.setSelectedProgramId(null); -// } -// } -// break; -// case ActivityLongline: -// context.setSelectedActivityId(e.getTopiaId()); -// break; -// case SetLongline: -// context.setSelectedSetId(e.getTopiaId()); -// break; -// case FloatingObject: -// context.setSelectedFloatingObjectId(e.getTopiaId()); -// break; -// case NonTargetLength: -// break; -// case TargetLength: -// break; -// case TransmittingBuoy: -// break; -// case NonTargetCatch: -// break; -// case TargetCatch: -// break; -// case NonTargetSample: -// break; -// case TargetSample: -// break; -// case ObjectObservedSpecies: -// break; -// case SchoolEstimate: -// break; -// case ObjectSchoolEstimate: -// break; -// case VesselActivitySeine: -// break; -// case SurroundingActivity: -// break; -// case Vessel: -// break; -// case VesselSizeCategory: -// break; -// case WeightCategory: -// break; -// case ReasonForNullSet: -// break; -// case ReasonForNoFishing: -// break; -// case SpeciesFate: -// break; -// case ObjectFate: -// break; -// case Species: -// break; -// case SpeciesGroup: -// break; -// case DetectionMode: -// break; -// case Person: -// break; -// case Ocean: -// break; -// case TransmittingBuoyOperation: -// break; -// case ObjectOperation: -// break; -// case Organism: -// break; -// case LengthWeightParameter: -// break; -// case Country: -// break; -// case Program: -// break; -// case ReasonForDiscard: -// break; -// case SpeciesStatus: -// break; -// case ObservedSystem: -// break; -// case TransmittingBuoyType: -// break; -// case VesselType: -// break; -// case ObjectType: -// break; -// case Wind: -// break; -// } - } - - private void removeEntityFromContext(IdDto e) { - - DataContext context = getContext().getDataContext(); - - //FIXME -// ObserveEntityEnum anEnum = ObserveEntityEnum.valueOf(e); -// switch (anEnum) { -// case Route: -// context.setSelectedRouteId(null); -// break; -// case TripSeine: -// context.setSelectedTripId(null); -// context.setSelectedProgramId(null); -// break; -// case ActivitySeine: -// context.setSelectedActivityId(null); -// break; -// case SetSeine: -// context.setSelectedSetId(null); -// break; -// case TripLongline: -// context.setSelectedTripId(null); -// context.setSelectedProgramId(null); -// break; -// case ActivityLongline: -// context.setSelectedActivityId(null); -// break; -// case SetLongline: -// context.setSelectedSetId(null); -// break; -// case FloatingObject: -// context.setSelectedFloatingObjectId(null); -// break; -// case NonTargetLength: -// break; -// case TargetLength: -// break; -// case TransmittingBuoy: -// break; -// case NonTargetCatch: -// break; -// case TargetCatch: -// break; -// case NonTargetSample: -// break; -// case TargetSample: -// break; -// case ObjectObservedSpecies: -// break; -// case SchoolEstimate: -// break; -// case ObjectSchoolEstimate: -// break; -// case VesselActivitySeine: -// break; -// case SurroundingActivity: -// break; -// case Vessel: -// break; -// case VesselSizeCategory: -// break; -// case WeightCategory: -// break; -// case ReasonForNullSet: -// break; -// case ReasonForNoFishing: -// break; -// case SpeciesFate: -// break; -// case ObjectFate: -// break; -// case Species: -// break; -// case SpeciesGroup: -// break; -// case DetectionMode: -// break; -// case Person: -// break; -// case Ocean: -// break; -// case TransmittingBuoyOperation: -// break; -// case ObjectOperation: -// break; -// case Organism: -// break; -// case LengthWeightParameter: -// break; -// case Country: -// break; -// case Program: -// break; -// case ReasonForDiscard: -// break; -// case SpeciesStatus: -// break; -// case ObservedSystem: -// break; -// case TransmittingBuoyType: -// break; -// case VesselType: -// break; -// case ObjectType: -// break; -// case Wind: -// break; -// } - } - -// @Override - public void visit(IdDto e, - String name, - Class<?> type, - Object value) { - IdDto e1 = getTopiaValue(value); - if (e1 != null) { - addPath(e1, name, -1); - try { - //FIXME -// try { -// e1.accept(this); -// } catch (TopiaException ex) { -// if (log.isErrorEnabled()) { -// log.error(ex.getMessage(), ex); -// } -// } - } finally { - removePath(); - } - } - } - -// @Override - public void visit(IdDto e, - String name, - Class<?> collectionType, - Class<?> type, - int index, - Object value) { - IdDto e1 = getTopiaValue(value); - if (e1 != null) { - addPath(e1, name, index); - try { - //FIXME -// try { -// e1.accept(this); -// } catch (TopiaException ex) { -// if (log.isErrorEnabled()) { -// log.error(ex.getMessage(), ex); -// } -// } - } finally { - removePath(); - } - } - } - -// @Override - public void visit(IdDto e, - String name, - Class<?> collectionType, - Class<?> type, - Object value) { - Collection<?> cValue = (Collection<?>) value; - if (IdDto.class.isAssignableFrom(type) && - cValue != null && !cValue.isEmpty()) { - int i = 0; - for (Object currentValue : cValue) { - visit(e, name, collectionType, type, i++, currentValue); - } - } - } - - //FIXME -// public SortedMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> getRefs() { -// // on renvoie toujours une copie -// // pour pouvoir au plus tôt nettoyer le detecteur -// TreeMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>> result; -// result = new TreeMap<TopiaEntityRef, List<SimpleBeanValidatorMessage<?>>>(refs); -// return result; -// } - - //FIXME -// @Override - public void clear() { - path.clear(); -// refs.clear(); - root = null; - explored.clear(); - accessorExpression.setLength(0); - } - - protected IdDto getTopiaValue(Object value) { - IdDto topiaEntity = (IdDto) (value != null && - value instanceof IdDto ? value : null); - if (topiaEntity != null && explored.contains(topiaEntity)) { - // entite deja visitee - topiaEntity = null; - } - return topiaEntity; - } - - protected <T extends IdDto> SimpleBeanValidator<T> getValidator(T e) { - Class<T> contractClass; - //FIXME -// contractClass = (Class<T>) ObserveDAOHelper.getContractClass(e.getClass()); -// return validators.getValidator(contractClass); - return null; - } - - protected void addPath(IdDto e, String name, int index) { - path.add(e); - if (accessorExpression.length() > 0) { - accessorExpression.append(SEPARATOR); - } - accessorExpression.append(name); - if (index > -1) { - //FIXME - accessorExpression.append("[@topiaId=\""); - accessorExpression.append(e.getId()); - accessorExpression.append("\"]"); - } - if (log.isTraceEnabled()) { - log.trace("add to stack : " + e.getId() + ", new size : " + - path.size() + ", path : " + accessorExpression); - } - } - - protected void removePath() { - IdDto e = path.removeLast(); - if (path.isEmpty()) { - accessorExpression.setLength(0); - } else { - int index = accessorExpression.lastIndexOf(SEPARATOR); - if (index > -1) { - accessorExpression.delete(index, - accessorExpression.length()); - } - } - if (log.isTraceEnabled()) { - log.trace("remove from stack : " + e.getId() + - ", new size : " + path.size() + ", path : " + - accessorExpression); - } - } - - @Override - public void onFieldChanged(SimpleBeanValidatorEvent event) { - SimpleBeanValidator<?> validator = event.getSource(); - - // on ne traite que les messages a ajouter - String[] messagesToAdd = event.getMessagesToAdd(); - - if (messagesToAdd == null || messagesToAdd.length == 0) { - return; - } - - //FIXME -// if (log.isDebugEnabled()) { -// log.debug("will add " + Arrays.toString(messagesToAdd) + -// " for " + currentRef.getAccessorExpression()); -// } -// List<SimpleBeanValidatorMessage<?>> list = refs.get(currentRef); -// if (list == null) { -// // first time for this entity -// list = new ArrayList<SimpleBeanValidatorMessage<?>>(); -// refs.put(currentRef, list); -// } - for (String m : messagesToAdd) { - SimpleBeanValidatorMessage<?> message; - message = new SimpleBeanValidatorMessage( - validator, - event.getField(), - m, - event.getScope()); - if (log.isDebugEnabled()) { - log.debug("add message " + message); - } - //FIXME -// list.add(message); - } - } -} diff --git a/observe-application-swing/src/test/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionValidatorServiceTest.java b/observe-application-swing/src/test/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionValidatorServiceTest.java index f84dbf2..4bedf20 100644 --- a/observe-application-swing/src/test/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionValidatorServiceTest.java +++ b/observe-application-swing/src/test/java/fr/ird/observe/ui/content/impl/longline/LonglineDetailCompositionValidatorServiceTest.java @@ -59,7 +59,7 @@ public class LonglineDetailCompositionValidatorServiceTest { protected LonglineDetailCompositionUIValidationHelper.LonglineDetailCompositionValidatorService service; @Before - public void setUp() throws Exception { + public void setUp() { if (ObserveSwingApplicationContext.isInit()) { diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/ObserveWebMotionRender.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/ObserveWebMotionRender.java index 07905fb..106e90a 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/ObserveWebMotionRender.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/ObserveWebMotionRender.java @@ -40,7 +40,7 @@ import java.io.PrintWriter; */ public class ObserveWebMotionRender<T> extends Render { - protected T model; + protected final T model; public ObserveWebMotionRender(T model) { this.model = model; diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/ObserveWebApplicationConfigurationOption.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/ObserveWebApplicationConfigurationOption.java index 2776124..817d5d9 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/ObserveWebApplicationConfigurationOption.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/ObserveWebApplicationConfigurationOption.java @@ -31,7 +31,6 @@ import org.nuiton.version.Version; import java.io.File; import java.net.URL; import java.util.Collections; -import java.util.Comparator; import java.util.List; import static org.nuiton.i18n.I18n.n; @@ -125,13 +124,7 @@ public enum ObserveWebApplicationConfigurationOption implements ConfigOptionDef public static ImmutableList<ObserveWebApplicationConfigurationOption> orderedByNameValues() { List<ObserveWebApplicationConfigurationOption> values = Lists.newArrayList(values()); - Collections.sort(values, new Comparator<ObserveWebApplicationConfigurationOption>() { - - @Override - public int compare(ObserveWebApplicationConfigurationOption o1, ObserveWebApplicationConfigurationOption o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }); + Collections.sort(values, (o1, o2) -> o1.getKey().compareTo(o2.getKey())); return ImmutableList.copyOf(values); } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabase.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabase.java index 5c5d22a..1003be9 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabase.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabase.java @@ -22,9 +22,8 @@ package fr.ird.observe.application.web.configuration.db; * #L% */ -import com.google.common.base.Optional; - import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabases.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabases.java index 9f9072c..16930fb 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabases.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabases.java @@ -22,9 +22,8 @@ package fr.ird.observe.application.web.configuration.db; * #L% */ -import com.google.common.base.Optional; - import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseBean.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseBean.java index 16d9dbd..5fcb4dc 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseBean.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseBean.java @@ -22,12 +22,11 @@ package fr.ird.observe.application.web.configuration.db.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabase; import java.util.LinkedHashSet; +import java.util.Optional; /** * Created on 30/08/15. @@ -85,12 +84,6 @@ public class ObserveWebDatabaseBean implements ObserveWebDatabase<ObserveWebData } public ObserveWebDatabaseImmutable toImmutable() { - return new ObserveWebDatabaseImmutable(name, defaultDatabase, url, Iterables.transform(roles, new Function<ObserveWebDatabaseRoleBean, ObserveWebDatabaseRoleImmutable>() { - - @Override - public ObserveWebDatabaseRoleImmutable apply(ObserveWebDatabaseRoleBean input) { - return input.toImmutable(); - } - })); + return new ObserveWebDatabaseImmutable(name, defaultDatabase, url, Iterables.transform(roles, ObserveWebDatabaseRoleBean::toImmutable)); } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseImmutable.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseImmutable.java index 5a0df27..9409318 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseImmutable.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabaseImmutable.java @@ -22,8 +22,6 @@ package fr.ird.observe.application.web.configuration.db.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -31,6 +29,7 @@ import com.google.common.collect.Sets; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabase; import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. @@ -54,13 +53,7 @@ public class ObserveWebDatabaseImmutable implements ObserveWebDatabase<ObserveWe this.name = name; this.defaultDatabase = defaultDatabase; this.url = url; - this.roles = Maps.uniqueIndex(roles, new Function<ObserveWebDatabaseRoleImmutable, String>() { - - @Override - public String apply(ObserveWebDatabaseRoleImmutable input) { - return input.getLogin(); - } - }); + this.roles = Maps.uniqueIndex(roles, input -> input.getLogin()); } @Override @@ -86,7 +79,7 @@ public class ObserveWebDatabaseImmutable implements ObserveWebDatabase<ObserveWe @Override public Optional<ObserveWebDatabaseRoleImmutable> getDatabaseRoleByLogin(String login) { ObserveWebDatabaseRoleImmutable observeWebDatabaseRole = roles.get(login); - return Optional.fromNullable(observeWebDatabaseRole); + return Optional.ofNullable(observeWebDatabaseRole); } public ObserveWebDatabaseBean toBean() { @@ -94,13 +87,7 @@ public class ObserveWebDatabaseImmutable implements ObserveWebDatabase<ObserveWe observeWebDatabaseBean.setDefaultDatabase(defaultDatabase); observeWebDatabaseBean.setName(name); observeWebDatabaseBean.setUrl(url); - observeWebDatabaseBean.setRoles(Sets.newLinkedHashSet(Iterables.transform(getRoles(), new Function<ObserveWebDatabaseRoleImmutable, ObserveWebDatabaseRoleBean>() { - - @Override - public ObserveWebDatabaseRoleBean apply(ObserveWebDatabaseRoleImmutable input) { - return input.toBean(); - } - }))); + observeWebDatabaseBean.setRoles(Sets.newLinkedHashSet(Iterables.transform(getRoles(), ObserveWebDatabaseRoleImmutable::toBean))); return observeWebDatabaseBean; } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesBean.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesBean.java index efd3385..d70c074 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesBean.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesBean.java @@ -22,12 +22,11 @@ package fr.ird.observe.application.web.configuration.db.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabases; import java.util.LinkedHashSet; +import java.util.Optional; /** * Created on 30/08/15. @@ -60,13 +59,7 @@ public class ObserveWebDatabasesBean implements ObserveWebDatabases<ObserveWebDa public ObserveWebDatabasesImmutable toImmutable() { - return new ObserveWebDatabasesImmutable(Iterables.transform(databases, new Function<ObserveWebDatabaseBean, ObserveWebDatabaseImmutable>() { - - @Override - public ObserveWebDatabaseImmutable apply(ObserveWebDatabaseBean input) { - return input.toImmutable(); - } - })); + return new ObserveWebDatabasesImmutable(Iterables.transform(databases, input -> input.toImmutable())); } public void setDatabases(LinkedHashSet<ObserveWebDatabaseBean> databases) { diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesImmutable.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesImmutable.java index 98840af..160be2c 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesImmutable.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/db/impl/ObserveWebDatabasesImmutable.java @@ -22,8 +22,6 @@ package fr.ird.observe.application.web.configuration.db.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -31,6 +29,7 @@ import com.google.common.collect.Sets; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabases; import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. @@ -44,13 +43,7 @@ public class ObserveWebDatabasesImmutable implements ObserveWebDatabases<Observe private final ObserveWebDatabaseImmutable defaultDatabase; public ObserveWebDatabasesImmutable(Iterable<ObserveWebDatabaseImmutable> databases) { - this.databases = Maps.uniqueIndex(databases, new Function<ObserveWebDatabaseImmutable, String>() { - - @Override - public String apply(ObserveWebDatabaseImmutable input) { - return input.getName(); - } - }); + this.databases = Maps.uniqueIndex(databases, input -> input.getName()); ObserveWebDatabaseImmutable defaultDb = null; for (ObserveWebDatabaseImmutable database : databases) { @@ -81,18 +74,12 @@ public class ObserveWebDatabasesImmutable implements ObserveWebDatabases<Observe @Override public Optional<ObserveWebDatabaseImmutable> getDatabaseByName(String databaseName) { ObserveWebDatabaseImmutable database = databases.get(databaseName); - return Optional.fromNullable(database); + return Optional.ofNullable(database); } public ObserveWebDatabasesBean toBean() { ObserveWebDatabasesBean observeWebDatabasesBean = new ObserveWebDatabasesBean(); - observeWebDatabasesBean.setDatabases(Sets.newLinkedHashSet(Iterables.transform(getDatabases(), new Function<ObserveWebDatabaseImmutable, ObserveWebDatabaseBean>() { - - @Override - public ObserveWebDatabaseBean apply(ObserveWebDatabaseImmutable input) { - return input.toBean(); - } - }))); + observeWebDatabasesBean.setDatabases(Sets.newLinkedHashSet(Iterables.transform(getDatabases(), input -> input.toBean()))); return observeWebDatabasesBean; } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUser.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUser.java index 90c4377..6f073a9 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUser.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUser.java @@ -22,9 +22,8 @@ package fr.ird.observe.application.web.configuration.user; * #L% */ -import com.google.common.base.Optional; - import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsers.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsers.java index 665db68..a9dbbe3 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsers.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsers.java @@ -22,9 +22,8 @@ package fr.ird.observe.application.web.configuration.user; * #L% */ -import com.google.common.base.Optional; - import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelper.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelper.java index acab15b..b0175eb 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelper.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelper.java @@ -27,7 +27,6 @@ import com.esotericsoftware.yamlbeans.YamlException; import com.esotericsoftware.yamlbeans.YamlReader; import com.esotericsoftware.yamlbeans.YamlWriter; import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.io.Files; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabase; import fr.ird.observe.application.web.configuration.db.ObserveWebDatabaseRole; @@ -46,6 +45,7 @@ import java.io.File; import java.io.Reader; import java.io.Writer; import java.util.LinkedHashSet; +import java.util.Optional; import java.util.Set; /** @@ -81,7 +81,7 @@ public class ObserveWebUsersHelper { return result; } - public void validateObserveWebUsersBean(ObserveWebDatabases databases, ObserveWebUsersBean observeWebUsersBean) throws InvalidObserveWebUsersException, InvalidObserveWebUserException, InvalidObserveWebUserPermissionException { + public void validateObserveWebUsersBean(ObserveWebDatabases databases, ObserveWebUsersBean observeWebUsersBean) throws InvalidObserveWebUserException, InvalidObserveWebUserPermissionException { if (CollectionUtils.isEmpty(observeWebUsersBean.getUsers())) { throw new InvalidObserveWebUserException("No user defined"); diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserBean.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserBean.java index d141460..84d4354 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserBean.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserBean.java @@ -22,12 +22,11 @@ package fr.ird.observe.application.web.configuration.user.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import fr.ird.observe.application.web.configuration.user.ObserveWebUser; import java.util.LinkedHashSet; +import java.util.Optional; /** * Created on 30/08/15. @@ -75,13 +74,7 @@ public class ObserveWebUserBean implements ObserveWebUser<ObserveWebUserPermissi } public ObserveWebUserImmutable toImmutable() { - return new ObserveWebUserImmutable(login, password, Iterables.transform(roles, new Function<ObserveWebUserPermissionBean, ObserveWebUserPermissionImmutable>() { - - @Override - public ObserveWebUserPermissionImmutable apply(ObserveWebUserPermissionBean input) { - return input.toImmutable(); - } - })); + return new ObserveWebUserImmutable(login, password, Iterables.transform(roles, ObserveWebUserPermissionBean::toImmutable)); } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserImmutable.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserImmutable.java index d9aaf9b..de23bce 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserImmutable.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUserImmutable.java @@ -22,8 +22,6 @@ package fr.ird.observe.application.web.configuration.user.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -31,6 +29,7 @@ import com.google.common.collect.Sets; import fr.ird.observe.application.web.configuration.user.ObserveWebUser; import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. @@ -49,13 +48,7 @@ public class ObserveWebUserImmutable implements ObserveWebUser<ObserveWebUserPer this.login = login; this.password = password; - this.permissions = Maps.uniqueIndex(permissions, new Function<ObserveWebUserPermissionImmutable, String>() { - - @Override - public String apply(ObserveWebUserPermissionImmutable input) { - return input.getDatabase(); - } - }); + this.permissions = Maps.uniqueIndex(permissions, ObserveWebUserPermissionImmutable::getDatabase); } @@ -76,20 +69,14 @@ public class ObserveWebUserImmutable implements ObserveWebUser<ObserveWebUserPer @Override public Optional<ObserveWebUserPermissionImmutable> getPermissionByDatabaseName(String databaseName) { - return Optional.fromNullable(permissions.get(databaseName)); + return Optional.ofNullable(permissions.get(databaseName)); } public ObserveWebUserBean toBean() { ObserveWebUserBean observeWebUserBean = new ObserveWebUserBean(); observeWebUserBean.setLogin(login); observeWebUserBean.setPassword(password); - observeWebUserBean.setPermissions(Sets.newLinkedHashSet(Iterables.transform(getPermissions(), new Function<ObserveWebUserPermissionImmutable, ObserveWebUserPermissionBean>() { - - @Override - public ObserveWebUserPermissionBean apply(ObserveWebUserPermissionImmutable input) { - return input.toBean(); - } - }))); + observeWebUserBean.setPermissions(Sets.newLinkedHashSet(Iterables.transform(getPermissions(), ObserveWebUserPermissionImmutable::toBean))); return observeWebUserBean; } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersBean.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersBean.java index 1bdc870..e18a763 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersBean.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersBean.java @@ -22,12 +22,11 @@ package fr.ird.observe.application.web.configuration.user.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import fr.ird.observe.application.web.configuration.user.ObserveWebUsers; import java.util.LinkedHashSet; +import java.util.Optional; /** * Created on 30/08/15. @@ -53,13 +52,7 @@ public class ObserveWebUsersBean implements ObserveWebUsers<ObserveWebUserBean> } public ObserveWebUsersImmutable toImmutable() { - return new ObserveWebUsersImmutable(Iterables.transform(users, new Function<ObserveWebUserBean, ObserveWebUserImmutable>() { - - @Override - public ObserveWebUserImmutable apply(ObserveWebUserBean input) { - return input.toImmutable(); - } - })); + return new ObserveWebUsersImmutable(Iterables.transform(users, ObserveWebUserBean::toImmutable)); } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersImmutable.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersImmutable.java index 3510b4e..7f4fe68 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersImmutable.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/configuration/user/impl/ObserveWebUsersImmutable.java @@ -22,8 +22,6 @@ package fr.ird.observe.application.web.configuration.user.impl; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -31,6 +29,7 @@ import com.google.common.collect.Sets; import fr.ird.observe.application.web.configuration.user.ObserveWebUsers; import java.util.Collection; +import java.util.Optional; /** * Created on 30/08/15. @@ -42,13 +41,7 @@ public class ObserveWebUsersImmutable implements ObserveWebUsers<ObserveWebUserI private final ImmutableMap<String, ObserveWebUserImmutable> users; public ObserveWebUsersImmutable(Iterable<ObserveWebUserImmutable> users) { - this.users = Maps.uniqueIndex(users, new Function<ObserveWebUserImmutable, String>() { - - @Override - public String apply(ObserveWebUserImmutable input) { - return input.getLogin(); - } - }); + this.users = Maps.uniqueIndex(users, ObserveWebUserImmutable::getLogin); } @Override @@ -58,18 +51,12 @@ public class ObserveWebUsersImmutable implements ObserveWebUsers<ObserveWebUserI @Override public Optional<ObserveWebUserImmutable> getUserByLogin(String login) { - return Optional.fromNullable(users.get(login)); + return Optional.ofNullable(users.get(login)); } public ObserveWebUsersBean toBean() { ObserveWebUsersBean observeWebUsersBean = new ObserveWebUsersBean(); - observeWebUsersBean.setUsers(Sets.newLinkedHashSet(Iterables.transform(getUsers(), new Function<ObserveWebUserImmutable, ObserveWebUserBean>() { - - @Override - public ObserveWebUserBean apply(ObserveWebUserImmutable input) { - return input.toBean(); - } - }))); + observeWebUsersBean.setUsers(Sets.newLinkedHashSet(Iterables.transform(getUsers(), ObserveWebUserImmutable::toBean))); return observeWebUsersBean; } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java index c95c772..a4d2513 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/DataSourceServiceController.java @@ -22,7 +22,6 @@ package fr.ird.observe.application.web.controller.v1; * #L% */ -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import fr.ird.observe.application.web.request.ObserveWebRequestContext; import fr.ird.observe.application.web.security.ObserveWebSecurityApplicationContext; @@ -44,6 +43,7 @@ import fr.ird.observe.services.service.DatabaseNotFoundException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.Optional; import java.util.Set; /** diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/converter/ObserveDtoConverter.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/converter/ObserveDtoConverter.java index a892019..1d85b3d 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/converter/ObserveDtoConverter.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/converter/ObserveDtoConverter.java @@ -47,7 +47,7 @@ public class ObserveDtoConverter extends AbstractConverter { @Override protected <T> T convertToType(Class<T> type, Object value) throws Throwable { - T observeDto = null; + T observeDto; if (ObserveDto.class.isAssignableFrom(type)) { diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/DateInjector.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/DateInjector.java index ad28bac..8f14c73 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/DateInjector.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/DateInjector.java @@ -41,7 +41,7 @@ public class DateInjector implements ExecutorParametersInjectorHandler.Injector{ private static final Log log = LogFactory.getLog(DateInjector.class); - protected String datePattern; + protected final String datePattern; public DateInjector(String datePattern) { this.datePattern = datePattern; diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java index 29891c5..368402b 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java @@ -100,7 +100,7 @@ public class ObserveDtoInjector extends AbstractConverter implements ExecutorPar @Override protected <T> T convertToType(Class<T> type, Object value) throws Throwable { - T observeDto = null; + T observeDto; if (ObserveDto.class.isAssignableFrom(type)) { diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/request/ObserveWebRequestContext.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/request/ObserveWebRequestContext.java index b68e7ab..a65c905 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/request/ObserveWebRequestContext.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/request/ObserveWebRequestContext.java @@ -22,20 +22,20 @@ package fr.ird.observe.application.web.request; * #L% */ -import com.google.common.base.Optional; import fr.ird.observe.application.web.ObserveWebApplicationContext; -import fr.ird.observe.services.security.AdminApiKeyNotFoundException; -import fr.ird.observe.services.security.AuthenticationTokenNotFoundException; -import fr.ird.observe.services.security.InvalidAdminKeyApiException; import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.ObserveServiceInitializer; import fr.ird.observe.services.ObserveSpeciesListConfiguration; import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationAndConnection; import fr.ird.observe.services.dto.constants.ReferentialLocale; +import fr.ird.observe.services.security.AdminApiKeyNotFoundException; +import fr.ird.observe.services.security.AuthenticationTokenNotFoundException; +import fr.ird.observe.services.security.InvalidAdminKeyApiException; import org.debux.webmotion.server.call.HttpContext; import java.util.Locale; +import java.util.Optional; /** * Created on 4/25/14. @@ -80,8 +80,8 @@ public class ObserveWebRequestContext { this.applicationLocale = applicationLocale; this.referentialLocale = referentialLocale; this.speciesListConfiguration = speciesListConfiguration; - this.optionalAdminApiKey = Optional.fromNullable(adminApiKey); - this.optionalAuthenticationToken = Optional.fromNullable(authenticationToken); + this.optionalAdminApiKey = Optional.ofNullable(adminApiKey); + this.optionalAuthenticationToken = Optional.ofNullable(authenticationToken); } public ObserveWebApplicationContext getApplicationContext() { diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java index 10bd677..9a7d63e 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityApplicationContext.java @@ -22,7 +22,6 @@ package fr.ird.observe.application.web.security; * #L% */ -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; @@ -48,6 +47,7 @@ import org.nuiton.version.Version; import java.io.Closeable; import java.util.Objects; +import java.util.Optional; /** * Pour conserver les données applicatives liée à la sécurité (principale le cache des utilisateurs connectés). diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java index 8f744b7..26196fd 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/security/ObserveWebSecurityAuthenticationTokenCache.java @@ -25,7 +25,6 @@ package fr.ird.observe.application.web.security; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationAndConnection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -56,13 +55,9 @@ public class ObserveWebSecurityAuthenticationTokenCache implements Closeable { .maximumSize(maximumSize) .expireAfterWrite(expireDelay, TimeUnit.MINUTES) .expireAfterAccess(expireDelay, TimeUnit.MINUTES) - .removalListener(new RemovalListener<String, ObserveDataSourceConfigurationAndConnection>() { - - @Override - public void onRemoval(RemovalNotification<String, ObserveDataSourceConfigurationAndConnection> notification) { - if (log.isInfoEnabled()) { - log.info(String.format("Remove authentication token: %s - %s", notification.getKey(), notification.getValue())); - } + .removalListener((RemovalListener<String, ObserveDataSourceConfigurationAndConnection>) notification -> { + if (log.isInfoEnabled()) { + log.info(String.format("Remove authentication token: %s - %s", notification.getKey(), notification.getValue())); } }) .build(); diff --git a/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabasesHelperTest.java b/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabasesHelperTest.java index d67ab46..4e57dcd 100644 --- a/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabasesHelperTest.java +++ b/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/db/ObserveWebDatabasesHelperTest.java @@ -23,7 +23,6 @@ package fr.ird.observe.application.web.configuration.db; */ import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.io.Files; import fr.ird.observe.application.web.configuration.ObserveWebApplicationConfiguration; @@ -41,6 +40,7 @@ import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.LinkedHashSet; +import java.util.Optional; import java.util.Set; /** @@ -88,7 +88,7 @@ public class ObserveWebDatabasesHelperTest { } @Before - public void setUp() throws IOException { + public void setUp() { configuration = new ObserveWebApplicationConfiguration("observeweb-test.conf"); configuration.init(); observeWebDatabasesHelper = new ObserveWebDatabasesHelper(); diff --git a/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelperTest.java b/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelperTest.java index e82bb24..45d7e0d 100644 --- a/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelperTest.java +++ b/observe-application-web/src/test/java/fr/ird/observe/application/web/configuration/user/ObserveWebUsersHelperTest.java @@ -23,7 +23,6 @@ package fr.ird.observe.application.web.configuration.user; */ import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.io.Files; import fr.ird.observe.application.web.configuration.ObserveWebApplicationConfiguration; @@ -43,6 +42,7 @@ import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.LinkedHashSet; +import java.util.Optional; import java.util.Set; /** diff --git a/observe-business/src/main/java/fr/ird/observe/ObserveApplicationContext.java b/observe-business/src/main/java/fr/ird/observe/ObserveApplicationContext.java index a921cec..d3a1a18 100644 --- a/observe-business/src/main/java/fr/ird/observe/ObserveApplicationContext.java +++ b/observe-business/src/main/java/fr/ird/observe/ObserveApplicationContext.java @@ -48,7 +48,7 @@ import java.util.Locale; public class ObserveApplicationContext extends DefaultApplicationContext { /** Logger */ - static private Log log = LogFactory.getLog(ObserveApplicationContext.class); + private static final Log log = LogFactory.getLog(ObserveApplicationContext.class); /** the jaxx context entry to store the config */ public static final JAXXContextEntryDef<IObserveConfig> CONFIG_ENTRY_DEF = diff --git a/observe-business/src/main/java/fr/ird/observe/ObserveServiceHelper.java b/observe-business/src/main/java/fr/ird/observe/ObserveServiceHelper.java index e2b57d5..efb22d1 100644 --- a/observe-business/src/main/java/fr/ird/observe/ObserveServiceHelper.java +++ b/observe-business/src/main/java/fr/ird/observe/ObserveServiceHelper.java @@ -44,7 +44,7 @@ import static org.nuiton.i18n.I18n.n; public class ObserveServiceHelper { /** Logger. */ - private static Log log = LogFactory.getLog(ObserveServiceHelper.class); + private static final Log log = LogFactory.getLog(ObserveServiceHelper.class); /** Le context applicatif. */ public static ObserveApplicationContext context; diff --git a/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSource.java b/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSource.java index d282922..efe81cd 100644 --- a/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSource.java +++ b/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSource.java @@ -44,7 +44,7 @@ import java.util.Set; public class PGDataSource extends AbstractDataSource { /** Logger */ - static private Log log = LogFactory.getLog(PGDataSource.class); + private static final Log log = LogFactory.getLog(PGDataSource.class); public PGDataSource(PGDataSourceConfig config) { super(config); diff --git a/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSourceConfig.java b/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSourceConfig.java index d065164..150ca7a 100644 --- a/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSourceConfig.java +++ b/observe-business/src/main/java/fr/ird/observe/db/impl/PGDataSourceConfig.java @@ -53,7 +53,7 @@ import static org.nuiton.i18n.I18n.t; public class PGDataSourceConfig extends AbstractDataSourceConfig { /** Logger */ - static private Log log = LogFactory.getLog(PGDataSourceConfig.class); + private static final Log log = LogFactory.getLog(PGDataSourceConfig.class); public static final String DATA_PRIVILEGES = "dataPrivileges"; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java b/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java index 2ed9d46..2c20226 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/Entities.java @@ -301,18 +301,8 @@ public class Entities { }; public static final ObserveEntityEnum[] ALL_ENTITIES = ObserveEntityEnum.values(); - public static final Predicate<String> IS_SEINE_ID = new Predicate<String>() { - @Override - public boolean apply(String input) { - return Entities.isSeineId(input); - } - }; - public static final Predicate<String> IS_LONGLINE_ID = new Predicate<String>() { - @Override - public boolean apply(String input) { - return Entities.isLonglineId(input); - } - }; + public static final java.util.function.Predicate<String> IS_SEINE_ID = input -> Entities.isSeineId(input); + public static final java.util.function.Predicate<String> IS_LONGLINE_ID = input -> Entities.isLonglineId(input); /** * @param klass le type d'entite a tester @@ -365,7 +355,7 @@ public class Entities { public static <E extends ObserveEntity> Map<String, E> toIdMap(Collection<E> entities) { Map<String, E> map = CollectionUtils.isEmpty(entities) - ? Maps.<String, E>newHashMap() + ? Maps.newHashMap() : Maps.uniqueIndex(entities, TopiaEntities.getTopiaIdFunction()); return map; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointTypePersist.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointTypePersist.java index 76b073d..e10d8a2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointTypePersist.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/TripMapPointTypePersist.java @@ -43,6 +43,6 @@ public enum TripMapPointTypePersist { longlineActivityWithHaulingStart, longlineActivityWithHaulingEnd, longlineActivityWithInteraction, - longlineActivityWithStation; + longlineActivityWithStation } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/NonTargetCatchComputedValueSourcePersist.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/NonTargetCatchComputedValueSourcePersist.java index c34eda9..351ceb2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/NonTargetCatchComputedValueSourcePersist.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/NonTargetCatchComputedValueSourcePersist.java @@ -47,6 +47,6 @@ public enum NonTargetCatchComputedValueSourcePersist { * * @since 3.0 */ - fromReferentiel; + fromReferentiel } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/OwnershipPersist.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/OwnershipPersist.java index d363869..7ffc123 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/OwnershipPersist.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/OwnershipPersist.java @@ -35,6 +35,6 @@ public enum OwnershipPersist implements Comparable<OwnershipPersist> { ceVessel, /** appartien a un autre vessel */ - autreVessel; + autreVessel } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/SchoolTypePersist.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/SchoolTypePersist.java index 69a6a08..a1c85b7 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/SchoolTypePersist.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/SchoolTypePersist.java @@ -36,6 +36,6 @@ public enum SchoolTypePersist { objet, /** banc libre // was 2 before version 4.0 */ - libre; + libre } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/TypeTransmittingBuoyOperationPersist.java b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/TypeTransmittingBuoyOperationPersist.java index e81bf6b..5726746 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/TypeTransmittingBuoyOperationPersist.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/constants/seine/TypeTransmittingBuoyOperationPersist.java @@ -32,6 +32,6 @@ public enum TypeTransmittingBuoyOperationPersist { pose, // deux balises lues - recuperationEtRemplacement; + recuperationEtRemplacement } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglines.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglines.java index f350769..43a0e78 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglines.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglines.java @@ -41,24 +41,13 @@ public class ActivityLonglines { * Comparateur de {@link ActivityLongline} basé sur la propriété {@link * ActivityLongline#getTimeStamp()}. */ - public static final Comparator<ActivityLongline> ACTIVITY_LONGLINE_COMPARATOR = new Comparator<ActivityLongline>() { - - @Override - public int compare(ActivityLongline o1, ActivityLongline o2) { - return o1.getTimeStamp().compareTo(o2.getTimeStamp()); - } - }; + public static final Comparator<ActivityLongline> ACTIVITY_LONGLINE_COMPARATOR = (o1, o2) -> o1.getTimeStamp().compareTo(o2.getTimeStamp()); public static void sort(List<ActivityLongline> routes) { Collections.sort(routes, ACTIVITY_LONGLINE_COMPARATOR); } public static Predicate<ActivityLongline> newTimeStampBeforePredicate(final Date timeStamp) { - return new Predicate<ActivityLongline>() { - @Override - public boolean apply(ActivityLongline input) { - return input.getTimeStamp().before(timeStamp); - } - }; + return input -> input.getTimeStamp().before(timeStamp); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java index cc874ce..5714a38 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/TripLonglineTopiaDao.java @@ -122,7 +122,7 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl private static class TripMapActivityPointQuery extends TopiaSqlQuery<List<TripMapPoint>> { - private static String SQL = "SELECT" + + private static final String SQL = "SELECT" + " a.timestamp, " + " a.latitude," + " a.longitude," + @@ -145,7 +145,7 @@ public class TripLonglineTopiaDao extends AbstractTripLonglineTopiaDao<TripLongl " WHERE a.trip = ?" + " ORDER BY a.timestamp"; - protected String tripId; + protected final String tripId; public TripMapActivityPointQuery(String tripId) { this.tripId = tripId; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java index 1599934..4bbbe28 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java @@ -42,7 +42,7 @@ public abstract class AbstractDataSourceMigration extends TopiaMigrationCallback /** * Logger */ - static private Log log = + private static final Log log = LogFactory.getLog(AbstractDataSourceMigration.class); public static final Version V_3_0 = Versions.valueOf("3.0"); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java index 095b8dd..a17266e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java @@ -30,15 +30,12 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; import org.nuiton.version.Version; import java.io.IOException; import java.io.InputStream; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.SQLException; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -68,17 +65,13 @@ public abstract class AbstractObserveMigrationCallBack extends TopiaMigrationCal final Set<String> result = new HashSet<>(); - topiaSqlSupport.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT topiaId FROM %s;", tableName); - try (PreparedStatement ps = connection.prepareStatement(sql)) { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String id = set.getString(1); - result.add(id); - } + topiaSqlSupport.doSqlWork(connection -> { + String sql = String.format("SELECT topiaId FROM %s;", tableName); + try (PreparedStatement ps = connection.prepareStatement(sql)) { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String id = set.getString(1); + result.add(id); } } }); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java index fc8c1fc..f494bef 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java @@ -25,9 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -59,28 +57,24 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { // recherche du nom de la constrainte final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - - String sql = "select CONSTRAINT_NAME from INFORMATION_SCHEMA.Constraints where CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME=? AND Column_list =?;"; - PreparedStatement ps = connection.prepareStatement(sql); - ps.setString(1, tableName.toUpperCase()); - ps.setString(2, columnName.toUpperCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - String constraintName = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found constraint of type unique for table " + tableName + " and column " + columnName + ": " + constraintName); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraint unique for table" + tableName + " and column " + columnName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + + String sql = "select CONSTRAINT_NAME from INFORMATION_SCHEMA.Constraints where CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME=? AND Column_list =?;"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setString(1, tableName.toUpperCase()); + ps.setString(2, columnName.toUpperCase()); + try { + ResultSet set = ps.executeQuery(); + if (set.next()) { + String constraintName = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found constraint of type unique for table " + tableName + " and column " + columnName + ": " + constraintName); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraint unique for table" + tableName + " and column " + columnName, e); + } finally { + ps.close(); } }); @@ -98,26 +92,22 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { //(); final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = "select CONSTRAINT_NAME from INFORMATION_SCHEMA.Constraints where CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME=?;"; - PreparedStatement ps = connection.prepareStatement(sql); - ps.setString(1, tableName.toUpperCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - String constraintName = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found constraint of type unique for table " + tableName + " : " + constraintName); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraint unique for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = "select CONSTRAINT_NAME from INFORMATION_SCHEMA.Constraints where CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME=?;"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setString(1, tableName.toUpperCase()); + try { + ResultSet set = ps.executeQuery(); + if (set.next()) { + String constraintName = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found constraint of type unique for table " + tableName + " : " + constraintName); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraint unique for table " + tableName, e); + } finally { + ps.close(); } }); @@ -133,23 +123,19 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE (CONSTRAINT_TYPE='UNIQUE' OR CONSTRAINT_TYPE='REFERENTIAL') AND TABLE_NAME='%S';", tableName); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE (CONSTRAINT_TYPE='UNIQUE' OR CONSTRAINT_TYPE='REFERENTIAL') AND TABLE_NAME='%S';", tableName); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); @@ -160,23 +146,19 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE CONSTRAINT_TYPE='REFERENTIAL' AND TABLE_NAME='%S';", tableName); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE CONSTRAINT_TYPE='REFERENTIAL' AND TABLE_NAME='%S';", tableName); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); @@ -187,27 +169,23 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints " + - "WHERE CONSTRAINT_TYPE='REFERENTIAL' " + - "AND CONSTRAINT_SCHEMA='%S' " + - "AND TABLE_NAME='%S' " + - "AND COLUMN_LIST='%S';", schemaName, tableName, columnName); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints " + + "WHERE CONSTRAINT_TYPE='REFERENTIAL' " + + "AND CONSTRAINT_SCHEMA='%S' " + + "AND TABLE_NAME='%S' " + + "AND COLUMN_LIST='%S';", schemaName, tableName, columnName); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); @@ -236,23 +214,19 @@ public class H2DataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME='%S';", tableName); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT constraint_name FROM INFORMATION_SCHEMA.Constraints WHERE CONSTRAINT_TYPE='UNIQUE' AND TABLE_NAME='%S';", tableName); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java index 634a220..10ee36b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java @@ -38,7 +38,7 @@ import java.lang.reflect.Modifier; class ObserveMigrationCallBackForVersionResolver implements TopiaMigrationCallbackByClass.MigrationCallBackForVersionResolver { /** Logger */ - static private Log log = + private static final Log log = LogFactory.getLog(ObserveMigrationCallBackForVersionResolver.class); protected final String prefix; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java index 63f6cea..0d9ee4e4 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java @@ -25,9 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -59,72 +57,68 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { // recherche du nom de la constrainte final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - - // get table oid - String oid = null; - - String sqlOid = "select oid from pg_class where relname=?;"; - { - PreparedStatement ps = connection.prepareStatement(sqlOid); - ps.setString(1, tableName.toLowerCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - oid = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found table oid " + tableName + ": " + oid); - } - } catch (Exception e) { - throw new SQLException("Could not obtain oid for table" + tableName, e); - } finally { - ps.close(); - } - } + tx.doSqlWork(connection -> { + + // get table oid + String oid = null; - // get attribute num - String attNumSql = "select attnum from pg_attribute where attrelid=? AND attname =?"; - String attNum = null; - { - PreparedStatement ps = connection.prepareStatement(attNumSql); - ps.setInt(1, Integer.valueOf(oid)); - ps.setString(2, columnName.toLowerCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - attNum = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found attribute " + columnName + " attNum : " + attNum); - } - } catch (Exception e) { - throw new SQLException("Could not obtain attNum for column" + columnName, e); - } finally { - ps.close(); + String sqlOid = "select oid from pg_class where relname=?;"; + { + PreparedStatement ps = connection.prepareStatement(sqlOid); + ps.setString(1, tableName.toLowerCase()); + try { + ResultSet set = ps.executeQuery(); + if (set.next()) { + oid = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found table oid " + tableName + ": " + oid); } + } catch (Exception e) { + throw new SQLException("Could not obtain oid for table" + tableName, e); + } finally { + ps.close(); } + } - String sql = "SELECT conname FROM pg_constraint where contype='u' and conrelid= ? and conkey = '{" + attNum + "}';"; - - PreparedStatement ps = connection.prepareStatement(sql); + // get attribute num + String attNumSql = "select attnum from pg_attribute where attrelid=? AND attname =?"; + String attNum = null; + { + PreparedStatement ps = connection.prepareStatement(attNumSql); ps.setInt(1, Integer.valueOf(oid)); + ps.setString(2, columnName.toLowerCase()); try { ResultSet set = ps.executeQuery(); - if (set.next()) { - String constraintName = set.getString(1); + attNum = set.getString(1); if (log.isDebugEnabled()) - log.debug("found constraint of type unique for table " + tableName + " and column " + columnName + ": " + constraintName); - result.add(constraintName); + log.debug("found attribute " + columnName + " attNum : " + attNum); } } catch (Exception e) { - throw new SQLException("Could not obtain constraint unique for table" + tableName + " and column " + columnName, e); + throw new SQLException("Could not obtain attNum for column" + columnName, e); } finally { ps.close(); } } + + String sql = "SELECT conname FROM pg_constraint where contype='u' and conrelid= ? and conkey = '{" + attNum + "}';"; + + PreparedStatement ps = connection.prepareStatement(sql); + ps.setInt(1, Integer.valueOf(oid)); + try { + ResultSet set = ps.executeQuery(); + + if (set.next()) { + String constraintName = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found constraint of type unique for table " + tableName + " and column " + columnName + ": " + constraintName); + result.add(constraintName); + } + } catch (Exception e) { + throw new SQLException("Could not obtain constraint unique for table" + tableName + " and column " + columnName, e); + } finally { + ps.close(); + } }); if (result.isEmpty()) { @@ -141,26 +135,22 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { //(); final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = "SELECT conname FROM pg_constraint where contype='u' and conrelid= (select oid from pg_class where relname=?);"; - PreparedStatement ps = connection.prepareStatement(sql); - ps.setString(1, tableName.toLowerCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - String constraintName = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found constraint of type unique for table " + tableName + " : " + constraintName); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraint unique for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = "SELECT conname FROM pg_constraint where contype='u' and conrelid= (select oid from pg_class where relname=?);"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setString(1, tableName.toLowerCase()); + try { + ResultSet set = ps.executeQuery(); + if (set.next()) { + String constraintName = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found constraint of type unique for table " + tableName + " : " + constraintName); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraint unique for table " + tableName, e); + } finally { + ps.close(); } }); @@ -176,23 +166,19 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='u' OR contype='f' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='u' OR contype='f' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); @@ -203,23 +189,19 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='f' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='f' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); @@ -231,70 +213,67 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { final List<String> result = new ArrayList<>(); - tx.doSqlWork(new TopiaSqlWork() { - - public void execute(Connection connection) throws SQLException { - - - // get table oid - String oid = null; - - String sqlOid = "select oid from pg_class where relnamespace = (select oid from pg_catalog.pg_namespace where nspname=?) AND relname=?;"; - { - PreparedStatement ps = connection.prepareStatement(sqlOid); - ps.setString(1, schemaName.toLowerCase()); - ps.setString(2, tableName.toLowerCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - oid = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found table oid " + tableName + ": " + oid); - } - } catch (Exception e) { - throw new SQLException("Could not obtain oid for table" + tableName, e); - } finally { - ps.close(); - } - } + tx.doSqlWork(connection -> { + - // get attribute num - String attNumSql = "select attnum from pg_attribute where attrelid=? AND attname =?"; - String attNum = null; - { - PreparedStatement ps = connection.prepareStatement(attNumSql); - ps.setInt(1, Integer.valueOf(oid)); - ps.setString(2, columnName.toLowerCase()); - try { - ResultSet set = ps.executeQuery(); - if (set.next()) { - attNum = set.getString(1); - if (log.isDebugEnabled()) - log.debug("found attribute " + columnName + " attNum : " + attNum); - } - } catch (Exception e) { - throw new SQLException("Could not obtain attNum for column" + columnName, e); - } finally { - ps.close(); + // get table oid + String oid = null; + + String sqlOid = "select oid from pg_class where relnamespace = (select oid from pg_catalog.pg_namespace where nspname=?) AND relname=?;"; + { + PreparedStatement ps = connection.prepareStatement(sqlOid); + ps.setString(1, schemaName.toLowerCase()); + ps.setString(2, tableName.toLowerCase()); + try { + ResultSet set = ps.executeQuery(); + if (set.next()) { + oid = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found table oid " + tableName + ": " + oid); } + } catch (Exception e) { + throw new SQLException("Could not obtain oid for table" + tableName, e); + } finally { + ps.close(); } + } - String sql = "SELECT DISTINCT conname FROM pg_constraint WHERE contype='f' AND conrelid = ? AND conkey = '{" + attNum + "}';"; - PreparedStatement ps = connection.prepareStatement(sql); + // get attribute num + String attNumSql = "select attnum from pg_attribute where attrelid=? AND attname =?"; + String attNum = null; + { + PreparedStatement ps = connection.prepareStatement(attNumSql); ps.setInt(1, Integer.valueOf(oid)); - + ps.setString(2, columnName.toLowerCase()); try { ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); + if (set.next()) { + attNum = set.getString(1); + if (log.isDebugEnabled()) + log.debug("found attribute " + columnName + " attNum : " + attNum); } } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); + throw new SQLException("Could not obtain attNum for column" + columnName, e); } finally { ps.close(); } } + + String sql = "SELECT DISTINCT conname FROM pg_constraint WHERE contype='f' AND conrelid = ? AND conkey = '{" + attNum + "}';"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setInt(1, Integer.valueOf(oid)); + + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); + } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); + } }); String constraintName; @@ -321,23 +300,19 @@ public class PGDataSourceMigration extends AbstractDataSourceMigration { final Set<String> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='u' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String constraintName = set.getString(1); - result.add(constraintName); - } - } catch (Exception e) { - throw new SQLException("Could not obtain constraints for table " + tableName, e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = String.format("SELECT DISTINCT conname FROM pg_constraint WHERE ( contype='u' ) AND conrelid = (SELECT oid FROM pg_class WHERE relname='%s');", tableName.toLowerCase()); + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String constraintName = set.getString(1); + result.add(constraintName); } + } catch (Exception e) { + throw new SQLException("Could not obtain constraints for table " + tableName, e); + } finally { + ps.close(); } }); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java index a4d0113..d30c97a 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java @@ -29,9 +29,7 @@ import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -103,27 +101,23 @@ public class DataSourceMigrationForVersion_3_16 extends AbstractObserveMigration final Set<SenneData> result = new HashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = "SELECT topiaId, seineCircumference, seineDepth, seineBallastWeight FROM OBSERVE_SEINE.TRIP WHERE seineDepth IS NOT NULL OR seineDepth IS NOT NULL OR seineBallastWeight IS NOT NULL;"; - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - SenneData senneData = new SenneData(); - senneData.tripId = set.getString(1); - senneData.seineCircumference = set.getInt(2); - senneData.seineDepth = set.getInt(3); - senneData.seineBallastWeight = set.getInt(4); - result.add(senneData); - } - } catch (Exception e) { - throw new SQLException("Could not obtain trip senne data", e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = "SELECT topiaId, seineCircumference, seineDepth, seineBallastWeight FROM OBSERVE_SEINE.TRIP WHERE seineDepth IS NOT NULL OR seineDepth IS NOT NULL OR seineBallastWeight IS NOT NULL;"; + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + SenneData senneData = new SenneData(); + senneData.tripId = set.getString(1); + senneData.seineCircumference = set.getInt(2); + senneData.seineDepth = set.getInt(3); + senneData.seineBallastWeight = set.getInt(4); + result.add(senneData); } + } catch (Exception e) { + throw new SQLException("Could not obtain trip senne data", e); + } finally { + ps.close(); } }); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java index fbece2e..ea5102f 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java @@ -40,7 +40,7 @@ import java.util.Set; */ public abstract class DataSourceMigrationForVersion_3_5 extends AbstractObserveMigrationCallBack { - protected String[] TABLES = new String[]{ + protected static final String[] TABLES = new String[]{ "ParametrageTaillePoidsFaune", "ParametrageTaillePoidsThon", "ActiviteEnvironnante", diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java index 1391806..6c47bfd 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java @@ -33,9 +33,7 @@ import fr.ird.observe.entities.seine.GearUseFeaturesMeasurementSeine; import fr.ird.observe.entities.seine.GearUseFeaturesSeine; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -92,27 +90,23 @@ public abstract class DataSourceMigrationForVersion_4_0_1 extends AbstractObserv // L'ensemble des opérations de pêche où l'on doit regénerer les générer les haulingIds final Set<SetData> setIds = new LinkedHashSet<>(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = "SELECT topiaId, totalSectionsCount, basketsPerSectionCount, branchlinesPerBasketCount FROM OBSERVE_LONGLINE.SET WHERE HAULINGBREAKS = 0 AND haulingDirectionSameAsSetting IS FALSE;"; - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - SetData setData = new SetData(); - setData.id = set.getString(1); - setData.totalSectionsCount = set.getInt(2); - setData.basketsPerSectionCount = set.getInt(3); - setData.branchlinesPerBasketCount = set.getInt(4); - setIds.add(setData); - } - } catch (Exception e) { - throw new SQLException("Could not obtain SET data", e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = "SELECT topiaId, totalSectionsCount, basketsPerSectionCount, branchlinesPerBasketCount FROM OBSERVE_LONGLINE.SET WHERE HAULINGBREAKS = 0 AND haulingDirectionSameAsSetting IS FALSE;"; + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + SetData setData = new SetData(); + setData.id = set.getString(1); + setData.totalSectionsCount = set.getInt(2); + setData.basketsPerSectionCount = set.getInt(3); + setData.branchlinesPerBasketCount = set.getInt(4); + setIds.add(setData); } + } catch (Exception e) { + throw new SQLException("Could not obtain SET data", e); + } finally { + ps.close(); } }); @@ -128,24 +122,20 @@ public abstract class DataSourceMigrationForVersion_4_0_1 extends AbstractObserv protected void migrateGearUseFeaturesSeineMeasurementIds(TopiaSqlSupport tx, List<String> queries) { final Multimap<String, String> gearUseFeaturesSeineAndMeasurementIds = LinkedHashMultimap.create(); - tx.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - String sql = "SELECT GEARUSEFEATURES, topiaId FROM OBSERVE_SEINE.GEARUSEFEATURESMEASUREMENT;"; - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String gearUseFeaturesSeineId = set.getString(1); - String gearUseFeaturesMeasurementSeineId = set.getString(2); - gearUseFeaturesSeineAndMeasurementIds.put(gearUseFeaturesSeineId, gearUseFeaturesMeasurementSeineId); - } - } catch (Exception e) { - throw new SQLException("Could not obtain GEARUSEFEATURESMEASUREMENT ids", e); - } finally { - ps.close(); + tx.doSqlWork(connection -> { + String sql = "SELECT GEARUSEFEATURES, topiaId FROM OBSERVE_SEINE.GEARUSEFEATURESMEASUREMENT;"; + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String gearUseFeaturesSeineId = set.getString(1); + String gearUseFeaturesMeasurementSeineId = set.getString(2); + gearUseFeaturesSeineAndMeasurementIds.put(gearUseFeaturesSeineId, gearUseFeaturesMeasurementSeineId); } + } catch (Exception e) { + throw new SQLException("Could not obtain GEARUSEFEATURESMEASUREMENT ids", e); + } finally { + ps.close(); } }); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java index eb1ce64..527f753 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java @@ -27,9 +27,7 @@ import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; import fr.ird.observe.entities.migration.H2DataSourceMigration; import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -59,29 +57,25 @@ public class DataSourceMigrationForVersion_4_0_RC2 extends AbstractObserveMigrat // recherche du nom de la constrainte final Set<String> result = new HashSet<>(); - topiaSqlSupport.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - - String sql = "select distinct (geartype||'') from observe_common.program"; - { - PreparedStatement ps = connection.prepareStatement(sql); - try { - ResultSet set = ps.executeQuery(); - while (set.next()) { - String gearType = set.getString(1); - result.add(gearType); - } - - } catch (Exception e) { - throw new SQLException("Could not obtain program gear types", e); - } finally { - ps.close(); + topiaSqlSupport.doSqlWork(connection -> { + + String sql = "select distinct (geartype||'') from observe_common.program"; + { + PreparedStatement ps = connection.prepareStatement(sql); + try { + ResultSet set = ps.executeQuery(); + while (set.next()) { + String gearType = set.getString(1); + result.add(gearType); } - } + } catch (Exception e) { + throw new SQLException("Could not obtain program gear types", e); + } finally { + ps.close(); + } } + }); if (result.contains("seine")) { diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java index 9a02b27..2f92da3 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java @@ -30,7 +30,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; -import org.nuiton.topia.persistence.support.TopiaSqlWork; import java.sql.Connection; import java.sql.PreparedStatement; @@ -152,25 +151,20 @@ public abstract class DataSourceMigrationForVersion_4_0_RC3 extends AbstractObse private void removeForeignKeyIndex(TopiaSqlSupport tx, final List<String> queries, final String schemaName, final String tableName, final String columnName) { - tx.doSqlWork(new TopiaSqlWork() { + tx.doSqlWork(connection -> { - @Override - public void execute(Connection connection) throws SQLException { + // get table oid + int oid = getTableOid(connection, schemaName, tableName); - // get table oid - int oid = getTableOid(connection, schemaName, tableName); + // get attribute num + int attNum = getAttributeNum(connection, oid, columnName); - // get attribute num - int attNum = getAttributeNum(connection, oid, columnName); + Set<Integer> indexIds = getIndexId(connection, oid, attNum); - Set<Integer> indexIds = getIndexId(connection, oid, attNum); + for (Integer indexId : indexIds) { - for (Integer indexId : indexIds) { - - String indexName = getIndexName(connection, indexId); - queries.add("DROP INDEX " + schemaName + "." + indexName + ";"); - - } + String indexName = getIndexName(connection, indexId); + queries.add("DROP INDEX " + schemaName + "." + indexName + ";"); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/ObserveReferentialEntities.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/ObserveReferentialEntities.java index a444709..00db79c 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/ObserveReferentialEntities.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/ObserveReferentialEntities.java @@ -41,13 +41,7 @@ import java.util.List; */ public class ObserveReferentialEntities { - public static final Predicate<? extends ObserveReferentialEntity> IS_ACTIF_PREDICATE = new Predicate<ObserveReferentialEntity>() { - - @Override - public boolean apply(ObserveReferentialEntity input) { - return ReferenceStatusPersist.disabled != input.getStatus(); - } - }; + public static final Predicate<? extends ObserveReferentialEntity> IS_ACTIF_PREDICATE = (Predicate<ObserveReferentialEntity>) input -> ReferenceStatusPersist.disabled != input.getStatus(); /** Logger. */ private static final Log log = LogFactory.getLog(ObserveReferentialEntities.class); @@ -57,11 +51,11 @@ public class ObserveReferentialEntities { * entités qui ne sont pas actives {@link ObserveReferentialEntity#getStatus()} * * @param list la liste des entitées à filtrer - * @param <E> le type des entites du référentiel + * @param <E> le type des entites du référentiel */ public static <E extends ObserveReferentialEntity> void filterReferentielListByStatus( List<E> list) { - filterReferentielList(list, ObserveReferentialEntities.<E>newEnablePredicate()); + filterReferentielList(list, ObserveReferentialEntities.newEnablePredicate()::apply); } @@ -71,15 +65,15 @@ public class ObserveReferentialEntities { * * @param list la liste des entitées à filtrer * @param predicate le prédicate à appliquer pour conserver les valeurs - * @param <E> le type des entites du référentiel + * @param <E> le type des entites du référentiel */ public static <E extends ObserveReferentialEntity> void filterReferentielList( List<E> list, - Predicate<E> predicate) { + java.util.function.Predicate<E> predicate) { Iterator<E> itr = list.iterator(); while (itr.hasNext()) { E e = itr.next(); - if (!predicate.apply(e)) { + if (!predicate.test(e)) { // l'entite n'est pas retenue, on ne l'affiche pas @@ -121,7 +115,7 @@ public class ObserveReferentialEntities { public interface ReferentielWalker { - <E extends TopiaEntity> void walk(Class<E> beanClass) throws Exception; + <E extends TopiaEntity> void walk(Class<E> beanClass); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Persons.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Persons.java index 6be30b4..53fa5b2 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Persons.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Persons.java @@ -33,29 +33,14 @@ import com.google.common.base.Predicate; public class Persons { public static Predicate<Person> newObserverPredicate() { - return new Predicate<Person>() { - @Override - public boolean apply(Person input) { - return input.isObserver(); - } - }; + return Person::isObserver; } public static Predicate<Person> newCaptainPredicate() { - return new Predicate<Person>() { - @Override - public boolean apply(Person input) { - return input.isCaptain(); - } - }; + return Person::isCaptain; } public static Predicate<Person> newDataEntryOperatorPredicate() { - return new Predicate<Person>() { - @Override - public boolean apply(Person input) { - return input.isDataEntryOperator(); - } - }; + return Person::isDataEntryOperator; } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Programs.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Programs.java index 8645ba9..637ad67 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Programs.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Programs.java @@ -43,14 +43,7 @@ public class Programs { * FIXME-TC-20100205 : il faudrait que le comparateur soit sur le bon * libelle selon la langue de base choisie... */ - public static Comparator<Program> PROGRAMME_COMPARATOR = - new Comparator<Program>() { - - @Override - public int compare(Program o1, Program o2) { - return o1.getLabel2().compareTo(o2.getLabel2()); - } - }; + public static final Comparator<Program> PROGRAMME_COMPARATOR = (o1, o2) -> o1.getLabel2().compareTo(o2.getLabel2()); public static void sort(List<Program> programs) { //FIXME-TC20100207 : make possible sort on different libelles coming diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Species2.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Species2.java index db7d1ab..b37330e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Species2.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/Species2.java @@ -66,25 +66,13 @@ public class Species2 { public static List<WeightCategory> filterWeightCategoryBySpeciesIds(Collection<WeightCategory> speciess, final Set<String> speciesIds) { - return Lists.newArrayList(Iterables.filter(speciess, new Predicate<WeightCategory>() { - - @Override - public boolean apply(WeightCategory input) { - return speciesIds.contains(input.getSpecies().getTopiaId()); - } - })); + return Lists.newArrayList(Iterables.filter(speciess, input -> speciesIds.contains(input.getSpecies().getTopiaId()))); } public static List<WeightCategory> filterWeightCategoryByOcean(Collection<WeightCategory> speciess, final Ocean ocean) { - return Lists.newArrayList(Iterables.filter(speciess, new Predicate<WeightCategory>() { - - @Override - public boolean apply(WeightCategory input) { - return input.getSpecies().getOcean().contains(ocean); - } - })); + return Lists.newArrayList(Iterables.filter(speciess, input -> input.getSpecies().getOcean().contains(ocean))); } public static String decorate(Locale locale, Species species) { diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java index 8627cea..5a771ab 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java @@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.util.NumberUtil; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -50,7 +51,7 @@ public class ActivitySeineImpl extends ActivitySeineAbstract { public static final String ACTIVITY_CHANGED_ZONE = "21"; - private static final List<String> CALEE_OPERATIONS = Arrays.asList(ACTIVITY_FIN_DE_PECHE); + private static final List<String> CALEE_OPERATIONS = Collections.singletonList(ACTIVITY_FIN_DE_PECHE); private static final List<String> DCP_OPERATIONS = Arrays.asList("13", "14", "15"); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeines.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeines.java index 4273546..07a4a2a 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeines.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeines.java @@ -50,14 +50,8 @@ public class ActivitySeines { * ActivitySeine#getTime()}. */ public static final Comparator<ActivitySeine> ACTIVITE_COMPARATOR = - new Comparator<ActivitySeine>() { - - @Override - public int compare(ActivitySeine o1, ActivitySeine o2) { - return o1.getTime().compareTo( - o2.getTime()); - } - }; + (o1, o2) -> o1.getTime().compareTo( + o2.getTime()); /** Logger. */ private static final Log log = LogFactory.getLog(ActivitySeines.class); @@ -304,11 +298,6 @@ public class ActivitySeines { } public static Predicate<ActivitySeine> newDateBeforePredicate(final Date time) { - return new Predicate<ActivitySeine>() { - @Override - public boolean apply(ActivitySeine input) { - return input.getTime().before(time); - } - }; + return input -> input.getTime().before(time); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java index 1bcd84b..af34ed3 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchImpl.java @@ -43,7 +43,7 @@ public class NonTargetCatchImpl extends NonTargetCatchAbstract { /** Logger */ - static private Log log = LogFactory.getLog(NonTargetCatchImpl.class); + private static final Log log = LogFactory.getLog(NonTargetCatchImpl.class); private static final long serialVersionUID = 1L; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchs.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchs.java index c64b276..b81226b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchs.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetCatchs.java @@ -31,12 +31,7 @@ import fr.ird.observe.entities.referentiel.Species; public class NonTargetCatchs { public static Function<NonTargetCatch, Species> getSpeciesFunction() { - return new Function<NonTargetCatch, Species>() { - @Override - public Species apply(NonTargetCatch input) { - return input.getSpecies(); - } - }; + return NonTargetCatch::getSpecies; } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLenghts.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLenghts.java index e6416e4..abdbd0e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLenghts.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/NonTargetLenghts.java @@ -31,12 +31,7 @@ import fr.ird.observe.entities.referentiel.Species; public class NonTargetLenghts { public static Function<NonTargetLength, Species> getSpeciesFunction() { - return new Function<NonTargetLength, Species>() { - @Override - public Species apply(NonTargetLength input) { - return input.getSpecies(); - } - }; + return NonTargetLength::getSpecies; } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteTopiaDao.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteTopiaDao.java index a3c9bc4..500bbce 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteTopiaDao.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/RouteTopiaDao.java @@ -126,28 +126,24 @@ public class RouteTopiaDao extends AbstractRouteTopiaDao<Route> { final Date date = new Date(route.getDate().getTime()); - topiaSqlSupport.doSqlWork(new TopiaSqlWork() { - - @Override - public void execute(Connection connection) throws SQLException { - - String sql = "UPDATE observe_seine.SET" + - " SET ENDPURSINGTIMESTAMP = (? || ' ' || ENDPURSINGTIMESTAMP::time)::timestamp," + - " ENDSETTIMESTAMP = (? || ' ' || ENDSETTIMESTAMP::time)::timestamp" + - " WHERE TOPIAID IN " + - " (" + - " SELECT s.TOPIAID" + - " FROM observe_seine.ACTIVITY a, observe_seine.SET s" + - " WHERE a.ROUTE = ? AND a.SET = s.TOPIAID" + - " );"; - - PreparedStatement ps = connection.prepareStatement(sql); - ps.setDate(1, date); - ps.setDate(2, date); - ps.setString(3, routeId); - ps.executeUpdate(); - - } + topiaSqlSupport.doSqlWork(connection -> { + + String sql = "UPDATE observe_seine.SET" + + " SET ENDPURSINGTIMESTAMP = (? || ' ' || ENDPURSINGTIMESTAMP::time)::timestamp," + + " ENDSETTIMESTAMP = (? || ' ' || ENDSETTIMESTAMP::time)::timestamp" + + " WHERE TOPIAID IN " + + " (" + + " SELECT s.TOPIAID" + + " FROM observe_seine.ACTIVITY a, observe_seine.SET s" + + " WHERE a.ROUTE = ? AND a.SET = s.TOPIAID" + + " );"; + + PreparedStatement ps = connection.prepareStatement(sql); + ps.setDate(1, date); + ps.setDate(2, date); + ps.setString(3, routeId); + ps.executeUpdate(); + }); } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/Routes.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/Routes.java index d49e279..10a2004 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/Routes.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/Routes.java @@ -46,13 +46,7 @@ public class Routes { * Comparateur de {@link Route} basé sur la propriété {@link * Route#getDate()}. */ - public static final Comparator<Route> ROUTE_COMPARATOR = new Comparator<Route>() { - - @Override - public int compare(Route o1, Route o2) { - return o1.getDate().compareTo(o2.getDate()); - } - }; + public static final Comparator<Route> ROUTE_COMPARATOR = (o1, o2) -> o1.getDate().compareTo(o2.getDate()); public static void sort(List<Route> routes) { Collections.sort(routes, ROUTE_COMPARATOR); @@ -94,11 +88,6 @@ public class Routes { } public static Predicate<Route> newDateBeforePredicate(final Date date) { - return new Predicate<Route>() { - @Override - public boolean apply(Route input) { - return input.getDate().before(date); - } - }; + return input -> input.getDate().before(date); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeines.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeines.java index 167975e..a65035e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeines.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/SetSeines.java @@ -22,7 +22,6 @@ package fr.ird.observe.entities.seine; * #L% */ -import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import fr.ird.observe.entities.referentiel.Species; @@ -40,13 +39,7 @@ public class SetSeines { Collection<NonTargetLength> nonTargetLengths = null; if (!setSeine.isNonTargetSampleEmpty()) { - nonTargetLengths = Collections2.filter(setSeine.getNonTargetSample().iterator().next().getNonTargetLength(), new Predicate<NonTargetLength>() { - - @Override - public boolean apply(NonTargetLength input) { - return species.equals(input.getSpecies()); - } - }); + nonTargetLengths = Collections2.filter(setSeine.getNonTargetSample().iterator().next().getNonTargetLength(), input -> species.equals(input.getSpecies())); } return nonTargetLengths; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java index 658e692..d42a288 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java @@ -22,12 +22,12 @@ package fr.ird.observe.entities.seine; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Predicate; import fr.ird.observe.entities.referentiel.Species; import java.util.Collection; import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -43,21 +43,11 @@ public class TargetCatchs { } public static Function<TargetCatch, Species> getSpeciesFunction() { - return new Function<TargetCatch, Species>() { - @Override - public Species apply(TargetCatch input) { - return input.getSpecies(); - } - }; + return TargetCatch::getSpecies; } public static Predicate<TargetCatch> newDiscardedPredicate(final boolean discarded) { - return new Predicate<TargetCatch>() { - @Override - public boolean apply(TargetCatch input) { - return discarded == input.isDiscarded(); - } - }; + return input -> discarded == input.isDiscarded(); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLenghts.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLenghts.java index 118a9c1..7ecb115 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLenghts.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetLenghts.java @@ -22,21 +22,17 @@ package fr.ird.observe.entities.seine; * #L% */ -import com.google.common.base.Function; import fr.ird.observe.entities.referentiel.Species; +import java.util.function.Function; + /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ public class TargetLenghts { public static Function<TargetLength, Species> getSpeciesFunction() { - return new Function<TargetLength, Species>() { - @Override - public Species apply(TargetLength input) { - return input.getSpecies(); - } - }; + return input -> input.getSpecies(); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java index 1f35c35..8c944ac 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TripSeineTopiaDao.java @@ -118,7 +118,7 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { private static class TripMapActivityPointQuery extends TopiaSqlQuery<TripMapPoint> { - private static String SQL = "SELECT" + + private static final String SQL = "SELECT" + " r.date, " + " a.time, " + " a.latitude," + @@ -133,7 +133,7 @@ public class TripSeineTopiaDao extends AbstractTripSeineTopiaDao<TripSeine> { " WHERE r.trip = ?" + " ORDER BY r.date, a.time"; - protected String tripId; + protected final String tripId; public TripMapActivityPointQuery(String tripId) { this.tripId = tripId; diff --git a/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java b/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java index f3a47b7..fded7d4 100644 --- a/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java +++ b/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java @@ -57,7 +57,7 @@ public class ObserveTopiaApplicationContextTest { } @Before - public void setUp() throws Exception { + public void setUp() { testDirectory = TestHelper.newFile(testName.getMethodName()); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/ObserveServiceInitializer.java b/observe-services-api/src/main/java/fr/ird/observe/services/ObserveServiceInitializer.java index 70d033e..fe7e14f 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/ObserveServiceInitializer.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/ObserveServiceInitializer.java @@ -22,7 +22,6 @@ package fr.ird.observe.services; * #L% */ -import com.google.common.base.Optional; import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationAndConnection; import fr.ird.observe.services.configuration.ObserveDataSourceConnection; @@ -30,6 +29,7 @@ import fr.ird.observe.services.dto.constants.ReferentialLocale; import java.io.File; import java.util.Locale; +import java.util.Optional; /** * Objet contentant les informations nécessaire pour créer un nouveau service. @@ -190,11 +190,11 @@ public class ObserveServiceInitializer { } protected void setDataSourceConnection(ObserveDataSourceConnection dataSourceConnection) { - this.dataSourceConnection = Optional.fromNullable(dataSourceConnection); + this.dataSourceConnection = Optional.ofNullable(dataSourceConnection); } protected void setDataSourceConfiguration(ObserveDataSourceConfiguration dataSourceConfiguration) { - this.dataSourceConfiguration = Optional.fromNullable(dataSourceConfiguration); + this.dataSourceConfiguration = Optional.ofNullable(dataSourceConfiguration); } protected void setTemporaryDirectoryRoot(File temporaryDirectoryRoot) { diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java index c196fdd..a12eb2d 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java @@ -365,7 +365,7 @@ public class ReportBuilder { } String typeStr = parts[0].trim(); String request = parts[1].trim(); - Class<?> type = null; + Class<?> type; try { type = Class.forName(typeStr); } catch (ClassNotFoundException eee) { diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java index 21b8d49..1518ea5 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtoType.java @@ -23,7 +23,6 @@ package fr.ird.observe.services.service.actions.validate; */ import com.google.common.base.Optional; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import fr.ird.observe.services.dto.AbstractReference; @@ -53,12 +52,7 @@ public class ValidateResultForDtoType<D extends IdDto> implements ObserveDto { } public ValidateResultForDto<D> getValidateResult(final AbstractReference<D> referenceDto) { - Optional<ValidateResultForDto<D>> resultForDtoOptional = Iterables.tryFind(validateResultForDto, new Predicate<ValidateResultForDto<D>>() { - @Override - public boolean apply(ValidateResultForDto<D> input) { - return referenceDto.equals(input.getDto()); - } - }); + Optional<ValidateResultForDto<D>> resultForDtoOptional = Iterables.tryFind(validateResultForDto, input -> referenceDto.equals(input.getDto())); return resultForDtoOptional.orNull(); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java index 932aadd..d86c49f 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateResultForDtos.java @@ -22,8 +22,6 @@ package fr.ird.observe.services.service.actions.validate; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -34,14 +32,14 @@ import org.nuiton.validator.NuitonValidatorScope; import java.util.EnumMap; import java.util.EnumSet; import java.util.List; +import java.util.stream.Collectors; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ public class ValidateResultForDtos { - public static EnumMap<NuitonValidatorScope, Integer> getScopesCount( - ValidateResultForDto validateResultForDto) { + public static EnumMap<NuitonValidatorScope, Integer> getScopesCount(ValidateResultForDto<?> validateResultForDto) { EnumMap<NuitonValidatorScope, Integer> result = Maps.newEnumMap(NuitonValidatorScope.class); @@ -71,30 +69,16 @@ public class ValidateResultForDtos { return result; } - public static EnumSet<NuitonValidatorScope> getScopes( - ValidateResultForDto validateResultForDto) { + public static EnumSet<NuitonValidatorScope> getScopes(ValidateResultForDto<?> validateResultForDto) { - EnumSet<NuitonValidatorScope> result = Sets.newEnumSet(Iterables.transform(validateResultForDto.getMessages(), new Function<ValidationMessage, NuitonValidatorScope>() { - @Override - public NuitonValidatorScope apply(ValidationMessage input) { - return input.getScope(); - } - }), NuitonValidatorScope.class); + EnumSet<NuitonValidatorScope> result = Sets.newEnumSet(Iterables.transform(validateResultForDto.getMessages(), ValidationMessage::getScope), NuitonValidatorScope.class); return result; } - public static List<ValidationMessage> scopeMessageFilter(final NuitonValidatorScope scope, ValidateResultForDto validateResultForDto) { - - List<ValidationMessage> result = Lists.newLinkedList(Iterables.filter( - validateResultForDto.getMessages(), - new Predicate<ValidationMessage>() { - @Override - public boolean apply(ValidationMessage input) { - return scope.equals(input.getScope()); - } - } - )); + public static List<ValidationMessage> scopeMessageFilter(final NuitonValidatorScope scope, ValidateResultForDto<?> validateResultForDto) { + + List<ValidationMessage> result = Lists.newLinkedList(validateResultForDto.getMessages().stream().filter(input -> scope.equals(input.getScope())).collect(Collectors.toList())); return result; } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessage.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessage.java index 9719eca..de1666f 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessage.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessage.java @@ -26,12 +26,16 @@ import com.google.common.base.MoreObjects; import fr.ird.observe.services.dto.ObserveDto; import org.nuiton.validator.NuitonValidatorScope; +import java.io.Serializable; + /** * Représente un message de validation. * * @author Sylvain Bavencoff - bavencoff@codelutin.com */ -public class ValidationMessage implements ObserveDto { +public class ValidationMessage implements ObserveDto, Serializable { + + private static final long serialVersionUID = 1L; protected final NuitonValidatorScope scope; diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java index b2e6db5..a8a2e52 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/actions/validate/ValidatorDtos.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.service.actions.validate; * #L% */ -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import fr.ird.observe.services.dto.referential.ReferentialDto; @@ -42,16 +41,10 @@ public class ValidatorDtos { final EnumSet<NuitonValidatorScope> scopes, final String context) { - return Sets.newHashSet(Iterables.filter(validators, new Predicate<ValidatorDto>() { - @Override - public boolean apply(ValidatorDto input) { - return - (validateData && ! ReferentialDto.class.isAssignableFrom(input.getDtoType()) - || validateReferential && ReferentialDto.class.isAssignableFrom(input.getDtoType())) - && scopes.contains(input.getScope()) - && context.equals(input.getContext()); - } - })); + return Sets.newHashSet(Iterables.filter(validators, input -> (validateData && ! ReferentialDto.class.isAssignableFrom(input.getDtoType()) + || validateReferential && ReferentialDto.class.isAssignableFrom(input.getDtoType())) + && scopes.contains(input.getScope()) + && context.equals(input.getContext()))); } diff --git a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java index 2cfb98c..de5ac57 100644 --- a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java +++ b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRest.java @@ -23,10 +23,10 @@ package fr.ird.observe.services.configuration; */ import com.google.common.base.MoreObjects; -import com.google.common.base.Optional; import org.nuiton.version.Version; import java.net.URL; +import java.util.Optional; /** * Configuration d'une source de données Rest non connectée. @@ -113,7 +113,7 @@ public class ObserveDataSourceConfigurationRest implements ObserveDataSourceConf } public Optional<String> getOptionalDatabaseName() { - return Optional.fromNullable(optionalDatabaseName); + return Optional.ofNullable(optionalDatabaseName); } public void setOptionalDatabaseName(String optionalDatabaseName) { diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/AbstractReference.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/AbstractReference.java index fe7674f..74ca603 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/AbstractReference.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/AbstractReference.java @@ -81,25 +81,11 @@ public abstract class AbstractReference<D extends IdDto> implements ObserveDto, //FIXME Use java Predicate API public static <BeanType extends AbstractReference> Predicate<BeanType> newIdPredicate(String id) { - final String $tmp = id; - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return Objects.equals($tmp, input.getId()); - } - }; - + return input -> Objects.equals(id, input.getId()); } public static <BeanType extends AbstractReference> Predicate<BeanType> newIdsPredicate(final Collection<String> ids) { - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return ids.contains(input.getId()); - } - }; + return input -> ids.contains(input.getId()); } public static Function<AbstractReference, String> getIdFunction() { @@ -107,13 +93,7 @@ public abstract class AbstractReference<D extends IdDto> implements ObserveDto, } public static <BeanType extends AbstractReference> Function<BeanType, String> newIdFunction() { - return new Function<BeanType, String>() { - - @Override - public String apply(BeanType input) { - return input.getId(); - } - }; + return input -> input.getId(); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/DataReference.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/DataReference.java index ea7d862..0e66d04 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/DataReference.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/DataReference.java @@ -43,34 +43,16 @@ public class DataReference<D extends DataDto> extends AbstractReference<D> { private static final Log log = LogFactory.getLog(DataReference.class); public static Predicate<? super DataReference> newLabelValuePredicate(final String propertyName, final Serializable propertyValue) { - return new Predicate<DataReference>() { - - @Override - public boolean apply(DataReference input) { - return input.getPropertyNames().contains(propertyName) - && propertyValue.equals(input.getPropertyValue(propertyName)); - } - }; + return (Predicate<DataReference>) input -> input.getPropertyNames().contains(propertyName) + && propertyValue.equals(input.getPropertyValue(propertyName)); } public static Predicate<DataReference> newTripSeinePredicate() { - return new Predicate<DataReference>() { - - @Override - public boolean apply(DataReference input) { - return IdDtos.isTripSeineId(input.getId()); - } - }; + return input -> IdDtos.isTripSeineId(input.getId()); } - public static <BeanType extends IdDto> Predicate<BeanType> newTripLonglinePredicate() { - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return IdDtos.isTripLonglineId(input.getId()); - } - }; + public static <BeanType extends IdDto> java.util.function.Predicate<BeanType> newTripLonglinePredicate() { + return input -> IdDtos.isTripLonglineId(input.getId()); } @Override diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java index 6ae9d56..57ace7b 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/IdDtos.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.dto; * #L% */ -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import fr.ird.observe.services.dto.longline.ActivityLonglineDto; @@ -34,6 +33,7 @@ import fr.ird.observe.services.dto.seine.TripSeineDto; import java.util.Collection; import java.util.Map; +import java.util.function.Predicate; public class IdDtos extends AbstractIdDtos { @@ -42,23 +42,11 @@ public class IdDtos extends AbstractIdDtos { } public static <BeanType extends IdDto> Predicate<BeanType> newTripSeinePredicate() { - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return isTripSeineId(input.getId()) ; - } - }; + return input -> isTripSeineId(input.getId()); } public static <BeanType extends IdDto> Predicate<BeanType> newTripLonglinePredicate() { - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return isTripLonglineId(input.getId()) ; - } - }; + return input -> isTripLonglineId(input.getId()); } public static <BeanType extends IdDto> boolean exists(Iterable<BeanType> source, String id) { @@ -166,13 +154,7 @@ public class IdDtos extends AbstractIdDtos { } public static <BeanType extends IdDto> Predicate<BeanType> newIdsPredicate(final Collection<String> ids) { - return new Predicate<BeanType>() { - - @Override - public boolean apply(BeanType input) { - return ids.contains(input.getId()) ; - } - }; + return input -> ids.contains(input.getId()); } public static <BeanType extends IdDto> Map<String, BeanType> splitById(Collection<BeanType> dtos) { diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/ObserveDbUserDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ObserveDbUserDtos.java index 3a316d0..9890489 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/ObserveDbUserDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ObserveDbUserDtos.java @@ -26,7 +26,7 @@ import java.util.Comparator; public class ObserveDbUserDtos extends AbstractObserveDbUserDtos { - protected static UserDtoComparator USER_DTO_COMPARATOR = new UserDtoComparator(); + protected static final UserDtoComparator USER_DTO_COMPARATOR = new UserDtoComparator(); public static UserDtoComparator getUserDtoComparator() { return USER_DTO_COMPARATOR; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java index cf53d6f..338a1b2 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/Report.java @@ -21,7 +21,6 @@ */ package fr.ird.observe.services.dto.actions.report; -import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.ObserveDto; @@ -148,12 +147,7 @@ public class Report implements Serializable, ObserveDto { } public ReportVariable getRepeatVariable(final String name) { - return Iterables.find(Lists.newArrayList(repeatVariables), new Predicate<ReportVariable>() { - @Override - public boolean apply(ReportVariable reportVariable) { - return name.equals(reportVariable.getName()); - } - }); + return Iterables.find(Lists.newArrayList(repeatVariables), reportVariable -> name.equals(reportVariable.getName())); } public boolean canExecute() { diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportOperation.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportOperation.java index 87a6499..ca9c1da 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportOperation.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportOperation.java @@ -36,6 +36,6 @@ public enum ReportOperation implements ObserveDto { SumColumn, SumIntColumn, SumIntRow, - SumRow; + SumRow } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportVariable.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportVariable.java index 47747cd..e062779 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportVariable.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/actions/report/ReportVariable.java @@ -46,11 +46,11 @@ public class ReportVariable<V> implements Serializable, ObserveDto { private static final long serialVersionUID = 1L; - protected String name; + protected final String name; - protected Class<V> type; + protected final Class<V> type; - protected String request; + protected final String request; protected Set<V> values; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ObserveDbRole.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ObserveDbRole.java index 936dfd8..4fb9127 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ObserveDbRole.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ObserveDbRole.java @@ -31,6 +31,6 @@ public enum ObserveDbRole { REFERENTIAL, USER, TECHNICAL, - ADMINISTRATOR; + ADMINISTRATOR } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java index dbc6eef..ef3aecf 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/ReferenceStatus.java @@ -35,6 +35,6 @@ public enum ReferenceStatus { disabled, /** status active */ - enabled; + enabled } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java index 4af4528..8daeb12 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/TripMapPointType.java @@ -43,6 +43,6 @@ public enum TripMapPointType { longlineActivityWithHaulingStart, longlineActivityWithHaulingEnd, longlineActivityWithInteraction, - longlineActivityWithStation; - + longlineActivityWithStation + } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java index 6e5ab78..3be588e 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/NonTargetCatchComputedValueSource.java @@ -47,6 +47,6 @@ public enum NonTargetCatchComputedValueSource { * * @since 3.0 */ - fromReferentiel; + fromReferentiel } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/SchoolType.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/SchoolType.java index ab341df..5454c94 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/SchoolType.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/SchoolType.java @@ -36,6 +36,6 @@ public enum SchoolType { objet, /** banc libre // was 2 before version 4.0 */ - libre; + libre } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/TypeTransmittingBuoyOperation.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/TypeTransmittingBuoyOperation.java index ef57b3c..b4db646 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/TypeTransmittingBuoyOperation.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/constants/seine/TypeTransmittingBuoyOperation.java @@ -35,10 +35,10 @@ public enum TypeTransmittingBuoyOperation { recuperationEtRemplacement("2", "3"); /** les codes des opérations sur balise */ - private String[] codeOperation; + private final String[] codeOperation; /** le count de balises lues */ - private int nbBalises; + private final int nbBalises; TypeTransmittingBuoyOperation(String... codeOperation) { this.codeOperation = codeOperation; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ObserveDtoGsonSupplier.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ObserveDtoGsonSupplier.java index 3c71fd4..6b055db 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ObserveDtoGsonSupplier.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/gson/ObserveDtoGsonSupplier.java @@ -49,13 +49,7 @@ import java.util.Date; */ public class ObserveDtoGsonSupplier implements Supplier<Gson> { - public static final Supplier<Gson> DEFAULT_GSON_SUPPLIER = new Supplier<Gson>() { - - @Override - public Gson get() { - return new ObserveDtoGsonSupplier().get(); - } - }; + public static final Supplier<Gson> DEFAULT_GSON_SUPPLIER = () -> new ObserveDtoGsonSupplier().get(); protected final boolean prettyPrint; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplate.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplate.java index 42a3390..3b79565 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplate.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplate.java @@ -22,10 +22,6 @@ package fr.ird.observe.services.dto.longline; * #L% */ -import fr.ird.observe.services.dto.longline.BasketDto; -import fr.ird.observe.services.dto.longline.SectionDto; -import fr.ird.observe.services.dto.longline.SectionTemplate; - import java.util.Collection; import java.util.LinkedHashSet; diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplates.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplates.java index 56ccf82..ccb3512 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplates.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/longline/SectionWithTemplates.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.dto.longline; * #L% */ -import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -39,14 +38,6 @@ import java.util.List; */ public class SectionWithTemplates { - protected static Function<SectionWithTemplate, SectionDto> GET_DELEGATE_FUNCTION = new Function<SectionWithTemplate, SectionDto>() { - @Override - public SectionDto apply(SectionWithTemplate input) { - return input.getDelegate(); - } - }; - - public static List<SectionWithTemplate> getSectionTemplates(Collection<SectionDto> sections) { List<SectionWithTemplate> sectionTemplates = new ArrayList<>(); @@ -64,6 +55,6 @@ public class SectionWithTemplates { } public static LinkedHashSet<SectionDto> getSections(List<SectionWithTemplate> data) { - return Sets.newLinkedHashSet(Iterables.transform(data, GET_DELEGATE_FUNCTION)); + return Sets.newLinkedHashSet(Iterables.transform(data, SectionWithTemplate::getDelegate)); } } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/PersonDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/PersonDtos.java index c3050f4..256ebf7 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/PersonDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/PersonDtos.java @@ -44,38 +44,20 @@ public class PersonDtos extends AbstractPersonDtos { } public static Predicate<ReferentialReference<PersonDto>> newCaptainReferencePredicate() { - return new Predicate<ReferentialReference<PersonDto>>() { - - @Override - public boolean test(ReferentialReference<PersonDto> input) { - return input.getPropertyNames().contains(PersonDto.PROPERTY_CAPTAIN) - && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_CAPTAIN)); - } - }; + return input -> input.getPropertyNames().contains(PersonDto.PROPERTY_CAPTAIN) + && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_CAPTAIN)); } public static Predicate<ReferentialReference<PersonDto>> newDataEntryOperatorReferencePredicate() { - return new Predicate<ReferentialReference<PersonDto>>() { - - @Override - public boolean test(ReferentialReference<PersonDto> input) { - return input.getPropertyNames().contains(PersonDto.PROPERTY_DATA_ENTRY_OPERATOR) - && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_DATA_ENTRY_OPERATOR)); - } - }; + return input -> input.getPropertyNames().contains(PersonDto.PROPERTY_DATA_ENTRY_OPERATOR) + && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_DATA_ENTRY_OPERATOR)); } public static Predicate<ReferentialReference<PersonDto>> newObserverReferencePredicate() { - return new Predicate<ReferentialReference<PersonDto>>() { - - @Override - public boolean test(ReferentialReference<PersonDto> input) { - return input.getPropertyNames().contains(PersonDto.PROPERTY_OBSERVER) - && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_OBSERVER)); - } - }; + return input -> input.getPropertyNames().contains(PersonDto.PROPERTY_OBSERVER) + && Objects.equals(true, input.getPropertyValue(PersonDto.PROPERTY_OBSERVER)); } diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java index 29c86f8..4b8b631 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialDtos.java @@ -87,7 +87,7 @@ public class ReferentialDtos extends AbstractReferentialDtos { GearCaracteristicDto.class, GearDto.class); - public static final ImmutableSet<Class<? extends ReferentialDto>> REFERENCE_SEINE_DTOS = ImmutableSet.<Class<? extends ReferentialDto>>of( + public static final ImmutableSet<Class<? extends ReferentialDto>> REFERENCE_SEINE_DTOS = ImmutableSet.of( VesselActivitySeineDto.class, SurroundingActivityDto.class, ReasonForNullSetDto.class, diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java index 25935c1..75a38b8 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/referential/ReferentialReferences.java @@ -22,12 +22,13 @@ package fr.ird.observe.services.dto.referential; * #L% */ -import com.google.common.base.Function; -import com.google.common.base.Predicate; +import fr.ird.observe.services.dto.AbstractReference; import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; /** @@ -37,21 +38,9 @@ import java.util.stream.Collectors; */ public class ReferentialReferences { - protected static final Function<ReferentialReference, String> ID_FUNCTION = new Function<ReferentialReference, String>() { + protected static final Function<ReferentialReference, String> ID_FUNCTION = AbstractReference::getId; - @Override - public String apply(ReferentialReference input) { - return input.getId(); - } - }; - - protected static final Predicate<ReferentialReference> IS_ENABLE_PREDICATE = new Predicate<ReferentialReference>() { - - @Override - public boolean apply(ReferentialReference input) { - return input.isEnabled(); - } - }; + protected static final Predicate<ReferentialReference> IS_ENABLE_PREDICATE = ReferentialReference::isEnabled; public static <D extends ReferentialDto> List<ReferentialReference<D>> filterEnabled(Collection<ReferentialReference<D>> references) { diff --git a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveRequestBuilder.java b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveRequestBuilder.java index 3f0c124..73888f4 100644 --- a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveRequestBuilder.java +++ b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveRequestBuilder.java @@ -103,7 +103,7 @@ public class ObserveRequestBuilder { return this; } - public ObserveRequestBuilder addParameter(String parameterName, Object toJson) throws IOException { + public ObserveRequestBuilder addParameter(String parameterName, Object toJson) { String json = gson.toJson(toJson); return addParameter(parameterName, json); } diff --git a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponse.java b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponse.java index 730d7aa..419f966 100644 --- a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponse.java +++ b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponse.java @@ -26,8 +26,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.Header; -import java.io.IOException; - /** * @author Arnaud Thimel - thimel@codelutin.com */ @@ -44,7 +42,7 @@ public class ObserveResponse<T> { protected final T resultObject; - protected ObserveResponse(int statusCode, Header[] headers, String responseAsString, T resultObject) throws IOException { + protected ObserveResponse(int statusCode, Header[] headers, String responseAsString, T resultObject) { this.statusCode = statusCode; this.headers = headers; this.resultObject = resultObject; @@ -82,7 +80,7 @@ public class ObserveResponse<T> { throw new IllegalArgumentException(key + " key is not found in header"); } - public String getResponse() throws IOException { + public String getResponse() { return responseAsString; } diff --git a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponseBuilder.java b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponseBuilder.java index fe1d17e..229d726 100644 --- a/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponseBuilder.java +++ b/observe-services-rest/src/main/java/fr/ird/observe/services/http/ObserveResponseBuilder.java @@ -361,7 +361,7 @@ public class ObserveResponseBuilder { } } - protected <M extends HttpEntityEnclosingRequestBase> void addParameters(M method, String contentType, List<? extends NameValuePair> parameters) throws UnsupportedEncodingException { + protected <M extends HttpEntityEnclosingRequestBase> void addParameters(M method, String contentType, List<? extends NameValuePair> parameters) { UrlEncodedFormEntity encodedFormEntity = new UrlEncodedFormEntity(parameters, Charsets.UTF_8); if (StringUtils.isNotBlank(contentType)) { encodedFormEntity.setContentType(contentType); @@ -379,7 +379,7 @@ public class ObserveResponseBuilder { } } - public <T> T convertJson(String json, Type type) throws IOException { + public <T> T convertJson(String json, Type type) { Preconditions.checkNotNull(json); Preconditions.checkNotNull(gson); diff --git a/observe-services-rest/src/test/java/fr/ird/observe/services/service/AbstractServiceRestTest.java b/observe-services-rest/src/test/java/fr/ird/observe/services/service/AbstractServiceRestTest.java index 85aa99d..c43c2ab 100644 --- a/observe-services-rest/src/test/java/fr/ird/observe/services/service/AbstractServiceRestTest.java +++ b/observe-services-rest/src/test/java/fr/ird/observe/services/service/AbstractServiceRestTest.java @@ -66,7 +66,7 @@ public abstract class AbstractServiceRestTest { } @After - public void tearDown() throws Exception { + public void tearDown() { if (dataSourceConnection != null) { dataSourceService.close(); diff --git a/observe-services-rest/src/test/java/fr/ird/observe/services/service/ReferenceValuesSetServiceRestTest.java b/observe-services-rest/src/test/java/fr/ird/observe/services/service/ReferenceValuesSetServiceRestTest.java index dc5ab55..3453f17 100644 --- a/observe-services-rest/src/test/java/fr/ird/observe/services/service/ReferenceValuesSetServiceRestTest.java +++ b/observe-services-rest/src/test/java/fr/ird/observe/services/service/ReferenceValuesSetServiceRestTest.java @@ -36,8 +36,6 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import java.util.Date; - /** * Created on 13/11/15. * @@ -74,7 +72,7 @@ public class ReferenceValuesSetServiceRestTest { //FIXME ReferenceSetsRequest request = new ReferenceSetsRequest(); request.setRequestName(requestName); - request.setLastUpdateDates(ImmutableMap.<Class<?>, Date>of()); + request.setLastUpdateDates(ImmutableMap.of()); ImmutableSet<ReferentialReferenceSet<?>> referenceSetResult = service.getReferentialReferenceSets(request); Assert.assertNotNull(referenceSetResult); diff --git a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceRestTest.java b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceRestTest.java index 3fc0424..052158a 100644 --- a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceRestTest.java +++ b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceRestTest.java @@ -37,9 +37,7 @@ import org.junit.Test; import java.io.IOException; import java.net.URL; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Classe abstraite de test d'un report. @@ -102,9 +100,6 @@ public abstract class AbstractReportServiceRestTest extends AbstractServiceRestT // creation de l'executeur de report report = service.populateVariables(report, TRIP_SEINE_ID_1); - // les variables a utiliser (par defaut, pas de variable) - Map<String, Object> variables = new HashMap<>(); - // preparation des variables prepareVariables(); diff --git a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchRestTest.java b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchRestTest.java index 971a311..f384c3e 100644 --- a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchRestTest.java +++ b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchRestTest.java @@ -148,7 +148,7 @@ public class ReportAccessoryCatchRestTest extends AbstractReportServiceRestTest assertResultRow(result, row++, "[FAO]SPL [sc]Sphyrna lewini [fr]Requin marteau halicorne", "-", "-"); assertResultRow(result, row++, "[FAO]SPK [sc]Sphyrna mokarran [fr]Grand requin marteau", "-", "-"); assertResultRow(result, row++, "[FAO]SPZ [sc]Sphyrna zygaena [fr]Requin marteau commun", "-", "-"); - assertResultRow(result, row++, "[FAO]TOD [sc]Torpedinidae [fr]Torpilles, raies électriq. nca ", "-", "-"); + assertResultRow(result, row, "[FAO]TOD [sc]Torpedinidae [fr]Torpilles, raies électriq. nca ", "-", "-"); } diff --git a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceRestTest.java b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceRestTest.java index 542ba18..660f484 100644 --- a/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceRestTest.java +++ b/observe-services-rest/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceRestTest.java @@ -25,7 +25,74 @@ package fr.ird.observe.services.service.actions.validate; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.referential.CountryDto; +import fr.ird.observe.services.dto.referential.FpaZoneDto; +import fr.ird.observe.services.dto.referential.GearCaracteristicDto; +import fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto; +import fr.ird.observe.services.dto.referential.GearDto; +import fr.ird.observe.services.dto.referential.HarbourDto; +import fr.ird.observe.services.dto.referential.LengthWeightParameterDto; +import fr.ird.observe.services.dto.referential.OceanDto; +import fr.ird.observe.services.dto.referential.OrganismDto; +import fr.ird.observe.services.dto.referential.PersonDto; +import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.referential.SexDto; +import fr.ird.observe.services.dto.referential.SpeciesDto; +import fr.ird.observe.services.dto.referential.SpeciesGroupDto; +import fr.ird.observe.services.dto.referential.SpeciesListDto; +import fr.ird.observe.services.dto.referential.VesselDto; +import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; +import fr.ird.observe.services.dto.referential.VesselTypeDto; +import fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto; +import fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto; +import fr.ird.observe.services.dto.referential.longline.BaitTypeDto; +import fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto; +import fr.ird.observe.services.dto.referential.longline.EncounterTypeDto; +import fr.ird.observe.services.dto.referential.longline.HealthnessDto; +import fr.ird.observe.services.dto.referential.longline.HookPositionDto; +import fr.ird.observe.services.dto.referential.longline.HookSizeDto; +import fr.ird.observe.services.dto.referential.longline.HookTypeDto; +import fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto; +import fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto; +import fr.ird.observe.services.dto.referential.longline.LightsticksColorDto; +import fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto; +import fr.ird.observe.services.dto.referential.longline.LineTypeDto; +import fr.ird.observe.services.dto.referential.longline.MaturityStatusDto; +import fr.ird.observe.services.dto.referential.longline.MitigationTypeDto; +import fr.ird.observe.services.dto.referential.longline.SensorBrandDto; +import fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto; +import fr.ird.observe.services.dto.referential.longline.SensorTypeDto; +import fr.ird.observe.services.dto.referential.longline.SettingShapeDto; +import fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto; +import fr.ird.observe.services.dto.referential.longline.StomacFullnessDto; +import fr.ird.observe.services.dto.referential.longline.TripTypeDto; +import fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto; +import fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto; +import fr.ird.observe.services.dto.referential.seine.DetectionModeDto; +import fr.ird.observe.services.dto.referential.seine.ObjectFateDto; +import fr.ird.observe.services.dto.referential.seine.ObjectOperationDto; +import fr.ird.observe.services.dto.referential.seine.ObjectTypeDto; +import fr.ird.observe.services.dto.referential.seine.ObservedSystemDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto; +import fr.ird.observe.services.dto.referential.seine.SpeciesFateDto; +import fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto; +import fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto; +import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto; +import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto; +import fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto; +import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; +import fr.ird.observe.services.dto.referential.seine.WindDto; +import fr.ird.observe.services.dto.seine.ActivitySeineDto; +import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.NonTargetCatchDto; +import fr.ird.observe.services.dto.seine.RouteDto; +import fr.ird.observe.services.dto.seine.SchoolEstimateDto; +import fr.ird.observe.services.dto.seine.SetSeineDto; +import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; +import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.AbstractServiceRestTest; import org.junit.Assert; import org.junit.Test; @@ -37,24 +104,24 @@ import org.nuiton.validator.NuitonValidatorScope; public class ValidateServiceRestTest extends AbstractServiceRestTest { protected static final ImmutableSet<Class<? extends ReferentialDto>> REFERENTIAL_DTO_TYPES = ImmutableSet.of( - fr.ird.observe.services.dto.referential.CountryDto.class, - fr.ird.observe.services.dto.referential.FpaZoneDto.class, - fr.ird.observe.services.dto.referential.GearCaracteristicDto.class, - fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto.class, - fr.ird.observe.services.dto.referential.GearDto.class, - fr.ird.observe.services.dto.referential.HarbourDto.class, - fr.ird.observe.services.dto.referential.LengthWeightParameterDto.class, - fr.ird.observe.services.dto.referential.OceanDto.class, - fr.ird.observe.services.dto.referential.OrganismDto.class, - fr.ird.observe.services.dto.referential.PersonDto.class, - fr.ird.observe.services.dto.referential.ProgramDto.class, - fr.ird.observe.services.dto.referential.SexDto.class, - fr.ird.observe.services.dto.referential.SpeciesDto.class, - fr.ird.observe.services.dto.referential.SpeciesGroupDto.class, - fr.ird.observe.services.dto.referential.SpeciesListDto.class, - fr.ird.observe.services.dto.referential.VesselDto.class, - fr.ird.observe.services.dto.referential.VesselSizeCategoryDto.class, - fr.ird.observe.services.dto.referential.VesselTypeDto.class + CountryDto.class, + FpaZoneDto.class, + GearCaracteristicDto.class, + GearCaracteristicTypeDto.class, + GearDto.class, + HarbourDto.class, + LengthWeightParameterDto.class, + OceanDto.class, + OrganismDto.class, + PersonDto.class, + ProgramDto.class, + SexDto.class, + SpeciesDto.class, + SpeciesGroupDto.class, + SpeciesListDto.class, + VesselDto.class, + VesselSizeCategoryDto.class, + VesselTypeDto.class ); protected ValidateService service; @@ -82,67 +149,67 @@ public class ValidateServiceRestTest extends AbstractServiceRestTest { Assert.assertNotNull(resultByType); Assert.assertEquals(59, resultByType.size()); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.CountryDto.class, 53); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.FpaZoneDto.class, 41); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearCaracteristicDto.class, 22); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearDto.class, 26); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.HarbourDto.class, 74); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.LengthWeightParameterDto.class, 352); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.OceanDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.OrganismDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.PersonDto.class, 390); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.ProgramDto.class, 27); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SexDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesDto.class, 275); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesGroupDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesListDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselDto.class, 977); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselSizeCategoryDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselTypeDto.class, 14); - - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitTypeDto.class, 16); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.EncounterTypeDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HealthnessDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookPositionDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookSizeDto.class, 22); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookTypeDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LightsticksColorDto.class, 7); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto.class, 2); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LineTypeDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.MaturityStatusDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.MitigationTypeDto.class, 15); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorBrandDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto.class, 2); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorTypeDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SettingShapeDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto.class, 17); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.StomacFullnessDto.class, 7); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.TripTypeDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto.class, 3); - - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.DetectionModeDto.class, 10); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectFateDto.class, 9); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectOperationDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectTypeDto.class, 23); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObservedSystemDto.class, 21); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto.class, 10); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SpeciesFateDto.class, 9); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto.class, 23); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.WeightCategoryDto.class, 101); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.WindDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, CountryDto.class, 53); + assertValidateResultForReferentialDtoType(resultByType, FpaZoneDto.class, 41); + assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicDto.class, 22); + assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicTypeDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, GearDto.class, 26); + assertValidateResultForReferentialDtoType(resultByType, HarbourDto.class, 74); + assertValidateResultForReferentialDtoType(resultByType, LengthWeightParameterDto.class, 352); + assertValidateResultForReferentialDtoType(resultByType, OceanDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, OrganismDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, PersonDto.class, 390); + assertValidateResultForReferentialDtoType(resultByType, ProgramDto.class, 27); + assertValidateResultForReferentialDtoType(resultByType, SexDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, SpeciesDto.class, 275); + assertValidateResultForReferentialDtoType(resultByType, SpeciesGroupDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, SpeciesListDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, VesselDto.class, 977); + assertValidateResultForReferentialDtoType(resultByType, VesselSizeCategoryDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, VesselTypeDto.class, 14); + + assertValidateResultForReferentialDtoType(resultByType, BaitHaulingStatusDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, BaitSettingStatusDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, BaitTypeDto.class, 16); + assertValidateResultForReferentialDtoType(resultByType, CatchFateLonglineDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, EncounterTypeDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, HealthnessDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, HookPositionDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, HookSizeDto.class, 22); + assertValidateResultForReferentialDtoType(resultByType, HookTypeDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, ItemHorizontalPositionDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, ItemVerticalPositionDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, LightsticksColorDto.class, 7); + assertValidateResultForReferentialDtoType(resultByType, LightsticksTypeDto.class, 2); + assertValidateResultForReferentialDtoType(resultByType, LineTypeDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, MaturityStatusDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, MitigationTypeDto.class, 15); + assertValidateResultForReferentialDtoType(resultByType, SensorBrandDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, SensorDataFormatDto.class, 2); + assertValidateResultForReferentialDtoType(resultByType, SensorTypeDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, SettingShapeDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, SizeMeasureTypeDto.class, 17); + assertValidateResultForReferentialDtoType(resultByType, StomacFullnessDto.class, 7); + assertValidateResultForReferentialDtoType(resultByType, TripTypeDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, VesselActivityLonglineDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, WeightMeasureTypeDto.class, 3); + + assertValidateResultForReferentialDtoType(resultByType, DetectionModeDto.class, 10); + assertValidateResultForReferentialDtoType(resultByType, ObjectFateDto.class, 9); + assertValidateResultForReferentialDtoType(resultByType, ObjectOperationDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, ObjectTypeDto.class, 23); + assertValidateResultForReferentialDtoType(resultByType, ObservedSystemDto.class, 21); + assertValidateResultForReferentialDtoType(resultByType, ReasonForDiscardDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, ReasonForNoFishingDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, ReasonForNullSetDto.class, 10); + assertValidateResultForReferentialDtoType(resultByType, SpeciesFateDto.class, 9); + assertValidateResultForReferentialDtoType(resultByType, SpeciesStatusDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, SurroundingActivityDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyOperationDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyTypeDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, VesselActivitySeineDto.class, 23); + assertValidateResultForReferentialDtoType(resultByType, WeightCategoryDto.class, 101); + assertValidateResultForReferentialDtoType(resultByType, WindDto.class, 13); } @@ -161,11 +228,11 @@ public class ValidateServiceRestTest extends AbstractServiceRestTest { Assert.assertNotNull(resultByType); Assert.assertEquals(5, resultByType.size()); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TripSeineDto.class, 2); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.RouteDto.class, 80); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.ActivitySeineDto.class, 1519); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.FloatingObjectDto.class, 99); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.SetSeineDto.class, 77); + assertValidateResultForDtoType(resultByType, TripSeineDto.class, 2); + assertValidateResultForDtoType(resultByType, RouteDto.class, 80); + assertValidateResultForDtoType(resultByType, ActivitySeineDto.class, 1519); + assertValidateResultForDtoType(resultByType, FloatingObjectDto.class, 99); + assertValidateResultForDtoType(resultByType, SetSeineDto.class, 77); } @@ -185,14 +252,14 @@ public class ValidateServiceRestTest extends AbstractServiceRestTest { Assert.assertNotNull(resultByType); Assert.assertEquals(8, resultByType.size()); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TripSeineDto.class, 2); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.RouteDto.class, 80); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.ActivitySeineDto.class, 1519); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.FloatingObjectDto.class, 99); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TransmittingBuoyDto.class, 42); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.SetSeineDto.class, 77); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.NonTargetCatchDto.class, 3); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.SchoolEstimateDto.class, 27); + assertValidateResultForDtoType(resultByType, TripSeineDto.class, 2); + assertValidateResultForDtoType(resultByType, RouteDto.class, 80); + assertValidateResultForDtoType(resultByType, ActivitySeineDto.class, 1519); + assertValidateResultForDtoType(resultByType, FloatingObjectDto.class, 99); + assertValidateResultForDtoType(resultByType, TransmittingBuoyDto.class, 42); + assertValidateResultForDtoType(resultByType, SetSeineDto.class, 77); + assertValidateResultForDtoType(resultByType, NonTargetCatchDto.class, 3); + assertValidateResultForDtoType(resultByType, SchoolEstimateDto.class, 27); } diff --git a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/AbstractSpeciesFieldValidator.java b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/AbstractSpeciesFieldValidator.java index 350652d..a827a66 100644 --- a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/AbstractSpeciesFieldValidator.java +++ b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/AbstractSpeciesFieldValidator.java @@ -63,9 +63,9 @@ public abstract class AbstractSpeciesFieldValidator extends FieldValidatorSuppor public static class Bound { - private Float min; + private final Float min; - private Float max; + private final Float max; Bound(Float min, Float max) { this.min = min; diff --git a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_en_GB.properties b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_en_GB.properties index e2fccda..1419895 100644 --- a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_en_GB.properties +++ b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_en_GB.properties @@ -320,6 +320,7 @@ validator.service.targetCatch.required.weight= validator.service.targetCatch.required.weightCategory= validator.service.targetCatch.required.well= validator.service.targetCatch.uniqueKey= +validator.service.targetDiscarded.bound.weight= validator.service.targetDiscarded.comment.tobig= validator.service.targetDiscarded.desactivated.reasonForDiscard= validator.service.targetDiscarded.desactivated.species= @@ -399,4 +400,3 @@ validator.service.vesselSizeCategory.required.capacityLabel= validator.service.vesselSizeCategory.required.gaugeLabel= validator.service.wind.required.speedRange= validator.service.wind.required.waveHeight= -validator.service.targetDiscarded.bound.weight= diff --git a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_es_ES.properties b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_es_ES.properties index fc25bdf..40d4b91 100644 --- a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_es_ES.properties +++ b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_es_ES.properties @@ -320,6 +320,7 @@ validator.service.targetCatch.required.weight=No se ha introducido el peso. validator.service.targetCatch.required.weightCategory=Se debe seleccionar una categoría de peso. validator.service.targetCatch.required.well=No se ha introducido la cuba. validator.service.targetCatch.uniqueKey=El par (categoría de peso - cuba) debe ser única. +validator.service.targetDiscarded.bound.weight= validator.service.targetDiscarded.comment.tobig=La longitud del campo de comentarios está limitada a 1024 caracteres. validator.service.targetDiscarded.desactivated.reasonForDiscard=La causa del descarte seleccionada está desactivada. validator.service.targetDiscarded.desactivated.species=La especie seleccionada está desactivada. @@ -399,4 +400,3 @@ validator.service.vesselSizeCategory.required.capacityLabel=La etiqueta «Capaci validator.service.vesselSizeCategory.required.gaugeLabel=La etiqueta «Capacidad00BB no se ha establecido. validator.service.wind.required.speedRange=Etiqueta para la velocidad del viento no especificada. validator.service.wind.required.waveHeight=Etiqueta descriptiva para la altura media de las olas no especificada. -validator.service.targetDiscarded.bound.weight= diff --git a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_fr_FR.properties b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_fr_FR.properties index cbc3b01..f326125 100644 --- a/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_fr_FR.properties +++ b/observe-services-topia-validation/src/main/resources/i18n/observe-services-topia-validation_fr_FR.properties @@ -320,6 +320,7 @@ validator.service.targetCatch.required.weight=Le poids n'est pas renseigné. validator.service.targetCatch.required.weightCategory=La sélection d'une catégorie poids est obligatoire. validator.service.targetCatch.required.well=La cuve n'est pas renseignée. validator.service.targetCatch.uniqueKey=Le couple (catégorie poids - well) doit être unique. +validator.service.targetDiscarded.bound.weight= validator.service.targetDiscarded.comment.tobig=La taille du commentaire est limitée à 1024 caractères. validator.service.targetDiscarded.desactivated.reasonForDiscard=La raison rejet sélectionnée est désactivée. validator.service.targetDiscarded.desactivated.species=L'espèce sélectionnée est désactivée. @@ -399,4 +400,3 @@ validator.service.vesselSizeCategory.required.capacityLabel=Le libellé Capacit validator.service.vesselSizeCategory.required.gaugeLabel=Le libellé Jauge n'est pas renseigné. validator.service.wind.required.speedRange=Libellé vitesse vent non renseigné. validator.service.wind.required.waveHeight=Libellé descriptif hauteur moyenne vagues non renseigné. -validator.service.targetDiscarded.bound.weight= diff --git a/observe-services-topia-validation/src/test/java/fr/ird/observe/services/topia/validation/BeanValidatorDetectorTest.java b/observe-services-topia-validation/src/test/java/fr/ird/observe/services/topia/validation/BeanValidatorDetectorTest.java index 4bc32cd..1dcba07 100644 --- a/observe-services-topia-validation/src/test/java/fr/ird/observe/services/topia/validation/BeanValidatorDetectorTest.java +++ b/observe-services-topia-validation/src/test/java/fr/ird/observe/services/topia/validation/BeanValidatorDetectorTest.java @@ -141,7 +141,7 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { static Class<?>[] ALL_TYPES; @BeforeClass - public static void setUpClass() throws Exception { + public static void setUpClass() { ALL_TYPES = ObserveEntityEnum.getContractClasses(); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveSecurityHelper.java b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveSecurityHelper.java index 061a147..46c7461 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveSecurityHelper.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveSecurityHelper.java @@ -22,7 +22,6 @@ package fr.ird.observe.services; * #L% */ -import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import fr.ird.observe.entities.Entities; @@ -45,6 +44,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.function.Function; /** * FIXME Ca sert à quoi? @@ -100,12 +100,7 @@ public class ObserveSecurityHelper { OBSERVE_SEINE_SCHEMA_NAME, OBSERVE_LONGLINE_SCHEMA_NAME); - public static final Function<String, String> ESCAPE_STRING = new Function<String, String>() { - @Override - public String apply(String input) { - return "\"" + input + "\""; - } - }; + public static final Function<String, String> ESCAPE_STRING = input -> "\"" + input + "\""; protected final ObserveJdbcHelper jdbcHelper; @@ -236,7 +231,7 @@ public class ObserveSecurityHelper { } protected Set<String> escapedNames(Iterable<String> names) { - Iterable<String> transform = Iterables.transform(names, ESCAPE_STRING); + Iterable<String> transform = Iterables.transform(names, ESCAPE_STRING::apply); return Sets.newHashSet(transform); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java index aeb28dd..3646444 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveServiceTopia.java @@ -22,7 +22,6 @@ package fr.ird.observe.services; * #L% */ -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import fr.ird.observe.ObserveTopiaPersistenceContext; @@ -57,6 +56,7 @@ import java.sql.SQLException; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.Optional; /** * Support pour toute implantation d'un service ToPIA. @@ -138,7 +138,7 @@ public abstract class ObserveServiceTopia implements ObserveService { ObserveTopiaPersistenceContext persistenceContext = serviceContext.getTopiaPersistenceContext(); Date lastUpdateDate = persistenceContext.getLastUpdateDate(entityType); - Optional<Date> result = Optional.fromNullable(lastUpdateDate); + Optional<Date> result = Optional.ofNullable(lastUpdateDate); return result; } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveTopiaApplicationContextFactory.java b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveTopiaApplicationContextFactory.java index 43631a4..f5f14c6 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveTopiaApplicationContextFactory.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/ObserveTopiaApplicationContextFactory.java @@ -22,7 +22,6 @@ package fr.ird.observe.services; * #L% */ -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaConfiguration; @@ -37,6 +36,7 @@ import org.nuiton.topia.persistence.TopiaApplicationContext; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Optional; /** * Usine de contexte applicatif ToPIA. @@ -86,7 +86,7 @@ public class ObserveTopiaApplicationContextFactory { public static Optional<ObserveTopiaApplicationContext> getTopiaApplicationContextIfPresent(ObserveDataSourceConfigurationTopiaSupport dataSourceConfiguration) { ObserveTopiaApplicationContext topiaApplicationContext = TOPIA_APPLICATION_CONTEXT_CACHE.get(dataSourceConfiguration); - return Optional.fromNullable(topiaApplicationContext); + return Optional.ofNullable(topiaApplicationContext); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderEngine.java b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderEngine.java index 9838a62..3542685 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderEngine.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderEngine.java @@ -47,17 +47,17 @@ public class BinderEngine implements ReferenceBinderEngine { private static final BinderEngine INSTANCE = new BinderEngine(); - protected ImmutableMap<Class<? extends ReferentialDto>, BinderSupport> referentialBinders; + protected final ImmutableMap<Class<? extends ReferentialDto>, BinderSupport> referentialBinders; - protected ImmutableMap<Class<? extends DataDto>, BinderSupport> dataBinders; + protected final ImmutableMap<Class<? extends DataDto>, BinderSupport> dataBinders; - protected ImmutableMap<Class<? extends ReferentialDto>, Class<? extends ObserveReferentialEntity>> referentialDtoToEntityTypes; + protected final ImmutableMap<Class<? extends ReferentialDto>, Class<? extends ObserveReferentialEntity>> referentialDtoToEntityTypes; - protected ImmutableMap<Class<? extends DataDto>, Class<? extends ObserveDataEntity>> dataDtoToEntityTypes; + protected final ImmutableMap<Class<? extends DataDto>, Class<? extends ObserveDataEntity>> dataDtoToEntityTypes; - protected ImmutableMap<Class<? extends ObserveReferentialEntity>, Class<? extends ReferentialDto>> referentialEntityToDtoTypes; + protected final ImmutableMap<Class<? extends ObserveReferentialEntity>, Class<? extends ReferentialDto>> referentialEntityToDtoTypes; - protected ImmutableMap<Class<? extends ObserveDataEntity>, Class<? extends DataDto>> dataEntityToDtoTypes; + protected final ImmutableMap<Class<? extends ObserveDataEntity>, Class<? extends DataDto>> dataEntityToDtoTypes; public static BinderEngine get() { return INSTANCE; diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderSupport.java b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderSupport.java index e402a8f..bfc49ce 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderSupport.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/BinderSupport.java @@ -64,101 +64,29 @@ import java.util.List; */ public abstract class BinderSupport<E extends TopiaEntity, D extends IdDto> { - protected static final Function<TripMapPointType, TripMapPointTypePersist> TRIP_MAP_POINT_TO_ENTITY = new Function<TripMapPointType, TripMapPointTypePersist>() { + protected static final Function<TripMapPointType, TripMapPointTypePersist> TRIP_MAP_POINT_TO_ENTITY = input -> TripMapPointTypePersist.valueOf(input.name()); - @Override - public TripMapPointTypePersist apply(TripMapPointType input) { - return TripMapPointTypePersist.valueOf(input.name()); - } - }; - - protected static final Function<GearType, GearTypePersist> GEAR_TYPE_TO_ENTITY = new Function<GearType, GearTypePersist>() { - - @Override - public GearTypePersist apply(GearType input) { - return GearTypePersist.valueOf(input.name()); - } - }; - - protected static final Function<ReferenceStatus, ReferenceStatusPersist> REFERENCE_STATUS_TO_ENTITY = new Function<ReferenceStatus, ReferenceStatusPersist>() { - - @Override - public ReferenceStatusPersist apply(ReferenceStatus input) { - return ReferenceStatusPersist.valueOf(input.name()); - } - }; - - protected static final Function<Ownership, OwnershipPersist> OWNERSHIP_TO_ENTITY = new Function<Ownership, OwnershipPersist>() { - - @Override - public OwnershipPersist apply(Ownership input) { - return input == null ? null : OwnershipPersist.valueOf(input.name()); - } - }; - - protected static final Function<SchoolType, SchoolTypePersist> SCHOOL_TYPE_TO_ENTITY = new Function<SchoolType, SchoolTypePersist>() { - - @Override - public SchoolTypePersist apply(SchoolType input) { - return input == null ? null : SchoolTypePersist.valueOf(input.name()); - } - }; + protected static final Function<GearType, GearTypePersist> GEAR_TYPE_TO_ENTITY = input -> GearTypePersist.valueOf(input.name()); - protected static final Function<TypeTransmittingBuoyOperation, TypeTransmittingBuoyOperationPersist> TYPE_TRANSMITTING_BUOY_OPERATION_TO_ENTITY = new Function<TypeTransmittingBuoyOperation, TypeTransmittingBuoyOperationPersist>() { + protected static final Function<ReferenceStatus, ReferenceStatusPersist> REFERENCE_STATUS_TO_ENTITY = input -> ReferenceStatusPersist.valueOf(input.name()); - @Override - public TypeTransmittingBuoyOperationPersist apply(TypeTransmittingBuoyOperation input) { - return input == null ? null : TypeTransmittingBuoyOperationPersist.valueOf(input.name()); - } - }; + protected static final Function<Ownership, OwnershipPersist> OWNERSHIP_TO_ENTITY = input -> input == null ? null : OwnershipPersist.valueOf(input.name()); - protected static final Function<NonTargetCatchComputedValueSource, NonTargetCatchComputedValueSourcePersist> NON_TARGET_CATCH_COMPUTED_VALUE_SOURCE_TO_ENTITY = new Function<NonTargetCatchComputedValueSource, NonTargetCatchComputedValueSourcePersist>() { + protected static final Function<SchoolType, SchoolTypePersist> SCHOOL_TYPE_TO_ENTITY = input -> input == null ? null : SchoolTypePersist.valueOf(input.name()); - @Override - public NonTargetCatchComputedValueSourcePersist apply(NonTargetCatchComputedValueSource input) { - return input == null ? null : NonTargetCatchComputedValueSourcePersist.valueOf(input.name()); - } - }; + protected static final Function<TypeTransmittingBuoyOperation, TypeTransmittingBuoyOperationPersist> TYPE_TRANSMITTING_BUOY_OPERATION_TO_ENTITY = input -> input == null ? null : TypeTransmittingBuoyOperationPersist.valueOf(input.name()); - protected static final Function<TripMapPointTypePersist, TripMapPointType> TRIP_MAP_POINT_TO_DTO = new Function<TripMapPointTypePersist, TripMapPointType>() { + protected static final Function<NonTargetCatchComputedValueSource, NonTargetCatchComputedValueSourcePersist> NON_TARGET_CATCH_COMPUTED_VALUE_SOURCE_TO_ENTITY = input -> input == null ? null : NonTargetCatchComputedValueSourcePersist.valueOf(input.name()); - @Override - public TripMapPointType apply(TripMapPointTypePersist input) { - return TripMapPointType.valueOf(input.name()); - } - }; + protected static final Function<TripMapPointTypePersist, TripMapPointType> TRIP_MAP_POINT_TO_DTO = input -> TripMapPointType.valueOf(input.name()); - protected static final Function<GearTypePersist, GearType> GEAR_TYPE_TO_DTO = new Function<GearTypePersist, GearType>() { + protected static final Function<GearTypePersist, GearType> GEAR_TYPE_TO_DTO = input -> input == null ? null : GearType.valueOf(input.name()); - @Override - public GearType apply(GearTypePersist input) { - return input == null ? null : GearType.valueOf(input.name()); - } - }; + protected static final Function<ReferenceStatusPersist, ReferenceStatus> REFERENCE_STATUS_TO_DTO = input -> input == null ? null : ReferenceStatus.valueOf(input.name()); - protected static final Function<ReferenceStatusPersist, ReferenceStatus> REFERENCE_STATUS_TO_DTO = new Function<ReferenceStatusPersist, ReferenceStatus>() { + protected static final Function<OwnershipPersist, Ownership> OWNERSHIP_TO_DTO = input -> input == null ? null : Ownership.valueOf(input.name()); - @Override - public ReferenceStatus apply(ReferenceStatusPersist input) { - return input == null ? null : ReferenceStatus.valueOf(input.name()); - } - }; - - protected static final Function<OwnershipPersist, Ownership> OWNERSHIP_TO_DTO = new Function<OwnershipPersist, Ownership>() { - - @Override - public Ownership apply(OwnershipPersist input) { - return input == null ? null : Ownership.valueOf(input.name()); - } - }; - - protected static final Function<SchoolTypePersist, SchoolType> SCHOOL_TYPE_TO_DTO = new Function<SchoolTypePersist, SchoolType>() { - - @Override - public SchoolType apply(SchoolTypePersist input) { - return input == null ? null : SchoolType.valueOf(input.name()); - } - }; + protected static final Function<SchoolTypePersist, SchoolType> SCHOOL_TYPE_TO_DTO = input -> input == null ? null : SchoolType.valueOf(input.name()); // protected static final Function<fr.ird.observe.entities.constants.seine.TypeTransmittingBuoyOperationPersist, fr.ird.observe.services.dto.constants.seine.TypeTransmittingBuoyOperationPersist> TRANSMITTING_BUOY_OPERATION_TO_DTO = new Function<fr.ird.observe.entities.constants.seine.TypeTransmittingBuoyOperationPersist, fr.ird.observe.services.dto.constants.seine.TypeTransmittingBuoyOperationPersist>() { // @@ -168,13 +96,7 @@ public abstract class BinderSupport<E extends TopiaEntity, D extends IdDto> { // } // }; - protected static final Function<NonTargetCatchComputedValueSourcePersist, NonTargetCatchComputedValueSource> NON_TARGET_CATCH_COMPUTED_VALUE_SOURCE_TO_DTO = new Function<NonTargetCatchComputedValueSourcePersist, NonTargetCatchComputedValueSource>() { - - @Override - public NonTargetCatchComputedValueSource apply(NonTargetCatchComputedValueSourcePersist input) { - return input == null ? null : NonTargetCatchComputedValueSource.valueOf(input.name()); - } - }; + protected static final Function<NonTargetCatchComputedValueSourcePersist, NonTargetCatchComputedValueSource> NON_TARGET_CATCH_COMPUTED_VALUE_SOURCE_TO_DTO = input -> input == null ? null : NonTargetCatchComputedValueSource.valueOf(input.name()); protected final Class<E> entityType; diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesExtractor.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesExtractor.java index 4f52c92..3627148 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesExtractor.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesExtractor.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.entity; * #L% */ -import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import fr.ird.observe.ObserveTopiaPersistenceContext; @@ -30,6 +29,7 @@ import fr.ird.observe.entities.ObserveEntity; import org.nuiton.topia.persistence.TopiaDao; import java.util.Map; +import java.util.Optional; /** * Cette classe permet d'extraire dynamiquement un ensemble d'entitiées de la base de données. @@ -52,16 +52,16 @@ public class EntitiesExtractor<E extends ObserveEntity> { public Iterable<E> getEntities(ObserveTopiaPersistenceContext persistenceContext, Map<String, Object> requestContext) { Iterable<E> result = getEntitiesSetBase(persistenceContext, requestContext); - Predicate<E> filter = getFilter(requestContext); + java.util.function.Predicate<E> filter = getFilter(requestContext); if (filter != null) { - result = Iterables.filter(result, filter); + result = Iterables.filter(result, filter::test); } return result; } protected EntitiesExtractor(Class<E> entityType, Predicate<E> optionalFilter) { this.entityType = entityType; - this.optionalFilter = Optional.fromNullable(optionalFilter); + this.optionalFilter = Optional.ofNullable(optionalFilter); } protected Iterable<E> getEntitiesSetBase(ObserveTopiaPersistenceContext persistenceContext, Map<String, Object> requestContext) { @@ -69,8 +69,8 @@ public class EntitiesExtractor<E extends ObserveEntity> { return dao.findAll(); } - protected Predicate<E> getFilter(Map<String, Object> requestContext) { - return optionalFilter.orNull(); + protected java.util.function.Predicate<E> getFilter(Map<String, Object> requestContext) { + return optionalFilter.orElse(null)::apply; } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesSetFactory.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesSetFactory.java index 0fed350..ba9adad 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesSetFactory.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/EntitiesSetFactory.java @@ -71,17 +71,17 @@ public class EntitiesSetFactory { TripSeine.class, TripSeine.PROPERTY_CAPTAIN, Person.class, - Persons.newCaptainPredicate()); + Persons.newCaptainPredicate()); registerReferentialEntitiesExtractor(builder, TripSeine.class, TripSeine.PROPERTY_OBSERVER, Person.class, - Persons.newObserverPredicate()); + Persons.newObserverPredicate()); registerReferentialEntitiesExtractor(builder, TripSeine.class, TripSeine.PROPERTY_DATA_ENTRY_OPERATOR, Person.class, - Persons.newDataEntryOperatorPredicate()); + Persons.newDataEntryOperatorPredicate()); registerReferentialEntitiesExtractor(builder, TripSeine.class, TripSeine.PROPERTY_VESSEL, @@ -93,17 +93,17 @@ public class EntitiesSetFactory { TripLongline.class, TripLongline.PROPERTY_CAPTAIN, Person.class, - Persons.newCaptainPredicate()); + Persons.newCaptainPredicate()); registerReferentialEntitiesExtractor(builder, TripLongline.class, TripLongline.PROPERTY_OBSERVER, Person.class, - Persons.newObserverPredicate()); + Persons.newObserverPredicate()); registerReferentialEntitiesExtractor(builder, TripLongline.class, TripLongline.PROPERTY_DATA_ENTRY_OPERATOR, Person.class, - Persons.newDataEntryOperatorPredicate()); + Persons.newDataEntryOperatorPredicate()); registerReferentialEntitiesExtractor(builder, TripLongline.class, TripLongline.PROPERTY_VESSEL, diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListEntitiesExtractor.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListEntitiesExtractor.java index 3355929..1983da3 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListEntitiesExtractor.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListEntitiesExtractor.java @@ -43,7 +43,7 @@ public class SpeciesListEntitiesExtractor extends EntitiesExtractor<Species> { protected final String speciesListId; public SpeciesListEntitiesExtractor(String speciesListId) { - super(Species.class, ObserveReferentialEntities.<Species>newEnablePredicate()); + super(Species.class, ObserveReferentialEntities.newEnablePredicate()); this.speciesListId = speciesListId; } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListOceanEntitiesExtractor.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListOceanEntitiesExtractor.java index 6a1209a..10309ab 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListOceanEntitiesExtractor.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/SpeciesListOceanEntitiesExtractor.java @@ -23,7 +23,6 @@ package fr.ird.observe.services.entity; */ import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import fr.ird.observe.entities.referentiel.Ocean; import fr.ird.observe.entities.referentiel.Species; import fr.ird.observe.entities.referentiel.Species2; @@ -42,16 +41,16 @@ public class SpeciesListOceanEntitiesExtractor extends SpeciesListEntitiesExtrac } @Override - protected Predicate<Species> getFilter(Map<String, Object> requestContext) { + protected java.util.function.Predicate<Species> getFilter(Map<String, Object> requestContext) { - Predicate<Species> filter = super.getFilter(requestContext); + java.util.function.Predicate<Species> filter = super.getFilter(requestContext); Ocean ocean = (Ocean) requestContext.get(Species.PROPERTY_OCEAN); if (ocean != null) { Predicate<Species> oceanFilter = Species2.newSpeciesByOceanPredicate(ocean); - filter = Predicates.and(filter, oceanFilter); + filter = filter.and(oceanFilter::apply); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java index 7a73c3c..8755efc 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/entity/TripMapDtoFactory.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.entity; * #L% */ -import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import fr.ird.observe.entities.TripMapPoint; @@ -32,6 +31,7 @@ import fr.ird.observe.services.dto.constants.TripMapPointType; import java.util.LinkedHashSet; import java.util.Set; +import java.util.function.Function; /** * Created on 09/01/16. @@ -43,20 +43,17 @@ public class TripMapDtoFactory { public static TripMapDto newTripMapDto(String tripId, Set<TripMapPoint> points) { TripMapDto tripMapDto = new TripMapDto(); tripMapDto.setId(tripId); - LinkedHashSet<TripMapPointDto> pointDtos = Sets.newLinkedHashSet(Iterables.transform(points, TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION)); + LinkedHashSet<TripMapPointDto> pointDtos = Sets.newLinkedHashSet(Iterables.transform(points, TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION::apply)); tripMapDto.setPoints(pointDtos); return tripMapDto; } - protected static final Function<TripMapPoint, TripMapPointDto> TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION = new Function<TripMapPoint, TripMapPointDto>() { - @Override - public TripMapPointDto apply(TripMapPoint tripMapPoint) { - TripMapPointDto result = new TripMapPointDto(); - result.setLatitude(tripMapPoint.getLatitude()); - result.setLongitude(tripMapPoint.getLongitude()); - result.setTime(tripMapPoint.getTime()); - result.setType(TripMapPointType.valueOf(tripMapPoint.getType().name())); - return result; - } + protected static final Function<TripMapPoint, TripMapPointDto> TRIP_MAP_POINT_TRIP_MAP_POINT_DTO_FUNCTION = tripMapPoint -> { + TripMapPointDto result = new TripMapPointDto(); + result.setLatitude(tripMapPoint.getLatitude()); + result.setLongitude(tripMapPoint.getLongitude()); + result.setTime(tripMapPoint.getTime()); + result.setType(TripMapPointType.valueOf(tripMapPoint.getType().name())); + return result; }; } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java index 0ab73f9..b29ff3c 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java @@ -23,7 +23,6 @@ package fr.ird.observe.services.service; */ import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -56,6 +55,7 @@ import org.nuiton.version.Version; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.util.Optional; import java.util.Set; import java.util.UUID; diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java index 1a4ec1a..a176caa 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java @@ -23,7 +23,6 @@ package fr.ird.observe.services.service; */ import com.google.common.base.Joiner; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -35,8 +34,8 @@ import fr.ird.observe.services.binder.BinderEngine; import fr.ird.observe.services.binder.referential.ReferentialBinderSupport; import fr.ird.observe.services.dto.DataDto; import fr.ird.observe.services.dto.DataReferenceSet; -import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.Form; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.reference.ReferenceSetDefinition; import fr.ird.observe.services.dto.reference.request.ReferenceSetRequestDefinition; @@ -55,6 +54,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Optional; /** * Created on 16/08/15. diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/SqlScriptProducerServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/SqlScriptProducerServiceTopia.java index fb5427c..e2c4cc9 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/SqlScriptProducerServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/SqlScriptProducerServiceTopia.java @@ -117,7 +117,7 @@ public class SqlScriptProducerServiceTopia extends ObserveServiceTopia implement { - Set<String> tripIds1 = Sets.newHashSet(Iterables.filter(tripIds, Entities.IS_SEINE_ID)); + Set<String> tripIds1 = Sets.newHashSet(Iterables.filter(tripIds, Entities.IS_SEINE_ID::test)); if (!tripIds1.isEmpty()) { @@ -132,7 +132,7 @@ public class SqlScriptProducerServiceTopia extends ObserveServiceTopia implement { - Set<String> tripIds1 = Sets.newHashSet(Iterables.filter(tripIds, Entities.IS_LONGLINE_ID)); + Set<String> tripIds1 = Sets.newHashSet(Iterables.filter(tripIds, Entities.IS_LONGLINE_ID::test)); if (!tripIds1.isEmpty()) { diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateActivitySeineDataResultBuilder.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateActivitySeineDataResultBuilder.java index 1868469..05244cb 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateActivitySeineDataResultBuilder.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateActivitySeineDataResultBuilder.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.service.actions.consolidate; * #L% */ -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import fr.ird.observe.entities.constants.seine.SchoolTypePersist; import fr.ird.observe.entities.referentiel.I18nReferenceEntities; @@ -42,6 +41,7 @@ import org.apache.commons.logging.LogFactory; import java.util.Date; import java.util.Locale; +import java.util.Optional; import static fr.ird.observe.services.service.actions.consolidate.ConsolidateActivitySeineDataResult.NonTargetCatchModification; import static fr.ird.observe.services.service.actions.consolidate.ConsolidateActivitySeineDataResult.NonTargetLengthModification; @@ -74,13 +74,13 @@ public class ConsolidateActivitySeineDataResultBuilder { protected String newSchoolType; - protected ImmutableSet.Builder<String> lengthWeightParameterNotFoundBuilder = new ImmutableSet.Builder<>(); + protected final ImmutableSet.Builder<String> lengthWeightParameterNotFoundBuilder = new ImmutableSet.Builder<>(); - protected ImmutableSet.Builder<TargetLengthModification> targetLengthModificationBuilder = new ImmutableSet.Builder<>(); + protected final ImmutableSet.Builder<TargetLengthModification> targetLengthModificationBuilder = new ImmutableSet.Builder<>(); - protected ImmutableSet.Builder<NonTargetLengthModification> nonTargetLengthModificationBuilder = new ImmutableSet.Builder<>(); + protected final ImmutableSet.Builder<NonTargetLengthModification> nonTargetLengthModificationBuilder = new ImmutableSet.Builder<>(); - protected ImmutableSet.Builder<NonTargetCatchModification> nonTargetCatchModificationBuilder = new ImmutableSet.Builder<>(); + protected final ImmutableSet.Builder<NonTargetCatchModification> nonTargetCatchModificationBuilder = new ImmutableSet.Builder<>(); public void flushTargetLengthModification(TargetLength targetLength, String... propertyNamesModified) { @@ -246,7 +246,7 @@ public class ConsolidateActivitySeineDataResultBuilder { } - return Optional.fromNullable(consolidateActivitySeineDataResult); + return Optional.ofNullable(consolidateActivitySeineDataResult); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateDataServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateDataServiceTopia.java index 443a4dd..4a361cb 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateDataServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/consolidate/ConsolidateDataServiceTopia.java @@ -22,7 +22,6 @@ package fr.ird.observe.services.service.actions.consolidate; * #L% */ -import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; import fr.ird.observe.ObserveTopiaDaoSupplier; import fr.ird.observe.ObserveTopiaPersistenceContext; @@ -58,6 +57,7 @@ import org.nuiton.util.beans.BeanMonitor; import java.util.Collection; import java.util.Date; import java.util.Locale; +import java.util.Optional; /** * Created on 28/08/15. @@ -270,7 +270,7 @@ public class ConsolidateDataServiceTopia extends ObserveServiceTopia implements log.info("Found some modifications on trip: " + consolidateTripSeineDataResult.getTripSeineLabel()); } } - return Optional.fromNullable(consolidateTripSeineDataResult); + return Optional.ofNullable(consolidateTripSeineDataResult); } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java index 224f461..9cf6e3e 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/report/ReportServiceTopia.java @@ -382,7 +382,7 @@ public class ReportServiceTopia extends ObserveServiceTopia implements ReportSer DataMatrix result = new DataMatrix(); - Map<String, Object> params = request.extractParams(report, tripId); + Map<String, Object> params = ReportRequest.extractParams(report, tripId); for (Object repeatValue : repeatValues.getValues()) { params.put(request.getRepeat().getVariableName(), repeatValue); @@ -423,7 +423,7 @@ public class ReportServiceTopia extends ObserveServiceTopia implements ReportSer } public DataMatrix executeReportRequest(ReportRequest request, Report report, String tripId) { - Map<String, Object> params = request.extractParams(report, tripId); + Map<String, Object> params = ReportRequest.extractParams(report, tripId); DataMatrix dataMatrix = executeReportRequest(request, params); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/synchro/UnidirectionalReferentialSynchronizeRemoteServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/synchro/UnidirectionalReferentialSynchronizeRemoteServiceTopia.java index d39d373..b3cc570 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/synchro/UnidirectionalReferentialSynchronizeRemoteServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/synchro/UnidirectionalReferentialSynchronizeRemoteServiceTopia.java @@ -36,7 +36,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaDao; -import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -92,9 +91,9 @@ public class UnidirectionalReferentialSynchronizeRemoteServiceTopia extends Obse ReferentialLocale referentialLocale = getReferentialLocale(); BinderEngine binderEngine = BinderEngine.get(); - Class<ReferentialDto> referentialDtoType = binderEngine.getReferentialDtoType(entityType); +// Class<ReferentialDto> referentialDtoType = binderEngine.getReferentialDtoType(entityType); Map<String, Long> localReferentialVersions = localReferentialStates.getReferentialVersions(entityName); - Collection<String> localReferentialDisabled = localReferentialStates.getReferentialDisabled(entityName); +// Collection<String> localReferentialDisabled = localReferentialStates.getReferentialDisabled(entityName); TopiaDao<E> dao = getTopiaPersistenceContext().getDao(entityType); for (E centralReferentialEntity : dao) { diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java index 74230e2..52bcc9f 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationMessageDetector.java @@ -21,7 +21,6 @@ */ package fr.ird.observe.services.service.actions.validate; -import com.google.common.base.Predicate; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; @@ -118,13 +117,7 @@ public class ValidationMessageDetector { } public <E extends TopiaEntity> Map<TopiaEntity, Collection<ValidationMessage>> getDetectedMessages(final Class<E> entityType) { - return Multimaps.filterEntries(detectedMessages, new Predicate<Map.Entry<TopiaEntity, ValidationMessage>>() { - - @Override - public boolean apply(Map.Entry<TopiaEntity, ValidationMessage> input) { - return entityType.isAssignableFrom(input.getKey().getClass()); - } - }).asMap(); + return Multimaps.filterEntries(detectedMessages, input -> entityType.isAssignableFrom(input.getKey().getClass())).asMap(); } public String translateMessage(String message) { diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java index 05a465e..fa454fa 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java @@ -281,6 +281,6 @@ public class ActivityLonglineServiceTopia extends ObserveServiceTopia implements protected int getActivityLonglinePositionInTripLongline(TripLongline tripLongline, ActivityLongline activityLongline) { return Iterables.size(Iterables.filter( tripLongline.getActivityLongline(), - ActivityLonglines.newTimeStampBeforePredicate(activityLongline.getTimeStamp()))); + ActivityLonglines.newTimeStampBeforePredicate(activityLongline.getTimeStamp())::apply)); } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java index 48cda67..7071335 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java @@ -281,6 +281,6 @@ public class ActivitySeineServiceTopia extends ObserveServiceTopia implements Ac protected int getActivitySeinePositionInRoute(Route route, ActivitySeine activitySeine) { return Iterables.size(Iterables.filter( route.getActivitySeine(), - ActivitySeines.newDateBeforePredicate(activitySeine.getTime()))); + ActivitySeines.newDateBeforePredicate(activitySeine.getTime())::apply)); } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java index 95c7558..2243a5f 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/RouteServiceTopia.java @@ -57,6 +57,7 @@ import java.util.Date; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com @@ -115,7 +116,7 @@ public class RouteServiceTopia extends ObserveServiceTopia implements RouteServi TopiaEntities.entityHasId(activitySeineDto.getId())); boolean isFindeVeille = activitySeine.getVesselActivitySeine() != null - && ActivitySeineImpl.ACTIVITY_FIN_DE_VEILLE.equals(activitySeine.getVesselActivitySeine().getCode()); + && ActivitySeineImpl.ACTIVITY_FIN_DE_VEILLE.equals(activitySeine.getVesselActivitySeine().getCode()); activitySeineDto.setActivityFinDeVeille(isFindeVeille); @@ -323,8 +324,9 @@ public class RouteServiceTopia extends ObserveServiceTopia implements RouteServi } protected int getRoutePositionInTripSeine(TripSeine tripSeine, Route route) { - return Iterables.size(Iterables.filter( - tripSeine.getRoute(), - Routes.newDateBeforePredicate(route.getDate()))); + return Iterables.size(tripSeine.getRoute() + .stream() + .filter(Routes.newDateBeforePredicate(route.getDate())::apply) + .collect(Collectors.toList())); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemetersTest.java b/observe-services-topia/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemetersTest.java index 701393e..4c963b8 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemetersTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/entities/referentiel/LengthWeightParemetersTest.java @@ -51,7 +51,7 @@ public class LengthWeightParemetersTest extends AbstractServiceTopiaTest { private ObserveTopiaPersistenceContext persistenceContext; @Before - public void setUp() throws Exception { + public void setUp() { persistenceContext = dataSourceResource.newPersistenceContext(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineMetadataTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineMetadataTest.java index 2efb0b3..6ec4f64 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineMetadataTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineMetadataTest.java @@ -51,7 +51,7 @@ public class BinderEngineMetadataTest { private BinderEngine binderEngine; @Before - public void setUp() throws Exception { + public void setUp() { binderEngine = BinderEngine.get(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineTest.java index 5fb10b0..dce0d53 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/binder/BinderEngineTest.java @@ -143,9 +143,6 @@ import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.dto.seine.TripSeineGearUseDto; import fr.ird.observe.services.service.AbstractServiceTopiaTest; -import fr.ird.observe.services.service.BabModelVersionException; -import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException; -import fr.ird.observe.services.service.DatabaseNotFoundException; import fr.ird.observe.test.DatabaseName; import fr.ird.observe.test.spi.DatabaseNameConfiguration; import org.apache.commons.logging.Log; @@ -171,7 +168,7 @@ public class BinderEngineTest extends AbstractServiceTopiaTest { private BinderEngine binderEngine; @Before - public void setUp() throws Exception { + public void setUp() { binderEngine = BinderEngine.get(); @@ -304,7 +301,7 @@ public class BinderEngineTest extends AbstractServiceTopiaTest { } - protected <D extends DataDto, E extends ObserveDataEntity> void transformDataEntityToDto(Class<D> dtoType) throws DatabaseNotFoundException, BabModelVersionException, DatabaseConnexionNotAuthorizedException { + protected <D extends DataDto, E extends ObserveDataEntity> void transformDataEntityToDto(Class<D> dtoType) { Class<E> entityType = binderEngine.getDataEntityType(dtoType); @@ -340,7 +337,7 @@ public class BinderEngineTest extends AbstractServiceTopiaTest { } - protected <D extends ReferentialDto, E extends ObserveReferentialEntity> void transformReferentialEntityToDto(Class<D> dtoType) throws DatabaseNotFoundException, BabModelVersionException, DatabaseConnexionNotAuthorizedException { + protected <D extends ReferentialDto, E extends ObserveReferentialEntity> void transformReferentialEntityToDto(Class<D> dtoType) { Class<E> entityType = binderEngine.getReferentialEntityType(dtoType); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java index bb6690e..f5d5614 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java @@ -64,7 +64,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { protected DataSourceService service; @Before - public void setUp() throws Exception { + public void setUp() { ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = dataSourceResource.getDataSourceConfiguration(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/MigrateTestsDatabases.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/MigrateTestsDatabases.java index 8efa1a9..3567ade 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/MigrateTestsDatabases.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/MigrateTestsDatabases.java @@ -107,7 +107,7 @@ public class MigrateTestsDatabases extends AbstractServiceTopiaTest { migrate(dataSourceResource.getDbName(), dump); } - protected void migrate(String dbName, byte[] dump) throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, DatabaseNotFoundException, BabModelVersionException, DatabaseConnexionNotAuthorizedException { + protected void migrate(String dbName, byte[] dump) throws IOException { File databasesRootDirectory = dataSourceResource.getDataSourceConfiguration().getDatabaseFile(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java index d9551b4..b66857b 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java @@ -104,9 +104,6 @@ public abstract class AbstractReportServiceTopiaTest extends AbstractServiceTopi // creation de l'executeur de report report = service.populateVariables(report, ObserveFixtures.TRIP_SEINE_ID_1); - // les variables a utiliser (par defaut, pas de variable) - Map<String, Object> variables = new HashMap<>(); - // preparation des variables prepareVariables(); @@ -132,7 +129,7 @@ public abstract class AbstractReportServiceTopiaTest extends AbstractServiceTopi if (variableName.equals(variable.getName())) { - Object value = Iterables.find(variable.getValues(), AbstractReference.newIdPredicate(id)); + Object value = Iterables.find(variable.getValues(), AbstractReference.newIdPredicate(id)::apply); variable.setSelectedValue(value); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatch2Test.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatch2Test.java index 31c48b8..2392f42 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatch2Test.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatch2Test.java @@ -193,7 +193,7 @@ public class ReportAccessoryCatch2Test extends ReportAccessoryCatchTest { assertResultRow(result, row++, "[FAO]XXX* [sc] [fr]", "-", "-"); assertResultRow(result, row++, "[FAO]YMO [sc]Sthenoteuthis oualaniensis [fr]Encornet bande violette", "-", "-"); assertResultRow(result, row++, "[FAO]YTC [sc]Seriola lalandi [fr]Sériole chicard", "-", "-"); - assertResultRow(result, row++, "[FAO]ZAO [sc]Zanclus cornutus [fr]Zanclus cornutus", "-", "-"); + assertResultRow(result, row, "[FAO]ZAO [sc]Zanclus cornutus [fr]Zanclus cornutus", "-", "-"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroup2Test.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroup2Test.java index a0a5a4e..9f29500 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroup2Test.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroup2Test.java @@ -62,7 +62,7 @@ public class ReportAccessoryCatchByGroup2Test extends ReportAccessoryCatchByGrou assertResultRow(result, row++, "[FAO]REO [sc]Remora remora [fr]Rémora", "2", "0", "0", "0", "2", "0", "0", "0", "0", "0.0"); assertResultRow(result, row++, "[FAO]GBA [sc]Sphyraena barracuda [fr]Barracuda", "0", "26", "0", "0", "3", "23", "0", "0", "0", "0.0"); assertResultRow(result, row++, "[FAO]BTS [sc]Tylosurus crocodilus [fr]Aiguille crocodile ", "0", "1", "0", "0", "1", "0", "0", "0", "0", "0.0"); - assertResultRow(result, row++, "[FAO]WAH [sc]Acanthocybium solandri [fr]Thazard bâtard", "0", "90", "0", "0", "3", "85", "0", "0", "2", "0.0"); + assertResultRow(result, row, "[FAO]WAH [sc]Acanthocybium solandri [fr]Thazard bâtard", "0", "90", "0", "0", "3", "85", "0", "0", "2", "0.0"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroupTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroupTest.java index 809ddfa..1383718 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroupTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchByGroupTest.java @@ -93,6 +93,6 @@ public class ReportAccessoryCatchByGroupTest extends AbstractReportServiceTopiaT assertResultRow(result, row++, "[FAO]RSK [sc]Carcharhinidae spp [fr]Famille Carcharhinidae", "0", "11", "0", "0", "5", "6", "0", "0", "0", "0.0"); assertResultRow(result, row++, "[FAO]STT [sc]Dasyatidae [fr]Famille Dasyatidae", "7", "0", "0", "0", "6", "0", "0", "0", "0", "1.0"); assertResultRow(result, row++, "[FAO]SPY [sc]Sphyrnidae [fr]Famille Sphyrnidae", "0", "1", "0", "0", "1", "0", "0", "0", "0", "0.0"); - assertResultRow(result, row++, "[FAO]RMB [sc]Manta birostris [fr]Mante atlantique", "9", "0", "0", "0", "9", "0", "0", "0", "0", "0.0"); + assertResultRow(result, row, "[FAO]RMB [sc]Manta birostris [fr]Mante atlantique", "9", "0", "0", "0", "9", "0", "0", "0", "0", "0.0"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchTest.java index 2e93314..7fdd627 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAccessoryCatchTest.java @@ -147,7 +147,7 @@ public class ReportAccessoryCatchTest extends AbstractReportServiceTopiaTest { assertResultRow(result, row++, "[FAO]SPL [sc]Sphyrna lewini [fr]Requin marteau halicorne", "-", "-"); assertResultRow(result, row++, "[FAO]SPK [sc]Sphyrna mokarran [fr]Grand requin marteau", "-", "-"); assertResultRow(result, row++, "[FAO]SPZ [sc]Sphyrna zygaena [fr]Requin marteau commun", "-", "-"); - assertResultRow(result, row++, "[FAO]TOD [sc]Torpedinidae [fr]Torpilles, raies électriq. nca ", "-", "-"); + assertResultRow(result, row, "[FAO]TOD [sc]Torpedinidae [fr]Torpilles, raies électriq. nca ", "-", "-"); } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportActivityWithCommentTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportActivityWithCommentTest.java index 37919e1..85df1b6 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportActivityWithCommentTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportActivityWithCommentTest.java @@ -342,6 +342,6 @@ public class ReportActivityWithCommentTest extends AbstractReportServiceTopiaTes assertResultRow(result, row++, "26/2/2013 13:7", "-4.6668053", "53.58347", "Recherche (général)", "Shiftage du 25.02.2013 de 13h à 16h35"); assertResultRow(result, row++, "26/2/2013 18:22", "-5.3168054", "54.566803", "Fin de veille", "Stopper pour la nuit."); assertResultRow(result, row++, "27/2/2013 15:36", "-4.5834723", "55.48347", "Autres (à préciser dans les notes)", "En attente pour rentrer au port avec le pilote"); - assertResultRow(result, row++, "27/2/2013 16:22", "-4.6168056", "55.450138", "Au port", "Fin de la première partie de calée.Loch totale marée: 5953.03"); + assertResultRow(result, row, "27/2/2013 16:22", "-4.6168056", "55.450138", "Au port", "Fin de la première partie de calée.Loch totale marée: 5953.03"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAllActivitysTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAllActivitysTest.java index fd39969..68b8a0b 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAllActivitysTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportAllActivitysTest.java @@ -935,7 +935,7 @@ public class ReportAllActivitysTest extends AbstractReportServiceTopiaTest { assertResultRow(result, row++, "27/2/2013 13:25", "-4.7001386", "55.600136", "Transit (route sans recherche)", null); assertResultRow(result, row++, "27/2/2013 14:25", "-4.5834723", "55.58347", "Transit (route sans recherche)", null); assertResultRow(result, row++, "27/2/2013 15:36", "-4.5834723", "55.48347", "Autres (à préciser dans les notes)", "En attente pour rentrer au port avec le pilote"); - assertResultRow(result, row++, "27/2/2013 16:22", "-4.6168056", "55.450138", "Au port", "Fin de la première partie de calée.Loch totale marée: 5953.03"); + assertResultRow(result, row, "27/2/2013 16:22", "-4.6168056", "55.450138", "Au port", "Fin de la première partie de calée.Loch totale marée: 5953.03"); } } \ No newline at end of file diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDailySetAndCatchTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDailySetAndCatchTest.java index 51f1453..9b3d04f 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDailySetAndCatchTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDailySetAndCatchTest.java @@ -96,7 +96,7 @@ public class ReportDailySetAndCatchTest extends AbstractReportServiceTopiaTest { assertResultRow(result, row++, "23/2/2013", "3", "197.44"); assertResultRow(result, row++, "24/2/2013", "1", "12.0"); assertResultRow(result, row++, "25/2/2013", "1", "48.075"); - assertResultRow(result, row++, "26/2/2013", "1", "13.7"); + assertResultRow(result, row, "26/2/2013", "1", "13.7"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDcpUsageTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDcpUsageTest.java index b457533..ba49f0a 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDcpUsageTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportDcpUsageTest.java @@ -135,7 +135,7 @@ public class ReportDcpUsageTest extends AbstractReportServiceTopiaTest { assertResultRow(result, row++, "16 - Radeau ou bouée en dérive", "2", "0", "0", "0", "0", null); assertResultRow(result, row++, "3 - Arbre (ou branche)", "3", "0", "0", "0", "0", null); assertResultRow(result, row++, "6 - Radeau balisé en dérive (bambou et filet)", "19", "6", "13", "0", "0", null); - assertResultRow(result, row++, "99 - Autre (à préciser dans les notes)", "2", "0", "0", "0", "0", null); + assertResultRow(result, row, "99 - Autre (à préciser dans les notes)", "2", "0", "0", "0", "0", null); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportSetByAssociationTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportSetByAssociationTest.java index 2daa3da..7676b5d 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportSetByAssociationTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportSetByAssociationTest.java @@ -121,7 +121,7 @@ public class ReportSetByAssociationTest extends AbstractReportServiceTopiaTest { int row = 0; assertResultRow(result, row++, "19" ,"1" ,"0" ,"6" ,"26"); assertResultRow(result, row++, "9", "0", "0", "0", "9"); - assertResultRow(result, row++, "28" ,"1" ,"0" ,"6" ,"35"); + assertResultRow(result, row, "28" ,"1" ,"0" ,"6" ,"35"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetCatchByAssociationTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetCatchByAssociationTest.java index d630fca..bef0baa 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetCatchByAssociationTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetCatchByAssociationTest.java @@ -108,7 +108,7 @@ public class ReportTargetCatchByAssociationTest extends AbstractReportServiceTop assertResultRow(result, row++, "26.0", "0.0", "0.0", "0.0", "0.0", "0.0", "26.0"); assertResultRow(result, row++, null, null, null, null, null, null, "0.0"); assertResultRow(result, row++, "32.0", "71.0", "10.0", "0.0", "0.0", "0.0", "113.0"); - assertResultRow(result, row++, "513.2", "71.0", "50.0", "0.0", "0.0", "2.2", "636.4"); + assertResultRow(result, row, "513.2", "71.0", "50.0", "0.0", "0.0", "2.2", "636.4"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetDiscardedByAssociationTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetDiscardedByAssociationTest.java index 006c906..d1ea99b 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetDiscardedByAssociationTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/ReportTargetDiscardedByAssociationTest.java @@ -108,7 +108,7 @@ public class ReportTargetDiscardedByAssociationTest extends AbstractReportServic assertResultRow(result, row++, null, null, null, null, null, null, "0.0"); assertResultRow(result, row++, null, null, null, null, null, null, "0.0"); assertResultRow(result, row++, "2.775", "5.405", "0.0", "0.0", "0.0", "0.1", "8.28"); - assertResultRow(result, row++, "3.6159999999999997", "5.405", "0.29", "0.0", "0.08", "0.11", "9.501"); + assertResultRow(result, row, "3.6159999999999997", "5.405", "0.29", "0.0", "0.08", "0.11", "9.501"); } } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java index 713e9bd..f5a411d 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/validate/ValidateServiceTopiaTest.java @@ -26,7 +26,73 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.dto.IdDto; +import fr.ird.observe.services.dto.referential.CountryDto; +import fr.ird.observe.services.dto.referential.FpaZoneDto; +import fr.ird.observe.services.dto.referential.GearCaracteristicDto; +import fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto; +import fr.ird.observe.services.dto.referential.GearDto; +import fr.ird.observe.services.dto.referential.HarbourDto; +import fr.ird.observe.services.dto.referential.LengthWeightParameterDto; +import fr.ird.observe.services.dto.referential.OceanDto; +import fr.ird.observe.services.dto.referential.OrganismDto; +import fr.ird.observe.services.dto.referential.PersonDto; +import fr.ird.observe.services.dto.referential.ProgramDto; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.referential.SexDto; +import fr.ird.observe.services.dto.referential.SpeciesDto; +import fr.ird.observe.services.dto.referential.SpeciesGroupDto; +import fr.ird.observe.services.dto.referential.SpeciesListDto; +import fr.ird.observe.services.dto.referential.VesselDto; +import fr.ird.observe.services.dto.referential.VesselSizeCategoryDto; +import fr.ird.observe.services.dto.referential.VesselTypeDto; +import fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto; +import fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto; +import fr.ird.observe.services.dto.referential.longline.BaitTypeDto; +import fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto; +import fr.ird.observe.services.dto.referential.longline.EncounterTypeDto; +import fr.ird.observe.services.dto.referential.longline.HealthnessDto; +import fr.ird.observe.services.dto.referential.longline.HookPositionDto; +import fr.ird.observe.services.dto.referential.longline.HookSizeDto; +import fr.ird.observe.services.dto.referential.longline.HookTypeDto; +import fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto; +import fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto; +import fr.ird.observe.services.dto.referential.longline.LightsticksColorDto; +import fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto; +import fr.ird.observe.services.dto.referential.longline.LineTypeDto; +import fr.ird.observe.services.dto.referential.longline.MaturityStatusDto; +import fr.ird.observe.services.dto.referential.longline.MitigationTypeDto; +import fr.ird.observe.services.dto.referential.longline.SensorBrandDto; +import fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto; +import fr.ird.observe.services.dto.referential.longline.SensorTypeDto; +import fr.ird.observe.services.dto.referential.longline.SettingShapeDto; +import fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto; +import fr.ird.observe.services.dto.referential.longline.StomacFullnessDto; +import fr.ird.observe.services.dto.referential.longline.TripTypeDto; +import fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto; +import fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto; +import fr.ird.observe.services.dto.referential.seine.DetectionModeDto; +import fr.ird.observe.services.dto.referential.seine.ObjectFateDto; +import fr.ird.observe.services.dto.referential.seine.ObjectOperationDto; +import fr.ird.observe.services.dto.referential.seine.ObjectTypeDto; +import fr.ird.observe.services.dto.referential.seine.ObservedSystemDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto; +import fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto; +import fr.ird.observe.services.dto.referential.seine.SpeciesFateDto; +import fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto; +import fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto; +import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto; +import fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto; +import fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto; +import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; +import fr.ird.observe.services.dto.referential.seine.WindDto; +import fr.ird.observe.services.dto.seine.ActivitySeineDto; +import fr.ird.observe.services.dto.seine.FloatingObjectDto; +import fr.ird.observe.services.dto.seine.NonTargetCatchDto; +import fr.ird.observe.services.dto.seine.RouteDto; +import fr.ird.observe.services.dto.seine.SetSeineDto; +import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; +import fr.ird.observe.services.dto.seine.TripSeineDto; import fr.ird.observe.services.service.AbstractServiceTopiaTest; import fr.ird.observe.test.DatabaseName; import fr.ird.observe.test.ObserveFixtures; @@ -68,67 +134,67 @@ public class ValidateServiceTopiaTest extends AbstractServiceTopiaTest { // System.out.println("assertValidateResultForReferentialDtoType(resultByType, " + entry.getKey().getName() + ".class, " + entry.getValue().getValidationResultForDto().size() + ");"); // } - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.CountryDto.class, 53); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.FpaZoneDto.class, 41); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearCaracteristicDto.class, 22); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearCaracteristicTypeDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.GearDto.class, 26); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.HarbourDto.class, 74); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.LengthWeightParameterDto.class, 352); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.OceanDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.OrganismDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.PersonDto.class, 390); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.ProgramDto.class, 27); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SexDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesDto.class, 275); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesGroupDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.SpeciesListDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselDto.class, 977); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselSizeCategoryDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.VesselTypeDto.class, 14); - - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitHaulingStatusDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitSettingStatusDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.BaitTypeDto.class, 16); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.CatchFateLonglineDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.EncounterTypeDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HealthnessDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookPositionDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookSizeDto.class, 22); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.HookTypeDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.ItemHorizontalPositionDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.ItemVerticalPositionDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LightsticksColorDto.class, 7); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LightsticksTypeDto.class, 2); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.LineTypeDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.MaturityStatusDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.MitigationTypeDto.class, 15); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorBrandDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorDataFormatDto.class, 2); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SensorTypeDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SettingShapeDto.class, 6); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.SizeMeasureTypeDto.class, 17); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.StomacFullnessDto.class, 7); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.TripTypeDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.VesselActivityLonglineDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.longline.WeightMeasureTypeDto.class, 3); - - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.DetectionModeDto.class, 10); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectFateDto.class, 9); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectOperationDto.class, 4); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObjectTypeDto.class, 23); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ObservedSystemDto.class, 21); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto.class, 5); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForNoFishingDto.class, 13); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.ReasonForNullSetDto.class, 10); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SpeciesFateDto.class, 9); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SpeciesStatusDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.SurroundingActivityDto.class, 8); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.TransmittingBuoyOperationDto.class, 3); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.TransmittingBuoyTypeDto.class, 12); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.VesselActivitySeineDto.class, 23); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.WeightCategoryDto.class, 101); - assertValidateResultForReferentialDtoType(resultByType, fr.ird.observe.services.dto.referential.seine.WindDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, CountryDto.class, 53); + assertValidateResultForReferentialDtoType(resultByType, FpaZoneDto.class, 41); + assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicDto.class, 22); + assertValidateResultForReferentialDtoType(resultByType, GearCaracteristicTypeDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, GearDto.class, 26); + assertValidateResultForReferentialDtoType(resultByType, HarbourDto.class, 74); + assertValidateResultForReferentialDtoType(resultByType, LengthWeightParameterDto.class, 352); + assertValidateResultForReferentialDtoType(resultByType, OceanDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, OrganismDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, PersonDto.class, 390); + assertValidateResultForReferentialDtoType(resultByType, ProgramDto.class, 27); + assertValidateResultForReferentialDtoType(resultByType, SexDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, SpeciesDto.class, 275); + assertValidateResultForReferentialDtoType(resultByType, SpeciesGroupDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, SpeciesListDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, VesselDto.class, 977); + assertValidateResultForReferentialDtoType(resultByType, VesselSizeCategoryDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, VesselTypeDto.class, 14); + + assertValidateResultForReferentialDtoType(resultByType, BaitHaulingStatusDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, BaitSettingStatusDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, BaitTypeDto.class, 16); + assertValidateResultForReferentialDtoType(resultByType, CatchFateLonglineDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, EncounterTypeDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, HealthnessDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, HookPositionDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, HookSizeDto.class, 22); + assertValidateResultForReferentialDtoType(resultByType, HookTypeDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, ItemHorizontalPositionDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, ItemVerticalPositionDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, LightsticksColorDto.class, 7); + assertValidateResultForReferentialDtoType(resultByType, LightsticksTypeDto.class, 2); + assertValidateResultForReferentialDtoType(resultByType, LineTypeDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, MaturityStatusDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, MitigationTypeDto.class, 15); + assertValidateResultForReferentialDtoType(resultByType, SensorBrandDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, SensorDataFormatDto.class, 2); + assertValidateResultForReferentialDtoType(resultByType, SensorTypeDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, SettingShapeDto.class, 6); + assertValidateResultForReferentialDtoType(resultByType, SizeMeasureTypeDto.class, 17); + assertValidateResultForReferentialDtoType(resultByType, StomacFullnessDto.class, 7); + assertValidateResultForReferentialDtoType(resultByType, TripTypeDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, VesselActivityLonglineDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, WeightMeasureTypeDto.class, 3); + + assertValidateResultForReferentialDtoType(resultByType, DetectionModeDto.class, 10); + assertValidateResultForReferentialDtoType(resultByType, ObjectFateDto.class, 9); + assertValidateResultForReferentialDtoType(resultByType, ObjectOperationDto.class, 4); + assertValidateResultForReferentialDtoType(resultByType, ObjectTypeDto.class, 23); + assertValidateResultForReferentialDtoType(resultByType, ObservedSystemDto.class, 21); + assertValidateResultForReferentialDtoType(resultByType, ReasonForDiscardDto.class, 5); + assertValidateResultForReferentialDtoType(resultByType, ReasonForNoFishingDto.class, 13); + assertValidateResultForReferentialDtoType(resultByType, ReasonForNullSetDto.class, 10); + assertValidateResultForReferentialDtoType(resultByType, SpeciesFateDto.class, 9); + assertValidateResultForReferentialDtoType(resultByType, SpeciesStatusDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, SurroundingActivityDto.class, 8); + assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyOperationDto.class, 3); + assertValidateResultForReferentialDtoType(resultByType, TransmittingBuoyTypeDto.class, 12); + assertValidateResultForReferentialDtoType(resultByType, VesselActivitySeineDto.class, 23); + assertValidateResultForReferentialDtoType(resultByType, WeightCategoryDto.class, 101); + assertValidateResultForReferentialDtoType(resultByType, WindDto.class, 13); } @@ -152,13 +218,13 @@ public class ValidateServiceTopiaTest extends AbstractServiceTopiaTest { // System.out.println("assertValidateResultForDtoType(resultByType, " + entry.getKey().getName() + ".class, " + entry.getValue().getValidationResultForDto().size() + ");"); // } - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TripSeineDto.class, 2); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.RouteDto.class, 80); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.ActivitySeineDto.class, 1519); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.FloatingObjectDto.class, 99); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.TransmittingBuoyDto.class, 42); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.SetSeineDto.class, 77); - assertValidateResultForDtoType(resultByType, fr.ird.observe.services.dto.seine.NonTargetCatchDto.class, 3); + assertValidateResultForDtoType(resultByType, TripSeineDto.class, 2); + assertValidateResultForDtoType(resultByType, RouteDto.class, 80); + assertValidateResultForDtoType(resultByType, ActivitySeineDto.class, 1519); + assertValidateResultForDtoType(resultByType, FloatingObjectDto.class, 99); + assertValidateResultForDtoType(resultByType, TransmittingBuoyDto.class, 42); + assertValidateResultForDtoType(resultByType, SetSeineDto.class, 77); + assertValidateResultForDtoType(resultByType, NonTargetCatchDto.class, 3); } diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractSqlAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractSqlAction.java index 4cbc38b..f708367 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractSqlAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractSqlAction.java @@ -73,23 +73,17 @@ public abstract class AbstractSqlAction<R extends AbstractSqlRequest> implements this.request = request; ImmutableSet.Builder<Closeable> closeableBuilder = ImmutableSet.builder(); - closeableBuilder.add(new Closeable() { - @Override - public void close() throws IOException { - if (sourcePersistenceContext != null) { - sourcePersistenceContext.close(); - } + closeableBuilder.add(() -> { + if (sourcePersistenceContext != null) { + sourcePersistenceContext.close(); } }); - closeableBuilder.add(new Closeable() { - @Override - public void close() throws IOException { - if (targetConnection != null) { - try { - targetConnection.close(); - } catch (SQLException e) { - throw new TopiaException("Could not close targetConnection", e); - } + closeableBuilder.add(() -> { + if (targetConnection != null) { + try { + targetConnection.close(); + } catch (SQLException e) { + throw new TopiaException("Could not close targetConnection", e); } } }); @@ -194,7 +188,7 @@ public abstract class AbstractSqlAction<R extends AbstractSqlRequest> implements } - protected final void after() throws SQLException { + protected final void after() { endTime = TIME_LOG.log(startTime, "Action executed", getClass().getName()); diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractTablesAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractTablesAction.java index e81aa30..0851106 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractTablesAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/AbstractTablesAction.java @@ -119,7 +119,7 @@ public abstract class AbstractTablesAction<R extends AbstractTablesRequest> exte } - protected String generateWildcardArguments(Iterable<String> columnNames) throws SQLException { + protected String generateWildcardArguments(Iterable<String> columnNames) { StringBuilder argsBuilder = new StringBuilder(); diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java index f4b66de..bec2b89 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/DeleteTablesAction.java @@ -123,11 +123,9 @@ public class DeleteTablesAction extends AbstractTablesAction<DeleteTablesRequest } - protected String newDeleteStatementSql(TopiaSqlTable table) throws SQLException { + protected String newDeleteStatementSql(TopiaSqlTable table) { - String sql = String.format(DELETE_STATEMENT, - table.getSchemaName(), - table.getTableName()); + String sql = String.format(DELETE_STATEMENT, table.getSchemaName(), table.getTableName()); if (log.isDebugEnabled()) { log.debug("Delete sql: " + sql); } diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/ReplicateTablesAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/ReplicateTablesAction.java index 8a623e0..792d5e9 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/ReplicateTablesAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/ReplicateTablesAction.java @@ -121,7 +121,7 @@ public class ReplicateTablesAction extends AbstractTablesAction<ReplicateTablesR } - protected String newInsertStatementSql(TopiaSqlTable table, List<String> columnNames) throws SQLException { + protected String newInsertStatementSql(TopiaSqlTable table, List<String> columnNames) { StringBuilder columnNamesBuilder = new StringBuilder(); diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/UpdateTablesAction.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/UpdateTablesAction.java index 0dde854..2b48710 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/UpdateTablesAction.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/actions/UpdateTablesAction.java @@ -177,7 +177,7 @@ public class UpdateTablesAction extends AbstractTablesAction<UpdateTablesRequest } - protected String newUpdateStatementSql(TopiaSqlTable table, Iterable<String> columnNames) throws SQLException { + protected String newUpdateStatementSql(TopiaSqlTable table, Iterable<String> columnNames) { StringBuilder columnNamesBuilder = new StringBuilder(); diff --git a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/tables/TopiaSqlTables.java b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/tables/TopiaSqlTables.java index a5f0cca..1b02f23 100644 --- a/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/tables/TopiaSqlTables.java +++ b/observe-topia-extension/src/main/java/org/nuiton/topia/service/sql/batch/tables/TopiaSqlTables.java @@ -144,7 +144,7 @@ public class TopiaSqlTables implements Iterable<TopiaSqlTable> { tableName, whereClauseAlias, fromClause, - ImmutableSet.<String>of()); + ImmutableSet.of()); return new BuilderStepOnTableImpl(null, entityEnum); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit b3c43334618e8226ab22502d9560f734d80db396 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 14:23:23 2016 +0200 fix test build --- .../service/actions/report/AbstractReportServiceTopiaTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java index b66857b..2194cc4 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/actions/report/AbstractReportServiceTopiaTest.java @@ -40,9 +40,7 @@ import org.junit.Test; import java.io.IOException; import java.net.URL; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * Classe abstraite de test d'un report. @@ -129,7 +127,7 @@ public abstract class AbstractReportServiceTopiaTest extends AbstractServiceTopi if (variableName.equals(variable.getName())) { - Object value = Iterables.find(variable.getValues(), AbstractReference.newIdPredicate(id)::apply); + Object value = Iterables.find(variable.getValues(), AbstractReference.newIdPredicate(id)); variable.setSelectedValue(value); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit c36671cd436724e2ab007ae34613c97a45a13658 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 15:33:26 2016 +0200 Introduction nouveau module pour les migrations --- observe-entities-migration/LICENSE.txt | 674 +++++++++++++++++++++ observe-entities-migration/README.md | 0 observe-entities-migration/pom.xml | 115 ++++ .../src/license/THIRD-PARTY.properties | 33 + .../DataSourceMigrationForVersion_3_1.java | 5 +- .../DataSourceMigrationForVersion_3_10.java | 8 +- .../DataSourceMigrationForVersion_3_11.java | 8 +- .../DataSourceMigrationForVersion_3_12.java | 8 +- .../DataSourceMigrationForVersion_3_14.java | 8 +- .../DataSourceMigrationForVersion_3_15.java | 8 +- .../DataSourceMigrationForVersion_3_16.java | 8 +- .../DataSourceMigrationForVersion_3_5.java | 8 +- .../DataSourceMigrationForVersion_3_7.java | 8 +- .../DataSourceMigrationForVersion_3_8.java | 8 +- .../DataSourceMigrationForVersion_3_9.java | 8 +- .../DataSourceMigrationForVersion_4_0.java | 8 +- .../DataSourceMigrationForVersion_4_0_1.java | 8 +- .../DataSourceMigrationForVersion_4_0_2.java | 8 +- .../DataSourceMigrationForVersion_4_0_4.java | 8 +- .../DataSourceMigrationForVersion_4_0_RC2.java | 8 +- .../DataSourceMigrationForVersion_4_0_RC3.java | 8 +- .../DataSourceMigrationForVersion_4_0_RC4.java | 8 +- .../DataSourceMigrationForVersion_4_0_RC6.java | 8 +- .../DataSourceMigrationForVersion_4_0_RC7.java | 8 +- .../DataSourceMigrationForVersion_4_900.java | 8 +- .../DataSourceMigrationForVersion_4_901.java | 8 +- .../DataSourceMigrationForVersion_4_902.java | 8 +- .../DataSourceMigrationForVersion_4_903.java | 8 +- .../DataSourceMigrationForVersion_4_904.java | 8 +- .../DataSourceMigrationForVersion_5_0.java | 8 +- .../main/java/fr/ird/type/CoordinateHelper.java | 55 ++ .../src/main/resources/db/3.5/constrainsts.csv | 0 .../resources/db/3.5/traduction_attributes.csv | 0 .../main/resources/db/3.5/traduction_tables.csv | 0 .../main/resources/db/3.5/traduction_tables2.csv | 0 .../db/migration/V3_10_01_remove-person-H2.sql | 0 .../db/migration/V3_10_01_remove-person-PG.sql | 0 .../db/migration/V3_10_02_add-missing-fk-H2.sql | 0 .../db/migration/V3_10_02_add-missing-fk-PG.sql | 0 .../V3_10_03_increase-comment-field-H2.sql | 0 .../V3_10_03_increase-comment-field-PG.sql | 0 .../migration/V3_10_04_fix-sensorDataFormat-H2.sql | 0 .../migration/V3_10_04_fix-sensorDataFormat-PG.sql | 0 .../migration/V3_10_05_normalize-sections-H2.sql | 0 .../migration/V3_10_05_normalize-sections-PG.sql | 0 ...1_01_remove-speciesGroup-obsolete-fields-H2.sql | 0 ...1_01_remove-speciesGroup-obsolete-fields-PG.sql | 0 ...3_11_02_add-country-on-transmitting-buoy-H2.sql | 0 ...3_11_02_add-country-on-transmitting-buoy-PG.sql | 0 .../db/migration/V3_11_03_add-fpaZones-H2.sql | 0 .../db/migration/V3_11_03_add-fpaZones-PG.sql | 0 .../migration/V3_11_04_add-activity-ersId-H2.sql | 0 .../migration/V3_11_04_add-activity-ersId-PG.sql | 0 .../migration/V3_11_05_add-person-country-H2.sql | 0 .../migration/V3_11_05_add-person-country-PG.sql | 0 .../db/migration/V3_11_06_add-harbours-H2.sql | 0 .../db/migration/V3_11_06_add-harbours-PG.sql | 0 .../db/migration/V3_12_01_add-missing-boat-H2.sql | 0 .../db/migration/V3_12_01_add-missing-boat-PG.sql | 0 ...3_14_01_remove-hooksPerBasketCount-field-H2.sql | 0 ...3_14_01_remove-hooksPerBasketCount-field-PG.sql | 0 ...3_14_02_fix-targetsample-discarded-value-H2.sql | 0 ...3_14_02_fix-targetsample-discarded-value-PG.sql | 0 .../V3_14_03_remove-orphan-seine-sample-H2.sql | 0 .../V3_14_03_remove-orphan-seine-sample-PG.sql | 0 ...4_04_remove-targetlength-discarded-field-H2.sql | 0 ...4_04_remove-targetlength-discarded-field-PG.sql | 0 ..._15_01_change-tdr-integer-field-to-float-H2.sql | 0 ..._15_01_change-tdr-integer-field-to-float-PG.sql | 0 ..._15_02_remove-set-longline-length-fields-H2.sql | 0 ..._15_02_remove-set-longline-length-fields-PG.sql | 0 .../V3_15_03_remove-brancheline-fields-H2.sql | 0 .../V3_15_03_remove-brancheline-fields-PG.sql | 0 .../migration/V3_16_01_add-gear-referential-H2.sql | 0 .../migration/V3_16_01_add-gear-referential-PG.sql | 0 .../db/migration/V3_16_02_add-gear-data-H2.sql | 0 .../db/migration/V3_16_02_add-gear-data-PG.sql | 0 .../V3_16_03_remove-tripSeine-seine-H2.sql | 0 .../V3_16_03_remove-tripSeine-seine-PG.sql | 0 .../db/migration/V3_5_01_migration-H2.sql | 0 .../db/migration/V3_5_01_migration-PG.sql | 0 .../migration/V3_5_02_add-longline-schema-H2.sql | 0 .../migration/V3_5_02_add-longline-schema-PG.sql | 0 .../V3_5_03_update-common-references-H2.sql | 0 .../V3_5_03_update-common-references-PG.sql | 0 .../V3_5_04_add-longline-references-H2.sql | 0 .../V3_5_04_add-longline-references-PG.sql | 0 .../db/migration/V3_7_01_rename-seine-model-H2.sql | 0 .../db/migration/V3_7_01_rename-seine-model-PG.sql | 0 .../migration/V3_7_02_remove-trip-organism-H2.sql | 0 .../migration/V3_7_02_remove-trip-organism-PG.sql | 0 .../V3_7_03_add-referential-needComment-H2.sql | 0 .../V3_7_03_add-referential-needComment-PG.sql | 0 .../V3_7_04_normalize-triplongline-H2.sql | 0 .../V3_7_04_normalize-triplongline-PG.sql | 0 .../V3_7_05_normalize-activitylongline-H2.sql | 0 .../V3_7_05_normalize-activitylongline-PG.sql | 0 .../migration/V3_7_06_normalize-setlongline-H2.sql | 0 .../migration/V3_7_06_normalize-setlongline-PG.sql | 0 .../V3_7_07_normalize-catchlongline-H2.sql | 0 .../V3_7_07_normalize-catchlongline-PG.sql | 0 .../db/migration/V3_7_08_normalize-tdr-H2.sql | 0 .../db/migration/V3_7_08_normalize-tdr-PG.sql | 0 .../db/migration/V3_7_09_add-species-list-H2.sql | 0 .../db/migration/V3_7_09_add-species-list-PG.sql | 0 .../V3_7_10_increase-comment-field-H2.sql | 0 .../V3_7_10_increase-comment-field-PG.sql | 0 .../db/migration/V3_8_01_fix-person-H2.sql | 0 .../db/migration/V3_8_01_fix-person-PG.sql | 0 .../V3_8_02_fix-branchelinecomposition-H2.sql | 0 .../V3_8_02_fix-branchelinecomposition-PG.sql | 0 .../migration/V3_8_03_normalize-sensorused-H2.sql | 0 .../migration/V3_8_03_normalize-sensorused-PG.sql | 0 .../db/migration/V3_8_04_normalize-tdr-H2.sql | 0 .../db/migration/V3_8_04_normalize-tdr-PG.sql | 0 .../V3_9_01_add-dataFilename-attribute-H2.sql | 0 .../V3_9_01_add-dataFilename-attribute-PG.sql | 0 .../migration/V3_9_02_fill-sensorDataFormat-H2.sql | 0 .../migration/V3_9_02_fill-sensorDataFormat-PG.sql | 0 .../resources/db/migration/V4_0_01_empty-H2.sql | 0 .../resources/db/migration/V4_0_01_empty-PG.sql | 0 .../V4_0_1_01_remove-gender-column-H2.sql | 0 .../db/migration/V4_0_1_02_add-missing-fk-H2.sql | 0 .../db/migration/V4_0_1_02_add-missing-fk-PG.sql | 0 .../V4_0_2_01_remove-gender-column-PG.sql | 0 ...0_4_01_remove-trip-datearriveeport-field-H2.sql | 0 ...0_4_01_remove-trip-datearriveeport-field-PG.sql | 0 .../V4_0_RC_2_01_add-foreign-key-indexes-PG.sql | 0 .../V4_0_RC_2_01_clean-program-gear-type-H2.sql | 0 .../V4_0_RC_2_01_clean-program-gear-type-PG.sql | 0 ...4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql | 0 ...4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql | 0 .../V4_0_RC_2_03_rename-unknown-longliner-H2.sql | 0 .../V4_0_RC_2_03_rename-unknown-longliner-PG.sql | 0 .../db/migration/V4_0_RC_4_01_add-gear-data-H2.sql | 0 .../db/migration/V4_0_RC_4_01_add-gear-data-PG.sql | 0 ...4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql | 0 ...4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql | 0 ...4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql | 0 ...4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql | 0 .../V4_0_RC_7_02_rename-unknown-longliner-H2.sql | 0 .../V4_0_RC_7_02_rename-unknown-longliner-PG.sql | 0 .../migration/V4_900_01_remove_open_field-H2.sql | 0 .../migration/V4_900_01_remove_open_field-PG.sql | 0 .../V4_901_01_add_lastUpdateDate_field-H2.sql | 0 .../V4_901_01_add_lastUpdateDate_field-PG.sql | 0 .../V4_902_01_add_lastUpdateDate_table-H2.sql | 0 .../V4_902_01_add_lastUpdateDate_table-PG.sql | 0 .../migration/V4_903_01_remove_unit_field-H2.sql | 0 .../migration/V4_903_01_remove_unit_field-PG.sql | 0 .../migration/V4_903_02_remove_gender_field-H2.sql | 0 .../migration/V4_903_02_remove_gender_field-PG.sql | 0 .../V4_903_03_remove_duplicate_rows-H2.sql | 0 .../V4_903_03_remove_duplicate_rows-PG.sql | 0 ...drop_not_null_constraint_gearUseFeatures-H2.sql | 0 ...drop_not_null_constraint_gearUseFeatures-PG.sql | 0 ...rveMigrationCallBackForVersionResolverTest.java | 6 +- .../src/test/resources/log4j.properties | 33 + observe-entities/pom.xml | 5 - .../observe/ObserveTopiaApplicationContext.java | 6 +- .../migration/AbstractDataSourceMigration.java | 65 +- .../entities/migration/MigrationVersions.java | 87 +++ ...ObserveMigrationCallBackForVersionResolver.java | 2 +- .../ObserveTopiaApplicationContextTest.java | 109 ---- .../validation => }/RelationRegexTest.java | 2 +- observe-services-topia/pom.xml | 6 + .../services/service/DataSourceServiceTopia.java | 3 +- .../ird/observe/services/DataSourceResource.java | 4 +- .../service/DataSourceServiceTopiaTest.java | 8 +- .../fr/ird/observe/services/service/RigthTest.java | 4 +- pom.xml | 1 + 171 files changed, 1080 insertions(+), 343 deletions(-) diff --git a/observe-entities-migration/LICENSE.txt b/observe-entities-migration/LICENSE.txt new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/observe-entities-migration/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/observe-entities-migration/README.md b/observe-entities-migration/README.md new file mode 100644 index 0000000..e69de29 diff --git a/observe-entities-migration/pom.xml b/observe-entities-migration/pom.xml new file mode 100644 index 0000000..503330d --- /dev/null +++ b/observe-entities-migration/pom.xml @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + ObServe :: Business + + $HeadURL: https://svn.mpl.ird.fr/osiris/observe/trunk/observe-business/pom.xml $ + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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% + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>fr.ird.observe</groupId> + <artifactId>observe</artifactId> + <version>5.0-SNAPSHOT</version> + </parent> + + <artifactId>observe-entities-migration</artifactId> + + <name>ObServe :: Entities Migration</name> + <description>ObServe entities migration module</description> + + <dependencies> + + <!-- sibling dependencies --> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>observe-entities</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Nuiton --> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-version</artifactId> + </dependency> + + <!-- commons --> + <dependency> + <groupId> org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + + <!-- ToPIA --> + + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-persistence</artifactId> + </dependency> + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-service-migration</artifactId> + </dependency> + + <!-- test --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jcl</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-validator</artifactId> + <scope>test</scope> + <classifier>tests</classifier> + </dependency> + + </dependencies> + +</project> diff --git a/observe-entities-migration/src/license/THIRD-PARTY.properties b/observe-entities-migration/src/license/THIRD-PARTY.properties new file mode 100644 index 0000000..e7f6efe --- /dev/null +++ b/observe-entities-migration/src/license/THIRD-PARTY.properties @@ -0,0 +1,33 @@ +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - AL 2.0 +# - Apache License 2.0 +# - Apache License, version 2.0 +# - Apache Software License, version 1.1 +# - BSD License +# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# - Common Development and Distribution License +# - Common Public License Version 1.0 +# - Eclipse Distribution License (EDL), Version 1.0 +# - Eclipse Public License (EPL), Version 1.0 +# - GNU General Public License, Version 2 with the Classpath Exception +# - GNU Library or Lesser General Public License +# - Indiana University Extreme! Lab Software License, vesion 1.1.1 +# - Lesser General Public License (LGPL) +# - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 +# - MIT License +# - MPL 1.1 +# - New BSD License +# - Public Domain +# - The Apache Software License, Version 2.0 +# - The H2 License, Version 1.0 +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Tue Aug 26 01:19:49 CEST 2014 +commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0 +dom4j--dom4j--1.6.1=BSD License diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java similarity index 96% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java index 3775113..d5a0d4b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -24,6 +24,7 @@ package fr.ird.observe.entities.migration.versions; import fr.ird.observe.entities.migration.AbstractDataSourceMigration; import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.MigrationVersions; import org.apache.commons.lang3.tuple.Pair; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -45,7 +46,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_1 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_1(AbstractDataSourceMigration callBack) { - super(AbstractDataSourceMigration.V_3_1, callBack, ""); + super(MigrationVersions.V_3_1.getVersion(), callBack, ""); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java index b858695..2274c41 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_10 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_10(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_10, callBack, scriptSuffix); + super(MigrationVersions.V_3_10.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java similarity index 85% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java index 44d1ed0..8b2f3e7 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_11 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_11(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_11, callBack, scriptSuffix); + super(MigrationVersions.V_3_11.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java index 813d7de..7c25f26 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_12 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_12(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_12, callBack, scriptSuffix); + super(MigrationVersions.V_3_12.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java index 2192843..479f72d 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_14 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_14(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_14, callBack, scriptSuffix); + super(MigrationVersions.V_3_14.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java index 2e7541a..9c89d04 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_15 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_15(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_15, callBack, scriptSuffix); + super(MigrationVersions.V_3_15.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java similarity index 94% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java index d30c97a..b03a7df 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -49,7 +45,7 @@ public class DataSourceMigrationForVersion_3_16 extends AbstractObserveMigration private static final Log log = LogFactory.getLog(DataSourceMigrationForVersion_3_16.class); public DataSourceMigrationForVersion_3_16(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_16, callBack, scriptSuffix); + super(MigrationVersions.V_3_16.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java similarity index 95% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java index ea5102f..beb41ed 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -91,7 +87,7 @@ public abstract class DataSourceMigrationForVersion_3_5 extends AbstractObserveM }; public DataSourceMigrationForVersion_3_5(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_5, callBack, scriptSuffix); + super(MigrationVersions.V_3_5.getVersion(), callBack, scriptSuffix); } protected abstract void removeFK(TopiaSqlSupport tx, String tableName, List<String> queries) throws TopiaException; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java similarity index 86% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java index 8b21f9b..1645adf 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_3_7 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_7(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_7, callBack, scriptSuffix); + super(MigrationVersions.V_3_7.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java index 9212ab2..371f9e8 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_8 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_8(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_8, callBack, scriptSuffix); + super(MigrationVersions.V_3_8.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java index f5a11a7..76aa2a9 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_9 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_9(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_3_9, callBack, scriptSuffix); + super(MigrationVersions.V_3_9.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java index 71214ca..adf8056 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_0 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0, callBack, scriptSuffix); + super(MigrationVersions.V_4_0.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java similarity index 95% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java index 6c47bfd..5d2ade9 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -25,10 +25,6 @@ package fr.ird.observe.entities.migration.versions; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import fr.ird.observe.ObserveTopiaIdFactory; -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import fr.ird.observe.entities.seine.GearUseFeaturesMeasurementSeine; import fr.ird.observe.entities.seine.GearUseFeaturesSeine; import org.nuiton.topia.persistence.TopiaException; @@ -51,7 +47,7 @@ import java.util.Set; public abstract class DataSourceMigrationForVersion_4_0_1 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_1(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_1, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_1.getVersion(), callBack, scriptSuffix); } protected abstract void removeForeignKeys(TopiaSqlSupport tx, List<String> queries); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java index 79be582..e10115b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_2 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_2(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_2, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_2.getVersion(), callBack, scriptSuffix); } public static class H2DataSourceMigrationForVersion extends DataSourceMigrationForVersion_4_0_2 { diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java index df23d87..2c5be0b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -40,7 +36,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_4 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_4(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_4, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_4.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java similarity index 88% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java index 527f753..dbe53fc 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.sql.PreparedStatement; @@ -44,7 +40,7 @@ import java.util.Set; public class DataSourceMigrationForVersion_4_0_RC2 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC2(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_RC2, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_RC2.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java similarity index 96% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java index 2f92da3..a104685 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; @@ -53,7 +49,7 @@ public abstract class DataSourceMigrationForVersion_4_0_RC3 extends AbstractObse private static final Log log = LogFactory.getLog(DataSourceMigrationForVersion_4_0_RC3.class); public DataSourceMigrationForVersion_4_0_RC3(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_RC3, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_RC3.getVersion(), callBack, scriptSuffix); } protected abstract void addMissingForeignKeys(TopiaSqlSupport tx, List<String> queries) throws TopiaException; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java index ca8f1c3..b7fc613 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_0_RC4 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC4(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_RC4, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_RC4.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java similarity index 87% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java index 776807f..3f5d6c3 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_RC6 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC6(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_RC6, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_RC6.getVersion(), callBack, scriptSuffix); } protected abstract void removeForeignKeyOnGearFseFeaturesMeasurementSeine(TopiaSqlSupport tx, List<String> queries); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java similarity index 85% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java index 539b6fd..7b0b3f7 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_RC7 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC7(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_0_RC7, callBack, scriptSuffix); + super(MigrationVersions.V_4_0_RC7.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java index 99ad967..f8a3ccc 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -38,7 +34,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_900 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_900(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_900, callBack, scriptSuffix); + super(MigrationVersions.V_4_900.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java index aed7b16..7a5b699 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -38,7 +34,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_901 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_901(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_901, callBack, scriptSuffix); + super(MigrationVersions.V_4_901.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java index bf171c1..63d05f7 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -38,7 +34,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_902 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_902(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_902, callBack, scriptSuffix); + super(MigrationVersions.V_4_902.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java similarity index 84% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java index afc4088..055bc2e 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -38,7 +34,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_903 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_903(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_903, callBack, scriptSuffix); + super(MigrationVersions.V_4_903.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java index 5861592..607b8aa 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -38,7 +34,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_904 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_904(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_4_904, callBack, scriptSuffix); + super(MigrationVersions.V_4_904.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java similarity index 83% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java index 6775e05..c0ac8b8 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration.versions; +package fr.ird.observe.entities.migration; /* * #%L @@ -22,10 +22,6 @@ package fr.ird.observe.entities.migration.versions; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.H2DataSourceMigration; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -39,7 +35,7 @@ import java.util.List; public class DataSourceMigrationForVersion_5_0 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_5_0(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(AbstractDataSourceMigration.V_5_0, callBack, scriptSuffix); + super(MigrationVersions.V_5_0.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/type/CoordinateHelper.java b/observe-entities-migration/src/main/java/fr/ird/type/CoordinateHelper.java new file mode 100644 index 0000000..5a519ab --- /dev/null +++ b/observe-entities-migration/src/main/java/fr/ird/type/CoordinateHelper.java @@ -0,0 +1,55 @@ +/* + * #%L + * ObServe :: Entities + * %% + * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ird.type; + +/** + * Helper to deal with coordinates. + * + * @author tchemit - chemit@codelutin.com + * @since 1.2 + */ +public class CoordinateHelper { + + /** + * Calcule le quadrant à partir d'une {@code longitude} et {@code latitude}. + * + * @param longitude la longitude décimale + * @param latitude la latitude décimale + * @return la valeur du quadrant ou {@code null} si l'une des deux + * coordonnées est {@code null}. + * @since 1.2 + */ + public static Integer getQuadrant(Float longitude, Float latitude) { + if (longitude == null || latitude == null) { + return null; + } + int result; + + if (latitude > 0) { + result = longitude > 0 ? 1 : 4; + } else { + result = longitude > 0 ? 2 : 3; + } + return result; + } + +} diff --git a/observe-entities/src/main/resources/db/3.5/constrainsts.csv b/observe-entities-migration/src/main/resources/db/3.5/constrainsts.csv similarity index 100% rename from observe-entities/src/main/resources/db/3.5/constrainsts.csv rename to observe-entities-migration/src/main/resources/db/3.5/constrainsts.csv diff --git a/observe-entities/src/main/resources/db/3.5/traduction_attributes.csv b/observe-entities-migration/src/main/resources/db/3.5/traduction_attributes.csv similarity index 100% rename from observe-entities/src/main/resources/db/3.5/traduction_attributes.csv rename to observe-entities-migration/src/main/resources/db/3.5/traduction_attributes.csv diff --git a/observe-entities/src/main/resources/db/3.5/traduction_tables.csv b/observe-entities-migration/src/main/resources/db/3.5/traduction_tables.csv similarity index 100% rename from observe-entities/src/main/resources/db/3.5/traduction_tables.csv rename to observe-entities-migration/src/main/resources/db/3.5/traduction_tables.csv diff --git a/observe-entities/src/main/resources/db/3.5/traduction_tables2.csv b/observe-entities-migration/src/main/resources/db/3.5/traduction_tables2.csv similarity index 100% rename from observe-entities/src/main/resources/db/3.5/traduction_tables2.csv rename to observe-entities-migration/src/main/resources/db/3.5/traduction_tables2.csv diff --git a/observe-entities/src/main/resources/db/migration/V3_10_01_remove-person-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_01_remove-person-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_01_remove-person-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_01_remove-person-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_01_remove-person-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_01_remove-person-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_01_remove-person-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_01_remove-person-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_02_add-missing-fk-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_02_add-missing-fk-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_02_add-missing-fk-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_02_add-missing-fk-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_02_add-missing-fk-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_02_add-missing-fk-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_02_add-missing-fk-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_02_add-missing-fk-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_03_increase-comment-field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_03_increase-comment-field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_03_increase-comment-field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_03_increase-comment-field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_03_increase-comment-field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_03_increase-comment-field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_03_increase-comment-field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_03_increase-comment-field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_04_fix-sensorDataFormat-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_05_normalize-sections-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_05_normalize-sections-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_05_normalize-sections-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_05_normalize-sections-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_10_05_normalize-sections-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_10_05_normalize-sections-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_10_05_normalize-sections-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_10_05_normalize-sections-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_01_remove-speciesGroup-obsolete-fields-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_02_add-country-on-transmitting-buoy-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_03_add-fpaZones-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_03_add-fpaZones-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_03_add-fpaZones-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_03_add-fpaZones-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_03_add-fpaZones-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_03_add-fpaZones-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_03_add-fpaZones-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_03_add-fpaZones-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_04_add-activity-ersId-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_04_add-activity-ersId-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_04_add-activity-ersId-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_04_add-activity-ersId-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_04_add-activity-ersId-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_04_add-activity-ersId-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_04_add-activity-ersId-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_04_add-activity-ersId-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_05_add-person-country-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_05_add-person-country-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_05_add-person-country-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_05_add-person-country-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_05_add-person-country-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_05_add-person-country-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_05_add-person-country-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_05_add-person-country-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_06_add-harbours-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_06_add-harbours-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_06_add-harbours-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_06_add-harbours-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_11_06_add-harbours-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_11_06_add-harbours-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_11_06_add-harbours-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_11_06_add-harbours-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_12_01_add-missing-boat-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_12_01_add-missing-boat-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_12_01_add-missing-boat-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_12_01_add-missing-boat-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_12_01_add-missing-boat-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_12_01_add-missing-boat-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_12_01_add-missing-boat-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_12_01_add-missing-boat-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_01_remove-hooksPerBasketCount-field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_02_fix-targetsample-discarded-value-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_03_remove-orphan-seine-sample-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_14_04_remove-targetlength-discarded-field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_01_change-tdr-integer-field-to-float-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_02_remove-set-longline-length-fields-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_15_03_remove-brancheline-fields-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_01_add-gear-referential-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_01_add-gear-referential-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_01_add-gear-referential-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_01_add-gear-referential-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_01_add-gear-referential-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_01_add-gear-referential-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_01_add-gear-referential-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_01_add-gear-referential-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_02_add-gear-data-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_02_add-gear-data-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_02_add-gear-data-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_02_add-gear-data-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_02_add-gear-data-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_02_add-gear-data-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_02_add-gear-data-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_02_add-gear-data-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_16_03_remove-tripSeine-seine-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_01_migration-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_01_migration-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_01_migration-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_01_migration-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_01_migration-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_01_migration-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_01_migration-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_01_migration-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_02_add-longline-schema-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_02_add-longline-schema-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_02_add-longline-schema-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_02_add-longline-schema-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_02_add-longline-schema-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_02_add-longline-schema-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_02_add-longline-schema-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_02_add-longline-schema-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_03_update-common-references-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_03_update-common-references-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_03_update-common-references-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_03_update-common-references-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_03_update-common-references-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_03_update-common-references-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_03_update-common-references-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_03_update-common-references-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_04_add-longline-references-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_04_add-longline-references-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_04_add-longline-references-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_04_add-longline-references-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_5_04_add-longline-references-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_5_04_add-longline-references-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_5_04_add-longline-references-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_5_04_add-longline-references-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_01_rename-seine-model-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_01_rename-seine-model-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_01_rename-seine-model-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_01_rename-seine-model-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_01_rename-seine-model-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_01_rename-seine-model-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_01_rename-seine-model-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_01_rename-seine-model-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_02_remove-trip-organism-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_02_remove-trip-organism-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_02_remove-trip-organism-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_02_remove-trip-organism-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_02_remove-trip-organism-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_02_remove-trip-organism-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_02_remove-trip-organism-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_02_remove-trip-organism-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_03_add-referential-needComment-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_03_add-referential-needComment-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_03_add-referential-needComment-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_03_add-referential-needComment-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_03_add-referential-needComment-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_03_add-referential-needComment-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_03_add-referential-needComment-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_03_add-referential-needComment-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_04_normalize-triplongline-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_04_normalize-triplongline-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_04_normalize-triplongline-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_04_normalize-triplongline-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_04_normalize-triplongline-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_04_normalize-triplongline-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_04_normalize-triplongline-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_04_normalize-triplongline-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_05_normalize-activitylongline-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_06_normalize-setlongline-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_06_normalize-setlongline-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_06_normalize-setlongline-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_06_normalize-setlongline-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_06_normalize-setlongline-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_06_normalize-setlongline-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_06_normalize-setlongline-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_06_normalize-setlongline-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_07_normalize-catchlongline-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_08_normalize-tdr-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_08_normalize-tdr-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_08_normalize-tdr-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_08_normalize-tdr-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_08_normalize-tdr-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_08_normalize-tdr-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_08_normalize-tdr-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_08_normalize-tdr-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_09_add-species-list-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_09_add-species-list-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_09_add-species-list-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_09_add-species-list-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_09_add-species-list-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_09_add-species-list-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_09_add-species-list-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_09_add-species-list-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_10_increase-comment-field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_10_increase-comment-field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_10_increase-comment-field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_10_increase-comment-field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_7_10_increase-comment-field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_7_10_increase-comment-field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_7_10_increase-comment-field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_7_10_increase-comment-field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_01_fix-person-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_01_fix-person-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_01_fix-person-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_01_fix-person-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_01_fix-person-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_01_fix-person-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_01_fix-person-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_01_fix-person-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_02_fix-branchelinecomposition-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_03_normalize-sensorused-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_03_normalize-sensorused-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_03_normalize-sensorused-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_03_normalize-sensorused-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_03_normalize-sensorused-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_03_normalize-sensorused-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_03_normalize-sensorused-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_03_normalize-sensorused-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_04_normalize-tdr-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_04_normalize-tdr-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_04_normalize-tdr-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_04_normalize-tdr-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_8_04_normalize-tdr-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_8_04_normalize-tdr-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_8_04_normalize-tdr-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_8_04_normalize-tdr-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_9_01_add-dataFilename-attribute-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V3_9_02_fill-sensorDataFormat-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_01_empty-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_01_empty-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_01_empty-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_01_empty-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_01_empty-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_01_empty-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_01_empty-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_01_empty-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_1_01_remove-gender-column-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_1_01_remove-gender-column-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_1_01_remove-gender-column-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_1_01_remove-gender-column-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_1_02_add-missing-fk-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_2_01_remove-gender-column-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_2_01_remove-gender-column-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_2_01_remove-gender-column-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_2_01_remove-gender-column-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_4_01_remove-trip-datearriveeport-field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_add-foreign-key-indexes-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_add-foreign-key-indexes-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_add-foreign-key-indexes-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_add-foreign-key-indexes-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_01_clean-program-gear-type-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_02_update-senne-gear-usedInTrip-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_2_03_rename-unknown-longliner-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_4_01_add-gear-data-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_6_01_fix-gearUseFeatures-topiaIds-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_01_update-senne-gear-usedInTrip-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_0_RC_7_02_rename-unknown-longliner-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_900_01_remove_open_field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_900_01_remove_open_field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_900_01_remove_open_field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_900_01_remove_open_field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_900_01_remove_open_field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_900_01_remove_open_field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_900_01_remove_open_field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_900_01_remove_open_field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_901_01_add_lastUpdateDate_field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_902_01_add_lastUpdateDate_table-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_01_remove_unit_field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_01_remove_unit_field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_01_remove_unit_field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_01_remove_unit_field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_01_remove_unit_field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_01_remove_unit_field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_01_remove_unit_field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_01_remove_unit_field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_02_remove_gender_field-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_02_remove_gender_field-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_02_remove_gender_field-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_02_remove_gender_field-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_02_remove_gender_field-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_02_remove_gender_field-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_02_remove_gender_field-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_02_remove_gender_field-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_903_03_remove_duplicate_rows-PG.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-H2.sql b/observe-entities-migration/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-H2.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-H2.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-H2.sql diff --git a/observe-entities/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-PG.sql b/observe-entities-migration/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-PG.sql similarity index 100% rename from observe-entities/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-PG.sql rename to observe-entities-migration/src/main/resources/db/migration/V4_904_01_drop_not_null_constraint_gearUseFeatures-PG.sql diff --git a/observe-entities/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java b/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java similarity index 91% rename from observe-entities/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java rename to observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java index 9a20b47..ede5b24 100644 --- a/observe-entities/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java +++ b/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java @@ -41,7 +41,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { = new ObserveMigrationCallBackForVersionResolver("H2"); Assert.assertNotNull(resolver); - for (Version version : AbstractDataSourceMigration.availableVersions) { + for (Version version : MigrationVersions.getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } @@ -52,7 +52,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { ObserveMigrationCallBackForVersionResolver resolver = new ObserveMigrationCallBackForVersionResolver("PG"); Assert.assertNotNull(resolver); - for (Version version : AbstractDataSourceMigration.availableVersions) { + for (Version version : MigrationVersions.getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } @@ -63,7 +63,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { ObserveMigrationCallBackForVersionResolver resolver = new ObserveMigrationCallBackForVersionResolver("Dummy"); Assert.assertNotNull(resolver); - for (Version version : AbstractDataSourceMigration.availableVersions) { + for (Version version : MigrationVersions.getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } diff --git a/observe-entities-migration/src/test/resources/log4j.properties b/observe-entities-migration/src/test/resources/log4j.properties new file mode 100644 index 0000000..434cab6 --- /dev/null +++ b/observe-entities-migration/src/test/resources/log4j.properties @@ -0,0 +1,33 @@ +### +# #%L +# ObServe :: Entities +# %% +# Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### + +# Global logging configuration +log4j.rootLogger=ERROR, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%c:%L) %M - %m%n + +# package level +log4j.logger.fr.ird.observe=INFO +log4j.logger.org.nuiton.topia=INFO +log4j.logger.jaxx.runtime.decorator=INFO diff --git a/observe-entities/pom.xml b/observe-entities/pom.xml index 862026c..c0eefb2 100644 --- a/observe-entities/pom.xml +++ b/observe-entities/pom.xml @@ -41,11 +41,6 @@ <!-- sibling dependencies --> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>observe-test-data</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> <artifactId>observe-topia-extension</artifactId> <version>${project.version}</version> </dependency> diff --git a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java index a22a85c..e2ea4da 100644 --- a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java +++ b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java @@ -87,7 +87,7 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat public ObserveTopiaApplicationContext(ObserveTopiaConfiguration topiaConfiguration) { super(topiaConfiguration); this.authenticationToken = UUID.randomUUID().toString(); - this.topiaMetadataModelSupport = new TopiaMetadataModelSupportImpl("fr.ird.observe","Observe"); + this.topiaMetadataModelSupport = new TopiaMetadataModelSupportImpl("fr.ird.observe", "Observe"); this.topiaSqlTablesFactory = new TopiaSqlTablesFactory(getMetadataModel(), this); } @@ -141,8 +141,8 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat try (ObserveTopiaPersistenceContext topiaPersistenceContext = newPersistenceContext()) { String sql = Stream.concat(Entities.REFERENCE_ENTITIES_LIST.stream(), Entities.DATA_ENTITIES_LIST.stream()) - .map(entity -> String.format(INSERT_LAST_UPDATE_PATTERN, entity.ordinal(), entity.getContract().getCanonicalName())) - .collect(Collectors.joining("\n")); + .map(entity -> String.format(INSERT_LAST_UPDATE_PATTERN, entity.ordinal(), entity.getContract().getCanonicalName())) + .collect(Collectors.joining("\n")); topiaPersistenceContext.getSqlSupport().executeSql(sql); topiaPersistenceContext.commit(); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java index 4bbbe28..25e58c8 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java @@ -27,7 +27,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; import org.nuiton.version.Version; -import org.nuiton.version.Versions; import java.util.List; @@ -39,63 +38,14 @@ import java.util.List; */ public abstract class AbstractDataSourceMigration extends TopiaMigrationCallbackByClass { - /** - * Logger - */ - private static final Log log = - LogFactory.getLog(AbstractDataSourceMigration.class); - - public static final Version V_3_0 = Versions.valueOf("3.0"); - public static final Version V_3_1 = Versions.valueOf("3.1"); - public static final Version V_3_5 = Versions.valueOf("3.5"); - public static final Version V_3_7 = Versions.valueOf("3.7"); - public static final Version V_3_8 = Versions.valueOf("3.8"); - public static final Version V_3_9 = Versions.valueOf("3.9"); - public static final Version V_3_10 = Versions.valueOf("3.10"); - public static final Version V_3_11 = Versions.valueOf("3.11"); - public static final Version V_3_12 = Versions.valueOf("3.12"); - public static final Version V_3_14 = Versions.valueOf("3.14"); - public static final Version V_3_15 = Versions.valueOf("3.15"); - public static final Version V_3_16 = Versions.valueOf("3.16"); - - public static final Version V_4_0_RC2 = Versions.valueOf("4.0-RC2"); - public static final Version V_4_0_RC3 = Versions.valueOf("4.0-RC3"); - public static final Version V_4_0_RC4 = Versions.valueOf("4.0-RC4"); - public static final Version V_4_0_RC6 = Versions.valueOf("4.0-RC6"); - public static final Version V_4_0_RC7 = Versions.valueOf("4.0-RC7"); - - public static final Version V_4_0 = Versions.valueOf("4.0"); - public static final Version V_4_0_1 = Versions.valueOf("4.0.1"); - public static final Version V_4_0_2 = Versions.valueOf("4.0.2"); - public static final Version V_4_0_4 = Versions.valueOf("4.0.4"); - - public static final Version V_4_900 = Versions.valueOf("4.900"); - public static final Version V_4_901 = Versions.valueOf("4.901"); - public static final Version V_4_902 = Versions.valueOf("4.902"); - public static final Version V_4_903 = Versions.valueOf("4.903"); - public static final Version V_4_904 = Versions.valueOf("4.904"); - - // FIXME A utiliser en version final 5.0 - public static final Version V_5_0 = Versions.valueOf("5.0"); - - /** - * Les versions de mise à jour disponibles. - */ - public static final Version[] availableVersions = new Version[]{ - V_3_1, V_3_5, V_3_7, V_3_8, V_3_9, V_3_10, V_3_11, V_3_12, V_3_14, V_3_15, V_3_16, V_4_0_RC2, - V_4_0_RC3, V_4_0_RC4, V_4_0_RC6, V_4_0_RC7, V_4_0, V_4_0_1, V_4_0_2, V_4_0_4, - V_4_900, V_4_901, V_4_902, V_4_903, V_4_904 - // FIXME A utiliser en version final 5.0 - //V_5_0 - - }; - + /** Logger. */ + private static final Log log = LogFactory.getLog(AbstractDataSourceMigration.class); public static ImmutableList<Version> getVersionsAfter(Version current) { ImmutableList.Builder<Version> builder = ImmutableList.builder(); - for (Version version : availableVersions) { + for (Version version : MigrationVersions.getAvailableVersions()) { if (version.after(current)) { @@ -117,22 +67,17 @@ public abstract class AbstractDataSourceMigration extends TopiaMigrationCallback @Override public Version[] getAvailableVersions() { - return availableVersions; + return MigrationVersions.getAvailableVersions(); } - @Override public boolean askUser(Version dbVersion, List<Version> versions) { // on autorise les migrations dès quelles sont demandée pour une version égale ou superieur à la V3.0. - return dbVersion.afterOrEquals(V_3_0); + return dbVersion.afterOrEquals(MigrationVersions.getMinimumVersion()); } public void setTopiaApplicationContext(ObserveTopiaApplicationContext topiaApplicationContext) { this.topiaApplicationContext = topiaApplicationContext; } - public static Version getLastVersion() { - int lastIndex = availableVersions.length - 1; - return availableVersions[lastIndex]; - } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java new file mode 100644 index 0000000..a6e8f06 --- /dev/null +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java @@ -0,0 +1,87 @@ +package fr.ird.observe.entities.migration; + +import org.nuiton.version.Version; +import org.nuiton.version.Versions; + +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * Created on 01/08/16. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 5.0 + */ +public enum MigrationVersions { + + V_3_0("3.0", false), + V_3_1("3.1"), + V_3_5("3.5"), + V_3_7("3.7"), + V_3_8("3.8"), + V_3_9("3.9"), + V_3_10("3.10"), + V_3_11("3.11"), + V_3_12("3.12"), + V_3_14("3.14"), + V_3_15("3.15"), + V_3_16("3.16"), + V_4_0_RC2("4.0-RC2"), + V_4_0_RC3("4.0-RC3"), + V_4_0_RC4("4.0-RC4"), + V_4_0_RC6("4.0-RC6"), + V_4_0_RC7("4.0-RC7"), + V_4_0("4.0"), + V_4_0_1("4.0.1"), + V_4_0_2("4.0.2"), + V_4_0_4("4.0.4"), + V_4_900("4.900"), + V_4_901("4.901"), + V_4_902("4.902"), + V_4_903("4.903"), + V_4_904("4.904"), + + // FIXME A utiliser en version final 5.0 + V_5_0("5.0", false); + + private static Version[] AVAILABLE_VERSIONS; + + private final Version version; + private final boolean canApply; + + MigrationVersions(String versionAsString, boolean canApply) { + this.version = Versions.valueOf(versionAsString); + this.canApply = canApply; + } + + MigrationVersions(String versionAsString) { + this(versionAsString, true); + } + + public Version getVersion() { + return version; + } + + public static Version[] getAvailableVersions() { + if (AVAILABLE_VERSIONS == null) { + Set<Version> result = new LinkedHashSet<>(); + for (MigrationVersions migrationVersions : values()) { + if (migrationVersions.canApply) { + result.add(migrationVersions.getVersion()); + } + } + AVAILABLE_VERSIONS = result.toArray(new Version[result.size()]); + } + return AVAILABLE_VERSIONS; + } + + public static Version getLastVersion() { + Version[] values = getAvailableVersions(); + int lastIndex = values.length - 1; + return values[lastIndex]; + } + + public static Version getMinimumVersion() { + return V_3_0.getVersion(); + } +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java index 10ee36b..0e440ee 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java @@ -51,7 +51,7 @@ class ObserveMigrationCallBackForVersionResolver implements TopiaMigrationCallba @Override public Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> getCallBack(Version version) { - String mainclassName = getClass().getPackage().getName() + ".versions.DataSourceMigrationForVersion_" + version.getValidName(); + String mainclassName = getClass().getPackage().getName() + ".DataSourceMigrationForVersion_" + version.getValidName(); Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> result = null; try { Class<?> mainClass = Class.forName(mainclassName); diff --git a/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java b/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java deleted file mode 100644 index fded7d4..0000000 --- a/observe-entities/src/test/java/fr/ird/observe/ObserveTopiaApplicationContextTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package fr.ird.observe; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2015 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.test.TestHelper; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.nuiton.topia.persistence.metadata.TopiaMetadataModel; -import org.nuiton.topia.persistence.metadata.TopiaMetadataModelVisitor; - -import java.io.File; - -/** - * Created on 23/08/15. - * - * @author Tony Chemit - chemit@codelutin.com - */ -public class ObserveTopiaApplicationContextTest { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ObserveTopiaApplicationContextTest.class); - - @Rule - public final TestName testName = new TestName(); - - protected File testDirectory; - - @BeforeClass - public static void setUpClass() throws Exception { - - TestHelper.initTest(ObserveTopiaApplicationContextTest.class); - } - - @Before - public void setUp() { - testDirectory = TestHelper.newFile(testName.getMethodName()); - } - - @Test - public void testOpenEmptyDatabase() { - - File dbDirectory = new File(testDirectory, "db"); - - if (log.isInfoEnabled()) { - log.info("database directory: " + dbDirectory); - } - - ObserveTopiaConfiguration topiaConfiguration = ObserveTopiaConfigurationFactory.forH2Database( - dbDirectory, - "obstuna", - TestHelper.TEST_H2_LOGIN, - String.valueOf(TestHelper.TEST_H2_PASSWORD), - true, - true, - true - ); - - ObserveTopiaApplicationContext topiaApplicationContext = new ObserveTopiaApplicationContext(topiaConfiguration); - - try (ObserveTopiaPersistenceContext topiaPersistenceContext = topiaApplicationContext.newPersistenceContext()) { - - TestHelper.assertSchemaCreated(topiaApplicationContext, topiaPersistenceContext, false); - - } - - TopiaMetadataModel metadataModel = topiaApplicationContext.getMetadataModel(); - - { - TopiaMetadataModelVisitor.PrintVisitor printVisitor = new TopiaMetadataModelVisitor.PrintVisitor(true, "\n"); - - metadataModel.getEntity(ObserveEntityEnum.TripSeine.name()).accept(printVisitor, metadataModel); - - log.info("TripSeine shell:\n" + printVisitor.toString()); - } - - { - TopiaMetadataModelVisitor.PrintVisitor printVisitor = new TopiaMetadataModelVisitor.PrintVisitor(true, "\n"); - - metadataModel.getEntity(ObserveEntityEnum.TripLongline.name()).accept(printVisitor, metadataModel); - - log.info("TripLongline shell:\n" + printVisitor.toString()); - } - } -} \ No newline at end of file diff --git a/observe-entities/src/test/java/fr/ird/observe/business/validation/RelationRegexTest.java b/observe-entities/src/test/java/fr/ird/observe/RelationRegexTest.java similarity index 98% rename from observe-entities/src/test/java/fr/ird/observe/business/validation/RelationRegexTest.java rename to observe-entities/src/test/java/fr/ird/observe/RelationRegexTest.java index 953eb41..cee74db 100644 --- a/observe-entities/src/test/java/fr/ird/observe/business/validation/RelationRegexTest.java +++ b/observe-entities/src/test/java/fr/ird/observe/RelationRegexTest.java @@ -20,7 +20,7 @@ * #L% */ -package fr.ird.observe.business.validation; +package fr.ird.observe; import org.junit.Assert; import org.junit.Test; diff --git a/observe-services-topia/pom.xml b/observe-services-topia/pom.xml index 69f9963..497ce95 100644 --- a/observe-services-topia/pom.xml +++ b/observe-services-topia/pom.xml @@ -45,6 +45,12 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>observe-entities-migration</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>observe-services-topia-validation</artifactId> <version>${project.version}</version> <scope>runtime</scope> diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java index b29ff3c..d5cfa7b 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java @@ -31,6 +31,7 @@ import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaConfiguration; import fr.ird.observe.ObserveTopiaConfigurationFactory; import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.MigrationVersions; import fr.ird.observe.services.ObserveJdbcHelper; import fr.ird.observe.services.ObserveSecurityHelper; import fr.ird.observe.services.ObserveServiceTopia; @@ -586,7 +587,7 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS writeReferential, readData, writeData, - AbstractDataSourceMigration.V_3_0, + MigrationVersions.getMinimumVersion(), version, AbstractDataSourceMigration.getVersionsAfter(version)); return information; diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java b/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java index d6302e1..614742d 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java @@ -26,7 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaPersistenceContext; -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.MigrationVersions; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; import fr.ird.observe.services.configuration.ObserveDataSourceConnection; import fr.ird.observe.services.dto.DataSourceCreateConfigurationDto; @@ -233,7 +233,7 @@ public class DataSourceResource implements TestRule { configurationTopiaH2.setDirectory(localDbFile); configurationTopiaH2.setDbName("obstuna"); configurationTopiaH2.setAutoMigrate(true); - configurationTopiaH2.setModelVersion(AbstractDataSourceMigration.getLastVersion()); + configurationTopiaH2.setModelVersion(MigrationVersions.getLastVersion()); return configurationTopiaH2; } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java index f5d5614..da3e600 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java @@ -24,7 +24,7 @@ package fr.ird.observe.services.service; import com.google.common.collect.ImmutableSet; import fr.ird.observe.ObserveTopiaApplicationContext; -import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.MigrationVersions; import fr.ird.observe.services.ObserveTopiaApplicationContextFactory; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; import fr.ird.observe.services.configuration.ObserveDataSourceConnection; @@ -175,7 +175,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { @Test public void testCreateDataSourceFromImportDatabase() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException, BabModelVersionException { - String scriptPath = applicationContextResource.getScriptPath("referentiel", H2DataSourceMigration.V_4_0); + String scriptPath = applicationContextResource.getScriptPath("referentiel", MigrationVersions.V_4_0.getVersion()); byte[] dumpContent = TestHelper.getResourceContent(scriptPath); @@ -193,7 +193,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { public void testCreateDataSourceFromImportReferential() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { // On crée un base qui fait office de source de référentiel - String scriptPath = applicationContextResource.getScriptPath("referentiel", H2DataSourceMigration.V_4_0_1); + String scriptPath = applicationContextResource.getScriptPath("referentiel", MigrationVersions.V_4_0_1.getVersion()); dataSourceResource.createDataSourceFromScript(scriptPath); ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = dataSourceResource.getDataSourceConfiguration(); @@ -217,7 +217,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { public void testCreateDataSourceFromImportReferentialAndData() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { // On crée un base qui fait office de source de référentiel et de source de données (uniquement des données seine) - String scriptPath = applicationContextResource.getScriptPath("dataForTestSeine", H2DataSourceMigration.V_4_0_1); + String scriptPath = applicationContextResource.getScriptPath("dataForTestSeine", MigrationVersions.V_4_0_1.getVersion()); dataSourceResource.createDataSourceFromScript(scriptPath); ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = dataSourceResource.getDataSourceConfiguration(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java index b10d4bd..a209ddd 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java @@ -22,7 +22,7 @@ package fr.ird.observe.services.service; * #L% */ -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.MigrationVersions; import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.ObserveServiceContextTopia; import fr.ird.observe.services.ObserveServiceContextTopiaTaiste; @@ -91,7 +91,7 @@ public class RigthTest { configurationTopiaPG.setUsername(login); configurationTopiaPG.setPassword('a'); configurationTopiaPG.setAutoMigrate(true); - configurationTopiaPG.setModelVersion(AbstractDataSourceMigration.getLastVersion()); + configurationTopiaPG.setModelVersion(MigrationVersions.getLastVersion()); return configurationTopiaPG; diff --git a/pom.xml b/pom.xml index 959f874..e28224b 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,7 @@ <module>observe-services-api</module> <module>observe-test-data</module> <module>observe-entities</module> + <module>observe-entities-migration</module> <module>observe-services-topia-validation</module> <module>observe-services-topia</module> <module>observe-services-rest</module> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 01d87d9d4d71cf4ae7fd052dbe2d52ad71cae029 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 16:39:23 2016 +0200 Meilleur découpage de la migration --- .../migration/AbstractDataSourceMigration.java | 30 +---- .../AbstractObserveMigrationCallBack.java | 26 +---- .../entities/migration/H2DataSourceMigration.java | 0 ...ObserveMigrationCallBackForVersionResolver.java | 2 +- .../ObserveMigrationConfigurationProviderImpl.java | 121 +++++++++++++++++++++ .../entities/migration/PGDataSourceMigration.java | 0 .../DataSourceMigrationForVersion_3_1.java | 6 +- .../DataSourceMigrationForVersion_3_10.java | 9 +- .../DataSourceMigrationForVersion_3_11.java | 9 +- .../DataSourceMigrationForVersion_3_12.java | 9 +- .../DataSourceMigrationForVersion_3_14.java | 9 +- .../DataSourceMigrationForVersion_3_15.java | 9 +- .../DataSourceMigrationForVersion_3_16.java | 9 +- .../DataSourceMigrationForVersion_3_5.java | 9 +- .../DataSourceMigrationForVersion_3_7.java | 9 +- .../DataSourceMigrationForVersion_3_8.java | 9 +- .../DataSourceMigrationForVersion_3_9.java | 9 +- .../DataSourceMigrationForVersion_4_0.java | 9 +- .../DataSourceMigrationForVersion_4_0_1.java | 9 +- .../DataSourceMigrationForVersion_4_0_2.java | 9 +- .../DataSourceMigrationForVersion_4_0_4.java | 9 +- .../DataSourceMigrationForVersion_4_0_RC2.java | 9 +- .../DataSourceMigrationForVersion_4_0_RC3.java | 9 +- .../DataSourceMigrationForVersion_4_0_RC4.java | 9 +- .../DataSourceMigrationForVersion_4_0_RC6.java | 9 +- .../DataSourceMigrationForVersion_4_0_RC7.java | 9 +- .../DataSourceMigrationForVersion_4_900.java | 9 +- .../DataSourceMigrationForVersion_4_901.java | 9 +- .../DataSourceMigrationForVersion_4_902.java | 9 +- .../DataSourceMigrationForVersion_4_903.java | 9 +- .../DataSourceMigrationForVersion_4_904.java | 9 +- .../DataSourceMigrationForVersion_5_0.java | 9 +- ...migration.ObserveMigrationConfigurationProvider | 1 + ...rveMigrationCallBackForVersionResolverTest.java | 6 +- .../observe/ObserveTopiaApplicationContext.java | 7 ++ .../observe/ObserveTopiaConfigurationFactory.java | 75 +++++++------ .../entities/migration/MigrationVersions.java | 87 --------------- .../ObserveMigrationConfigurationProvider.java | 40 +++++++ .../entities/migration/ObserveMigrationEngine.java | 13 +-- .../services/service/DataSourceServiceTopia.java | 14 +-- .../ird/observe/services/DataSourceResource.java | 4 +- .../service/DataSourceServiceTopiaTest.java | 7 +- .../fr/ird/observe/services/service/RigthTest.java | 6 +- .../java/fr/ird/observe/test/ObserveFixtures.java | 3 + 44 files changed, 411 insertions(+), 262 deletions(-) diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java similarity index 67% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java index 25e58c8..92a3f1b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractDataSourceMigration.java @@ -21,8 +21,6 @@ */ package fr.ird.observe.entities.migration; -import com.google.common.collect.ImmutableList; -import fr.ird.observe.ObserveTopiaApplicationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; @@ -41,43 +39,19 @@ public abstract class AbstractDataSourceMigration extends TopiaMigrationCallback /** Logger. */ private static final Log log = LogFactory.getLog(AbstractDataSourceMigration.class); - public static ImmutableList<Version> getVersionsAfter(Version current) { - - ImmutableList.Builder<Version> builder = ImmutableList.builder(); - - for (Version version : MigrationVersions.getAvailableVersions()) { - - if (version.after(current)) { - - builder.add(version); - - } - } - - return builder.build(); - } - - protected ObserveTopiaApplicationContext topiaApplicationContext; - protected AbstractDataSourceMigration(MigrationCallBackForVersionResolver callBackResolver) { - super(callBackResolver); - } @Override public Version[] getAvailableVersions() { - return MigrationVersions.getAvailableVersions(); + return ObserveMigrationConfigurationProvider.get().getAvailableVersions(); } @Override public boolean askUser(Version dbVersion, List<Version> versions) { // on autorise les migrations dès quelles sont demandée pour une version égale ou superieur à la V3.0. - return dbVersion.afterOrEquals(MigrationVersions.getMinimumVersion()); - } - - public void setTopiaApplicationContext(ObserveTopiaApplicationContext topiaApplicationContext) { - this.topiaApplicationContext = topiaApplicationContext; + return dbVersion.afterOrEquals(ObserveMigrationConfigurationProvider.get().getMinimumVersion()); } } diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java similarity index 79% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java index a17266e..f4f2e49 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/AbstractObserveMigrationCallBack.java @@ -1,27 +1,5 @@ package fr.ird.observe.entities.migration; -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; @@ -49,9 +27,7 @@ import java.util.Set; */ public abstract class AbstractObserveMigrationCallBack extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion { - /** - * Logger. - */ + /** Logger. */ private static final Log log = LogFactory.getLog(AbstractObserveMigrationCallBack.class); private final String scriptSuffix; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java similarity index 100% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/H2DataSourceMigration.java diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java similarity index 98% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java index 0e440ee..10ee36b 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolver.java @@ -51,7 +51,7 @@ class ObserveMigrationCallBackForVersionResolver implements TopiaMigrationCallba @Override public Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> getCallBack(Version version) { - String mainclassName = getClass().getPackage().getName() + ".DataSourceMigrationForVersion_" + version.getValidName(); + String mainclassName = getClass().getPackage().getName() + ".versions.DataSourceMigrationForVersion_" + version.getValidName(); Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> result = null; try { Class<?> mainClass = Class.forName(mainclassName); diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProviderImpl.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProviderImpl.java new file mode 100644 index 0000000..b08e15e --- /dev/null +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProviderImpl.java @@ -0,0 +1,121 @@ +package fr.ird.observe.entities.migration; + +import com.google.common.collect.ImmutableList; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; +import org.nuiton.version.Version; +import org.nuiton.version.Versions; + +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * Created on 01/08/16. + * + * @author Tony Chemit - chemit@codelutin.com + */ +public final class ObserveMigrationConfigurationProviderImpl extends ObserveMigrationConfigurationProvider { + + public enum ObserveMigrationVersions { + + V_3_0("3.0", false), + V_3_1("3.1"), + V_3_5("3.5"), + V_3_7("3.7"), + V_3_8("3.8"), + V_3_9("3.9"), + V_3_10("3.10"), + V_3_11("3.11"), + V_3_12("3.12"), + V_3_14("3.14"), + V_3_15("3.15"), + V_3_16("3.16"), + V_4_0_RC2("4.0-RC2"), + V_4_0_RC3("4.0-RC3"), + V_4_0_RC4("4.0-RC4"), + V_4_0_RC6("4.0-RC6"), + V_4_0_RC7("4.0-RC7"), + V_4_0("4.0"), + V_4_0_1("4.0.1"), + V_4_0_2("4.0.2"), + V_4_0_4("4.0.4"), + V_4_900("4.900"), + V_4_901("4.901"), + V_4_902("4.902"), + V_4_903("4.903"), + V_4_904("4.904"), + + // FIXME A utiliser en version final 5.0 + V_5_0("5.0", false); + + + private final Version version; + private final boolean canApply; + + ObserveMigrationVersions(String versionAsString, boolean canApply) { + this.version = Versions.valueOf(versionAsString); + this.canApply = canApply; + } + + ObserveMigrationVersions(String versionAsString) { + this(versionAsString, true); + } + + public Version getVersion() { + return version; + } + + } + + private final Version[] availableVersions; + + public ObserveMigrationConfigurationProviderImpl() { + + Set<Version> result = new LinkedHashSet<>(); + for (ObserveMigrationVersions version : ObserveMigrationVersions.values()) { + if (version.canApply) { + result.add(version.getVersion()); + } + } + this.availableVersions = result.toArray(new Version[result.size()]); + } + + @Override + public Version[] getAvailableVersions() { + return availableVersions; + } + + @Override + public Version getLastVersion() { + Version[] values = getAvailableVersions(); + int lastIndex = values.length - 1; + return values[lastIndex]; + } + + @Override + public Version getMinimumVersion() { + return ObserveMigrationVersions.V_3_0.getVersion(); + } + + @Override + public ImmutableList<Version> getVersionsAfter(Version current) { + + ImmutableList.Builder<Version> builder = ImmutableList.builder(); + + for (Version version : getAvailableVersions()) { + + if (version.after(current)) { + builder.add(version); + } + + } + + return builder.build(); + + } + + @Override + public Class<? extends TopiaMigrationCallbackByClass> getMigrationClassBack(boolean h2) { + return h2 ? H2DataSourceMigration.class : PGDataSourceMigration.class; + } + +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java similarity index 100% rename from observe-entities/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/PGDataSourceMigration.java diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java similarity index 94% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java index d5a0d4b..0f8e16f 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_1.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_1.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -24,7 +24,7 @@ package fr.ird.observe.entities.migration; import fr.ird.observe.entities.migration.AbstractDataSourceMigration; import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; -import fr.ird.observe.entities.migration.MigrationVersions; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; import org.apache.commons.lang3.tuple.Pair; import org.nuiton.topia.persistence.support.TopiaSqlQuery; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -46,7 +46,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_1 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_1(AbstractDataSourceMigration callBack) { - super(MigrationVersions.V_3_1.getVersion(), callBack, ""); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_1.getVersion(), callBack, ""); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java index 2274c41..dda7894 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_10.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_10.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_10 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_10(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_10.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_10.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java similarity index 81% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java index 8b2f3e7..956a5ae 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_11.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_11.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_11 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_11(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_11.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_11.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java index 7c25f26..bc99eb3 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_12.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_12.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_12 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_12(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_12.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_12.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java index 479f72d..98d69f9 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_14.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_14.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_14 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_14(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_14.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_14.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java index 9c89d04..911279c 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_15.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_15.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_15 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_15(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_15.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_15.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java similarity index 92% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java index b03a7df..29b2def 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_16.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_16.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -45,7 +50,7 @@ public class DataSourceMigrationForVersion_3_16 extends AbstractObserveMigration private static final Log log = LogFactory.getLog(DataSourceMigrationForVersion_3_16.class); public DataSourceMigrationForVersion_3_16(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_16.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_16.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java similarity index 94% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java index beb41ed..d085b1e 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_5.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_5.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -87,7 +92,7 @@ public abstract class DataSourceMigrationForVersion_3_5 extends AbstractObserveM }; public DataSourceMigrationForVersion_3_5(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_5.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_5.getVersion(), callBack, scriptSuffix); } protected abstract void removeFK(TopiaSqlSupport tx, String tableName, List<String> queries) throws TopiaException; diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java similarity index 82% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java index 1645adf..f970536 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_7.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_7.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_3_7 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_7(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_7.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_7.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java index 371f9e8..1453de5 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_8.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_8.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_8 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_8(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_8.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_8.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java index 76aa2a9..da4a57b 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_3_9.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_3_9.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_3_9 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_3_9(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_3_9.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_3_9.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java index adf8056..cacdcd0 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_0 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java similarity index 94% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java index 5d2ade9..fa85f0e 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_1.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_1.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -25,6 +25,11 @@ package fr.ird.observe.entities.migration; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import fr.ird.observe.ObserveTopiaIdFactory; +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import fr.ird.observe.entities.seine.GearUseFeaturesMeasurementSeine; import fr.ird.observe.entities.seine.GearUseFeaturesSeine; import org.nuiton.topia.persistence.TopiaException; @@ -47,7 +52,7 @@ import java.util.Set; public abstract class DataSourceMigrationForVersion_4_0_1 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_1(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_1.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_1.getVersion(), callBack, scriptSuffix); } protected abstract void removeForeignKeys(TopiaSqlSupport tx, List<String> queries); diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java index e10115b..9f1cccf 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_2.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_2.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_2 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_2(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_2.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_2.getVersion(), callBack, scriptSuffix); } public static class H2DataSourceMigrationForVersion extends DataSourceMigrationForVersion_4_0_2 { diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java index 2c5be0b..1a2a7a5 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_4.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_4.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.TopiaException; import org.nuiton.topia.persistence.support.TopiaSqlSupport; @@ -36,7 +41,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_4 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_4(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_4.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_4.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java similarity index 85% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java index dbe53fc..a7a561c 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC2.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC2.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.sql.PreparedStatement; @@ -40,7 +45,7 @@ import java.util.Set; public class DataSourceMigrationForVersion_4_0_RC2 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC2(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_RC2.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_RC2.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java similarity index 95% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java index a104685..7eee5b2 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC3.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC3.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.TopiaException; @@ -49,7 +54,7 @@ public abstract class DataSourceMigrationForVersion_4_0_RC3 extends AbstractObse private static final Log log = LogFactory.getLog(DataSourceMigrationForVersion_4_0_RC3.class); public DataSourceMigrationForVersion_4_0_RC3(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_RC3.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_RC3.getVersion(), callBack, scriptSuffix); } protected abstract void addMissingForeignKeys(TopiaSqlSupport tx, List<String> queries) throws TopiaException; diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java index b7fc613..02da08e 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC4.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC4.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_0_RC4 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC4(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_RC4.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_RC4.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java similarity index 84% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java index 3f5d6c3..49479ee 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC6.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC6.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_RC6 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC6(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_RC6.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_RC6.getVersion(), callBack, scriptSuffix); } protected abstract void removeForeignKeyOnGearFseFeaturesMeasurementSeine(TopiaSqlSupport tx, List<String> queries); diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java similarity index 81% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java index 7b0b3f7..37a85f2 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_0_RC7.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_0_RC7.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public abstract class DataSourceMigrationForVersion_4_0_RC7 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_0_RC7(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_0_RC7.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_0_RC7.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java index f8a3ccc..e5fd8bd 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_900.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_900.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -34,7 +39,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_900 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_900(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_900.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_900.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java index 7a5b699..35a647c 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_901.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_901.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -34,7 +39,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_901 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_901(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_901.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_901.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java index 63d05f7..94b3363 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_902.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_902.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -34,7 +39,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_902 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_902(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_902.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_902.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java similarity index 80% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java index 055bc2e..dd93904 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_903.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_903.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -34,7 +39,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_903 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_903(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_903.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_903.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java index 607b8aa..33cf160 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_4_904.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_4_904.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -34,7 +39,7 @@ import java.util.List; public class DataSourceMigrationForVersion_4_904 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_4_904(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_4_904.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_4_904.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java similarity index 79% rename from observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java rename to observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java index c0ac8b8..8800bb2 100644 --- a/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/DataSourceMigrationForVersion_5_0.java +++ b/observe-entities-migration/src/main/java/fr/ird/observe/entities/migration/versions/DataSourceMigrationForVersion_5_0.java @@ -1,4 +1,4 @@ -package fr.ird.observe.entities.migration; +package fr.ird.observe.entities.migration.versions; /* * #%L @@ -22,6 +22,11 @@ package fr.ird.observe.entities.migration; * #L% */ +import fr.ird.observe.entities.migration.AbstractDataSourceMigration; +import fr.ird.observe.entities.migration.AbstractObserveMigrationCallBack; +import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl; +import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.nuiton.topia.persistence.support.TopiaSqlSupport; import java.util.List; @@ -35,7 +40,7 @@ import java.util.List; public class DataSourceMigrationForVersion_5_0 extends AbstractObserveMigrationCallBack { public DataSourceMigrationForVersion_5_0(AbstractDataSourceMigration callBack, String scriptSuffix) { - super(MigrationVersions.V_5_0.getVersion(), callBack, scriptSuffix); + super(ObserveMigrationConfigurationProviderImpl.ObserveMigrationVersions.V_5_0.getVersion(), callBack, scriptSuffix); } @Override diff --git a/observe-entities-migration/src/main/resources/META-INF/services/fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider b/observe-entities-migration/src/main/resources/META-INF/services/fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider new file mode 100644 index 0000000..c1819ef --- /dev/null +++ b/observe-entities-migration/src/main/resources/META-INF/services/fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider @@ -0,0 +1 @@ +fr.ird.observe.entities.migration.ObserveMigrationConfigurationProviderImpl \ No newline at end of file diff --git a/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java b/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java index ede5b24..558667f 100644 --- a/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java +++ b/observe-entities-migration/src/test/java/fr/ird/observe/entities/migration/ObserveMigrationCallBackForVersionResolverTest.java @@ -41,7 +41,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { = new ObserveMigrationCallBackForVersionResolver("H2"); Assert.assertNotNull(resolver); - for (Version version : MigrationVersions.getAvailableVersions()) { + for (Version version : ObserveMigrationConfigurationProvider.get().getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } @@ -52,7 +52,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { ObserveMigrationCallBackForVersionResolver resolver = new ObserveMigrationCallBackForVersionResolver("PG"); Assert.assertNotNull(resolver); - for (Version version : MigrationVersions.getAvailableVersions()) { + for (Version version : ObserveMigrationConfigurationProvider.get().getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } @@ -63,7 +63,7 @@ public class ObserveMigrationCallBackForVersionResolverTest { ObserveMigrationCallBackForVersionResolver resolver = new ObserveMigrationCallBackForVersionResolver("Dummy"); Assert.assertNotNull(resolver); - for (Version version : MigrationVersions.getAvailableVersions()) { + for (Version version : ObserveMigrationConfigurationProvider.get().getAvailableVersions()) { Class<? extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion> callBack = resolver.getCallBack(version); Assert.assertNotNull(callBack); } diff --git a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java index e2ea4da..cea6a7c 100644 --- a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java +++ b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaApplicationContext.java @@ -24,6 +24,7 @@ package fr.ird.observe; import com.google.common.collect.ImmutableSet; import fr.ird.observe.entities.Entities; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider; import fr.ird.observe.entities.migration.ObserveMigrationEngine; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -80,6 +81,7 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat protected final String authenticationToken; protected final TopiaMetadataModelSupport topiaMetadataModelSupport; protected final TopiaSqlTablesFactory topiaSqlTablesFactory; + protected final ObserveMigrationConfigurationProvider observeMigrationConfigurationProvider; protected TopiaSqlTables tripSeineTables; protected TopiaSqlTables tripLonglineTables; protected TopiaSqlTables referentialTables; @@ -89,6 +91,7 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat this.authenticationToken = UUID.randomUUID().toString(); this.topiaMetadataModelSupport = new TopiaMetadataModelSupportImpl("fr.ird.observe", "Observe"); this.topiaSqlTablesFactory = new TopiaSqlTablesFactory(getMetadataModel(), this); + this.observeMigrationConfigurationProvider = ObserveMigrationConfigurationProvider.get(); } @Override @@ -104,6 +107,10 @@ public class ObserveTopiaApplicationContext extends AbstractObserveTopiaApplicat this.open = open; } + public ObserveMigrationConfigurationProvider getObserveMigrationConfigurationProvider() { + return observeMigrationConfigurationProvider; + } + public ObserveMigrationEngine getMigrationService() { return getServices(ObserveMigrationEngine.class).get(MIGRATION_SERVICE_NAME); } diff --git a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaConfigurationFactory.java b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaConfigurationFactory.java index ca7b1cb..5d65438 100644 --- a/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaConfigurationFactory.java +++ b/observe-entities/src/main/java/fr/ird/observe/ObserveTopiaConfigurationFactory.java @@ -23,9 +23,8 @@ package fr.ird.observe; */ import com.google.common.collect.ImmutableMap; -import fr.ird.observe.entities.migration.H2DataSourceMigration; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider; import fr.ird.observe.entities.migration.ObserveMigrationEngine; -import fr.ird.observe.entities.migration.PGDataSourceMigration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.jdbc.JdbcConfiguration; @@ -47,39 +46,39 @@ public class ObserveTopiaConfigurationFactory { /** l'url d'acces a la base locale */ public static final String H2_LOCAL_URL = "jdbc:h2:file:%s;" + - // on peut aussi utiliser file, socket - "FILE_LOCK=file;" + - //1 or 2 is needed to restore avec crash - // 0: logging is disabled (faster), - // 1: logging of the data is enabled, but logging of the index - // changes is disabled (default), 2: logging of both data and index - // changes are enabled - "LOG=0;" + - // on peut aussi utiliser hsqldb, mysql ou postgresql - "MODE=postgresql;" + - //"MODE=hsqldb;" + - // Sets the default lock timeout (in milliseconds) in this - // database that is used for the new sessions. - "DEFAULT_LOCK_TIMEOUT=100;" + - // -1: the database is never closed until the close delay is set to - // some other rev or SHUTDOWN is called., 0: no delay (default; the - // database is closed if the last connection to it is closed)., n: - // the database is left open for n second after the last connection - // is closed. - "DB_CLOSE_DELAY=0;" + - // 0: no locking (should only be used for testing), - // 1: table level locking (default), - // 2: table level locking with garbage collection (if the - // application does not close all connections). - // LOCK_MODE 3 (READ_COMMITTED). Table level locking, but only when - // writing (no read locks). - "LOCK_MODE=3;" + - // Levels: 0=off, 1=error, 2=info, 3=debug. - "TRACE_LEVEL_FILE=0;" + - // on system.out: 0=off, 1=error, 2=info, 3=debug. - "TRACE_LEVEL_SYSTEM_OUT=0;" + - // maximumn cache to improve performance... - "CACHE_SIZE=65536"; + // on peut aussi utiliser file, socket + "FILE_LOCK=file;" + + //1 or 2 is needed to restore avec crash + // 0: logging is disabled (faster), + // 1: logging of the data is enabled, but logging of the index + // changes is disabled (default), 2: logging of both data and index + // changes are enabled + "LOG=0;" + + // on peut aussi utiliser hsqldb, mysql ou postgresql + "MODE=postgresql;" + + //"MODE=hsqldb;" + + // Sets the default lock timeout (in milliseconds) in this + // database that is used for the new sessions. + "DEFAULT_LOCK_TIMEOUT=100;" + + // -1: the database is never closed until the close delay is set to + // some other rev or SHUTDOWN is called., 0: no delay (default; the + // database is closed if the last connection to it is closed)., n: + // the database is left open for n second after the last connection + // is closed. + "DB_CLOSE_DELAY=0;" + + // 0: no locking (should only be used for testing), + // 1: table level locking (default), + // 2: table level locking with garbage collection (if the + // application does not close all connections). + // LOCK_MODE 3 (READ_COMMITTED). Table level locking, but only when + // writing (no read locks). + "LOCK_MODE=3;" + + // Levels: 0=off, 1=error, 2=info, 3=debug. + "TRACE_LEVEL_FILE=0;" + + // on system.out: 0=off, 1=error, 2=info, 3=debug. + "TRACE_LEVEL_SYSTEM_OUT=0;" + + // maximumn cache to improve performance... + "CACHE_SIZE=65536"; protected static final JdbcConfigurationBuilder JDBC_CONFIGURATION_BUILDER = new JdbcConfigurationBuilder(); @@ -94,7 +93,7 @@ public class ObserveTopiaConfigurationFactory { ObserveTopiaConfiguration topiaConfiguration = createTopiaConfiguration(jdbcConfiguration, initSchema, - showMigrationSql, + showMigrationSql, showMigrationProgression, false); @@ -120,7 +119,7 @@ public class ObserveTopiaConfigurationFactory { ObserveTopiaConfiguration topiaConfiguration = createTopiaConfiguration(jdbcConfiguration, initSchema, - showMigrationSql, + showMigrationSql, showMigrationProgression, true); @@ -147,7 +146,7 @@ public class ObserveTopiaConfigurationFactory { } ImmutableMap<String, String> migrationServiceConfiguration = ImmutableMap.of( - ObserveMigrationEngine.MIGRATION_CALLBACK, h2Configuration ? H2DataSourceMigration.class.getName() : PGDataSourceMigration.class.getName(), + ObserveMigrationEngine.MIGRATION_CALLBACK, ObserveMigrationConfigurationProvider.get().getMigrationClassBack(h2Configuration).getName(), ObserveMigrationEngine.MIGRATION_SHOW_PROGRESSION, String.valueOf(showMigrationProgression), ObserveMigrationEngine.MIGRATION_SHOW_SQL, String.valueOf(showMigrationSql) ); diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java deleted file mode 100644 index a6e8f06..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/MigrationVersions.java +++ /dev/null @@ -1,87 +0,0 @@ -package fr.ird.observe.entities.migration; - -import org.nuiton.version.Version; -import org.nuiton.version.Versions; - -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * Created on 01/08/16. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 5.0 - */ -public enum MigrationVersions { - - V_3_0("3.0", false), - V_3_1("3.1"), - V_3_5("3.5"), - V_3_7("3.7"), - V_3_8("3.8"), - V_3_9("3.9"), - V_3_10("3.10"), - V_3_11("3.11"), - V_3_12("3.12"), - V_3_14("3.14"), - V_3_15("3.15"), - V_3_16("3.16"), - V_4_0_RC2("4.0-RC2"), - V_4_0_RC3("4.0-RC3"), - V_4_0_RC4("4.0-RC4"), - V_4_0_RC6("4.0-RC6"), - V_4_0_RC7("4.0-RC7"), - V_4_0("4.0"), - V_4_0_1("4.0.1"), - V_4_0_2("4.0.2"), - V_4_0_4("4.0.4"), - V_4_900("4.900"), - V_4_901("4.901"), - V_4_902("4.902"), - V_4_903("4.903"), - V_4_904("4.904"), - - // FIXME A utiliser en version final 5.0 - V_5_0("5.0", false); - - private static Version[] AVAILABLE_VERSIONS; - - private final Version version; - private final boolean canApply; - - MigrationVersions(String versionAsString, boolean canApply) { - this.version = Versions.valueOf(versionAsString); - this.canApply = canApply; - } - - MigrationVersions(String versionAsString) { - this(versionAsString, true); - } - - public Version getVersion() { - return version; - } - - public static Version[] getAvailableVersions() { - if (AVAILABLE_VERSIONS == null) { - Set<Version> result = new LinkedHashSet<>(); - for (MigrationVersions migrationVersions : values()) { - if (migrationVersions.canApply) { - result.add(migrationVersions.getVersion()); - } - } - AVAILABLE_VERSIONS = result.toArray(new Version[result.size()]); - } - return AVAILABLE_VERSIONS; - } - - public static Version getLastVersion() { - Version[] values = getAvailableVersions(); - int lastIndex = values.length - 1; - return values[lastIndex]; - } - - public static Version getMinimumVersion() { - return V_3_0.getVersion(); - } -} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProvider.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProvider.java new file mode 100644 index 0000000..f02999f --- /dev/null +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationConfigurationProvider.java @@ -0,0 +1,40 @@ +package fr.ird.observe.entities.migration; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import org.nuiton.topia.migration.TopiaMigrationCallbackByClass; +import org.nuiton.version.Version; + +import java.util.Iterator; +import java.util.ServiceLoader; + +/** + * Created on 01/08/16. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 5.0 + */ +public abstract class ObserveMigrationConfigurationProvider { + + private static ObserveMigrationConfigurationProvider INSTANCE; + + public abstract Version[] getAvailableVersions(); + + public abstract Version getLastVersion(); + + public abstract Version getMinimumVersion(); + + public abstract ImmutableList<Version> getVersionsAfter(Version current); + + public abstract Class<? extends TopiaMigrationCallbackByClass> getMigrationClassBack(boolean h2); + + public static ObserveMigrationConfigurationProvider get() { + if (INSTANCE == null) { + Iterator<ObserveMigrationConfigurationProvider> iterator = ServiceLoader.load(ObserveMigrationConfigurationProvider.class).iterator(); + Preconditions.checkArgument(iterator.hasNext(), "could not find migration versions provider"); + INSTANCE = iterator.next(); + } + return INSTANCE; + } + +} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationEngine.java b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationEngine.java index f1d5d49..33c0c0d 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationEngine.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/migration/ObserveMigrationEngine.java @@ -22,14 +22,10 @@ package fr.ird.observe.entities.migration; * #L% */ -import fr.ird.observe.ObserveTopiaApplicationContext; import org.nuiton.topia.migration.TopiaMigrationEngine; import org.nuiton.topia.migration.mappings.TMSVersionHibernateDao; -import org.nuiton.topia.persistence.TopiaApplicationContext; import org.nuiton.topia.persistence.util.TopiaUtil; -import java.util.Map; - /** * Created on 21/08/15. * @@ -37,15 +33,10 @@ import java.util.Map; */ public class ObserveMigrationEngine extends TopiaMigrationEngine { - @Override - public void initTopiaService(TopiaApplicationContext topiaApplicationContext, Map<String, String> serviceConfiguration) { - super.initTopiaService(topiaApplicationContext, serviceConfiguration); - ((AbstractDataSourceMigration) callback).setTopiaApplicationContext((ObserveTopiaApplicationContext) topiaApplicationContext); - } - - public void createSchemaIfNotExit() { + public void createSchemaIfNotExist() { if (TopiaUtil.isSchemaEmpty(versionConfiguration)) { TMSVersionHibernateDao.createTMSSchema(versionConfiguration); } } + } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java index d5cfa7b..95fc070 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/DataSourceServiceTopia.java @@ -30,8 +30,7 @@ import com.google.common.collect.Sets; import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaConfiguration; import fr.ird.observe.ObserveTopiaConfigurationFactory; -import fr.ird.observe.entities.migration.AbstractDataSourceMigration; -import fr.ird.observe.entities.migration.MigrationVersions; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider; import fr.ird.observe.services.ObserveJdbcHelper; import fr.ird.observe.services.ObserveSecurityHelper; import fr.ird.observe.services.ObserveServiceTopia; @@ -184,7 +183,7 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS if (((ObserveDataSourceConfigurationTopiaSupport) dataSourceConfiguration).isH2Database()) { topiaApplicationContext.executeSqlStatements(importDatabase); - topiaApplicationContext.getMigrationService().createSchemaIfNotExit(); + topiaApplicationContext.getMigrationService().createSchemaIfNotExist(); topiaApplicationContext.getMigrationService().runSchemaMigration(); } else { // base postgre @@ -201,14 +200,14 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS ObserveTopiaApplicationContext temporaryTopiaApplicationContext = ObserveTopiaApplicationContextFactory.createTopiaApplicationContext(temporaryConfiguration, false); temporaryTopiaApplicationContext.executeSqlStatements(importDatabase); - temporaryTopiaApplicationContext.getMigrationService().createSchemaIfNotExit(); + temporaryTopiaApplicationContext.getMigrationService().createSchemaIfNotExist(); temporaryTopiaApplicationContext.getMigrationService().runSchemaMigration(); SqlScriptProducerService dumpProducerService = serviceContext.newService(temporaryConfiguration, SqlScriptProducerService.class); SqlScriptProducerRequest request = SqlScriptProducerRequest.forPostgres().addSchema().addReferential().addAllData(); byte[] dump = dumpProducerService.produceSqlScript(request); topiaApplicationContext.executeSqlStatements(dump); - topiaApplicationContext.getMigrationService().createSchemaIfNotExit(); + topiaApplicationContext.getMigrationService().createSchemaIfNotExist(); topiaApplicationContext.getMigrationService().runSchemaMigration(); temporaryTopiaApplicationContext.close(); @@ -582,14 +581,15 @@ public class DataSourceServiceTopia extends ObserveServiceTopia implements DataS "write data : " + writeData + "."); } + ObserveMigrationConfigurationProvider observeMigrationConfigurationProvider = ObserveMigrationConfigurationProvider.get(); ObserveDataSourceInformation information = new ObserveDataSourceInformation( readReferential, writeReferential, readData, writeData, - MigrationVersions.getMinimumVersion(), + observeMigrationConfigurationProvider.getMinimumVersion(), version, - AbstractDataSourceMigration.getVersionsAfter(version)); + observeMigrationConfigurationProvider.getVersionsAfter(version)); return information; } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java b/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java index 614742d..5626b95 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/DataSourceResource.java @@ -26,7 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Strings; import fr.ird.observe.ObserveTopiaApplicationContext; import fr.ird.observe.ObserveTopiaPersistenceContext; -import fr.ird.observe.entities.migration.MigrationVersions; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; import fr.ird.observe.services.configuration.ObserveDataSourceConnection; import fr.ird.observe.services.dto.DataSourceCreateConfigurationDto; @@ -233,7 +233,7 @@ public class DataSourceResource implements TestRule { configurationTopiaH2.setDirectory(localDbFile); configurationTopiaH2.setDbName("obstuna"); configurationTopiaH2.setAutoMigrate(true); - configurationTopiaH2.setModelVersion(MigrationVersions.getLastVersion()); + configurationTopiaH2.setModelVersion(ObserveMigrationConfigurationProvider.get().getLastVersion()); return configurationTopiaH2; } diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java index da3e600..9ac5562 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/DataSourceServiceTopiaTest.java @@ -24,7 +24,6 @@ package fr.ird.observe.services.service; import com.google.common.collect.ImmutableSet; import fr.ird.observe.ObserveTopiaApplicationContext; -import fr.ird.observe.entities.migration.MigrationVersions; import fr.ird.observe.services.ObserveTopiaApplicationContextFactory; import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationTopiaH2; import fr.ird.observe.services.configuration.ObserveDataSourceConnection; @@ -175,7 +174,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { @Test public void testCreateDataSourceFromImportDatabase() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException, BabModelVersionException { - String scriptPath = applicationContextResource.getScriptPath("referentiel", MigrationVersions.V_4_0.getVersion()); + String scriptPath = applicationContextResource.getScriptPath("referentiel", ObserveFixtures.FIRST_TEST_DB_VERSION); byte[] dumpContent = TestHelper.getResourceContent(scriptPath); @@ -193,7 +192,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { public void testCreateDataSourceFromImportReferential() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { // On crée un base qui fait office de source de référentiel - String scriptPath = applicationContextResource.getScriptPath("referentiel", MigrationVersions.V_4_0_1.getVersion()); + String scriptPath = applicationContextResource.getScriptPath("referentiel", ObserveFixtures.FIRST_TEST_DB_VERSION); dataSourceResource.createDataSourceFromScript(scriptPath); ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = dataSourceResource.getDataSourceConfiguration(); @@ -217,7 +216,7 @@ public class DataSourceServiceTopiaTest extends AbstractServiceTopiaTest { public void testCreateDataSourceFromImportReferentialAndData() throws IOException, IncompatibleDataSourceCreateConfigurationException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, DatabaseConnexionNotAuthorizedException, DatabaseNotFoundException { // On crée un base qui fait office de source de référentiel et de source de données (uniquement des données seine) - String scriptPath = applicationContextResource.getScriptPath("dataForTestSeine", MigrationVersions.V_4_0_1.getVersion()); + String scriptPath = applicationContextResource.getScriptPath("dataForTestSeine", ObserveFixtures.FIRST_TEST_DB_VERSION); dataSourceResource.createDataSourceFromScript(scriptPath); ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = dataSourceResource.getDataSourceConfiguration(); diff --git a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java index a209ddd..39a3e13 100644 --- a/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java +++ b/observe-services-topia/src/test/java/fr/ird/observe/services/service/RigthTest.java @@ -22,7 +22,7 @@ package fr.ird.observe.services.service; * #L% */ -import fr.ird.observe.entities.migration.MigrationVersions; +import fr.ird.observe.entities.migration.ObserveMigrationConfigurationProvider; import fr.ird.observe.services.ObserveService; import fr.ird.observe.services.ObserveServiceContextTopia; import fr.ird.observe.services.ObserveServiceContextTopiaTaiste; @@ -51,7 +51,7 @@ import java.util.Locale; * FIXME Ca sert à quoi ? et je comprends pas le mot rigth ? * * @author Sylvain Bavencoff - bavencoff@codelutin.com - * FIXME IT tests + * FIXME IT tests */ @Ignore public class RigthTest { @@ -91,7 +91,7 @@ public class RigthTest { configurationTopiaPG.setUsername(login); configurationTopiaPG.setPassword('a'); configurationTopiaPG.setAutoMigrate(true); - configurationTopiaPG.setModelVersion(MigrationVersions.getLastVersion()); + configurationTopiaPG.setModelVersion(ObserveMigrationConfigurationProvider.get().getLastVersion()); return configurationTopiaPG; diff --git a/observe-test-data/src/main/java/fr/ird/observe/test/ObserveFixtures.java b/observe-test-data/src/main/java/fr/ird/observe/test/ObserveFixtures.java index 5d9236e..2d3a762 100644 --- a/observe-test-data/src/main/java/fr/ird/observe/test/ObserveFixtures.java +++ b/observe-test-data/src/main/java/fr/ird/observe/test/ObserveFixtures.java @@ -25,6 +25,8 @@ package fr.ird.observe.test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.apache.commons.lang3.mutable.MutableLong; +import org.nuiton.version.Version; +import org.nuiton.version.Versions; import java.util.Map; import java.util.TreeMap; @@ -36,6 +38,7 @@ import java.util.TreeMap; */ public class ObserveFixtures { + public static final Version FIRST_TEST_DB_VERSION = Versions.valueOf("4.0.1"); public static final String PREVIOUS_DEFAULT_VERSION = "4.0.1"; public static final String DEFAULT_VERSION = "4.904"; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit e4c75280980321b0a9e7981cc4fe7bf9f95ac828 Author: Tony CHEMIT <chemit@codelutin.com> Date: Mon Aug 1 17:15:45 2016 +0200 Revue du code relatif au gps et suppression du code en double (entités vs service model) --- .../swing/decoration/DecoratorService.java | 6 +- .../ActivitySimpleSpeedDtoValidator.java | 9 +- .../validators/ActivitySpeedDtoValidator.java | 9 +- .../observe/ObserveSwingApplicationContext.java | 7 +- observe-entities-migration/pom.xml | 4 + observe-entities/pom.xml | 4 - .../observe/entities}/gps/CoordinateHelper.java | 2 +- .../java/fr/ird/observe/entities/gps/GPSPoint.java | 120 ------- .../fr/ird/observe/entities/gps/GPSPointImpl.java | 79 ----- .../ird/observe/entities/gps/GPSPointInterval.java | 155 --------- .../observe/entities/gps/GPSPointIntervalImpl.java | 84 ----- .../java/fr/ird/observe/entities/gps/GPSRoute.java | 276 ---------------- .../fr/ird/observe/entities/gps/GPSRouteImpl.java | 144 --------- .../fr/ird/observe/entities/gps/GpsPoints.java | 177 ---------- .../entities/longline/ActivityLonglineImpl.java | 2 +- .../observe/entities/longline/SetLonglineImpl.java | 2 +- .../observe/entities/referentiel/HarbourImpl.java | 2 +- .../observe/entities/seine/ActivitySeineImpl.java | 2 +- .../main/java/fr/ird/type/CoordinateHelper.java | 55 ---- .../util/{gps/GpsPoints.java => GPSPoint.java} | 137 +++++--- .../main/java/fr/ird/observe/util/gps/GPSAble.java | 59 ---- .../fr/ird/observe/util/gps/GPSFileReader.java | 356 --------------------- .../java/fr/ird/observe/util/gps/GPSPoint.java | 118 ------- .../java/fr/ird/observe/util/gps/GPSPointImpl.java | 76 ----- .../fr/ird/observe/util/gps/GPSPointInterval.java | 155 --------- .../ird/observe/util/gps/GPSPointIntervalImpl.java | 86 ----- .../java/fr/ird/observe/util/gps/GPSRoute.java | 276 ---------------- .../java/fr/ird/observe/util/gps/GPSRouteImpl.java | 144 --------- .../java/fr/ird/observe/util/gps/GPSService.java | 115 ------- observe-services-topia-validation/pom.xml | 5 + .../validators/ActivitySimpleSpeedValidator.java | 9 +- .../validators/ActivitySpeedValidator.java | 9 +- .../longline/ActivityLonglineServiceTopia.java | 2 +- .../service/seine/ActivitySeineServiceTopia.java | 2 +- 34 files changed, 128 insertions(+), 2560 deletions(-) diff --git a/observe-application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/DecoratorService.java b/observe-application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/DecoratorService.java index 0e4c0a6..a349c6c 100644 --- a/observe-application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/DecoratorService.java +++ b/observe-application-swing-decoration/src/main/java/fr/ird/observe/application/swing/decoration/DecoratorService.java @@ -121,8 +121,7 @@ import fr.ird.observe.services.dto.seine.SetSeineDto; import fr.ird.observe.services.dto.seine.TargetLengthDto; import fr.ird.observe.services.dto.seine.TransmittingBuoyDto; import fr.ird.observe.services.dto.seine.TripSeineDto; -import fr.ird.observe.util.gps.GPSPoint; -import fr.ird.observe.util.gps.GPSPointInterval; +import fr.ird.observe.util.GPSPoint; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -584,9 +583,6 @@ public class DecoratorService extends DecoratorProvider { registerObserveDecorator("gpsPoint-gps", GPSPoint.class, t("observe.common.gps.gpsPoint")); - registerObserveDecorator(GPSPointInterval.class, - "gpsPointInterval-gps", - t("observe.common.gps.gpsPointInterval")); registerObserveDecorator(GPSPoint.class, "${time}$td/%1$tm/%1$tY %1$tH:%1$tM##${latitude}$s##${longitude}$s", diff --git a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySimpleSpeedDtoValidator.java b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySimpleSpeedDtoValidator.java index 4b6367d..73c8aee 100644 --- a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySimpleSpeedDtoValidator.java +++ b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySimpleSpeedDtoValidator.java @@ -28,8 +28,7 @@ import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.ActivitySeineStubDto; import fr.ird.observe.services.dto.seine.RouteDto; -import fr.ird.observe.util.gps.GPSPoint; -import fr.ird.observe.util.gps.GpsPoints; +import fr.ird.observe.util.GPSPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -140,10 +139,10 @@ public class ActivitySimpleSpeedDtoValidator extends FieldValidatorSupport { return; } - GPSPoint currentPoint = GpsPoints.newPoint(route, activity); - GPSPoint previousPoint = GpsPoints.newPoint(route, previousActivity); + GPSPoint currentPoint = GPSPoint.newPoint(route, activity); + GPSPoint previousPoint = GPSPoint.newPoint(route, previousActivity); - float computedSpeed = GpsPoints.getSpeed(previousPoint, currentPoint); + float computedSpeed = previousPoint.getSpeed(currentPoint); if (log.isDebugEnabled()) { log.debug("Speed computed between previous activity point " + decorate(previousPoint) + " to current activity point " + decorate(currentPoint) + ", speed is : " + computedSpeed); diff --git a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySpeedDtoValidator.java b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySpeedDtoValidator.java index 0864aaa..269ab28 100644 --- a/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySpeedDtoValidator.java +++ b/observe-application-swing-validation/src/main/java/fr/ird/observe/application/swing/validation/validators/ActivitySpeedDtoValidator.java @@ -27,8 +27,7 @@ import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.services.dto.seine.ActivitySeineStubDto; import fr.ird.observe.services.dto.seine.RouteDto; -import fr.ird.observe.util.gps.GPSPoint; -import fr.ird.observe.util.gps.GpsPoints; +import fr.ird.observe.util.GPSPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.xwork2.field.CollectionFieldExpressionValidator; @@ -137,10 +136,10 @@ public class ActivitySpeedDtoValidator extends FieldValidatorSupport { return true; } - GPSPoint previousPoint = GpsPoints.newPoint(route, previousActivity); - GPSPoint currentPoint = GpsPoints.newPoint(route, currentActivity); + GPSPoint previousPoint = GPSPoint.newPoint(route, previousActivity); + GPSPoint currentPoint = GPSPoint.newPoint(route, currentActivity); - float computedSpeed = GpsPoints.getSpeed(previousPoint, currentPoint); + float computedSpeed = previousPoint.getSpeed(currentPoint); if (LOG.isDebugEnabled()) { LOG.debug("Speed computed between previous activity point " + decorate(previousPoint) + " to current activity point " + decorate(currentPoint) + ", speed is : " + computedSpeed); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java index daad9ff..739a591 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ObserveSwingApplicationContext.java @@ -24,6 +24,7 @@ package fr.ird.observe; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.configuration.ObserveSwingApplicationConfig; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; @@ -55,7 +56,6 @@ import fr.ird.observe.services.service.seine.FloatingObjectService; import fr.ird.observe.services.service.seine.RouteService; import fr.ird.observe.services.service.seine.SetSeineService; import fr.ird.observe.services.service.seine.TripSeineService; -import fr.ird.observe.application.swing.decoration.DecoratorService; import fr.ird.observe.ui.ObserveMainUI; import fr.ird.observe.ui.ObserveMainUIHandler; import fr.ird.observe.ui.ObserveUIMode; @@ -81,7 +81,6 @@ import fr.ird.observe.ui.actions.shared.SelectNodeUIAction; import fr.ird.observe.ui.actions.shared.SelectOpenNodeUIAction; import fr.ird.observe.ui.content.ContentUI; import fr.ird.observe.ui.tree.ObserveTreeHelper; -import fr.ird.observe.util.gps.GPSService; import fr.ird.observe.validation.ObserveSwingValidator; import fr.ird.observe.validation.ValidationContext; import jaxx.runtime.JAXXUtil; @@ -166,10 +165,6 @@ public class ObserveSwingApplicationContext extends DefaultApplicationContext im public static final JAXXContextEntryDef<ObserveSwingBinderService> BINDER_SERVICE_ENTRY_DEF = JAXXUtil.newContextEntryDef(ObserveSwingBinderService.class); - /** the jaxx context entry to store the gps service */ - public static final JAXXContextEntryDef<GPSService> GPS_SERVICE_ENTRY_DEF = - JAXXUtil.newContextEntryDef(GPSService.class); - /** the jaxx context entry to store the data service */ public static final JAXXContextEntryDef<DataContext> DATA_CONTEXT_ENTRY_DEF = JAXXUtil.newContextEntryDef(DataContext.class); diff --git a/observe-entities-migration/pom.xml b/observe-entities-migration/pom.xml index 503330d..6bf68d1 100644 --- a/observe-entities-migration/pom.xml +++ b/observe-entities-migration/pom.xml @@ -61,6 +61,10 @@ <artifactId>commons-logging</artifactId> </dependency> <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> diff --git a/observe-entities/pom.xml b/observe-entities/pom.xml index c0eefb2..37514f9 100644 --- a/observe-entities/pom.xml +++ b/observe-entities/pom.xml @@ -69,10 +69,6 @@ <artifactId>commons-logging</artifactId> </dependency> <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/CoordinateHelper.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/CoordinateHelper.java similarity index 97% rename from observe-services-model/src/main/java/fr/ird/observe/util/gps/CoordinateHelper.java rename to observe-entities/src/main/java/fr/ird/observe/entities/gps/CoordinateHelper.java index 10be892..7bd7c46 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/CoordinateHelper.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/gps/CoordinateHelper.java @@ -19,7 +19,7 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -package fr.ird.observe.util.gps; +package fr.ird.observe.entities.gps; /** * Helper to deal with coordinates. diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPoint.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPoint.java deleted file mode 100644 index 47cd525..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPoint.java +++ /dev/null @@ -1,120 +0,0 @@ -package fr.ird.observe.entities.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.entities.GPSAble; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Date; - -public abstract class GPSPoint implements GPSAble, Serializable { - - private static final long serialVersionUID = 3761972876361753443L; - - public static final String PROPERTY_LATITUDE = "latitude"; - - public static final String PROPERTY_LONGITUDE = "longitude"; - - public static final String PROPERTY_VITESSE = "vitesse"; - - public static final String PROPERTY_TIME = "time"; - - protected Float latitude; - - protected Float longitude; - - protected Float vitesse; - - protected Date time; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public Float getLatitude() { - return latitude; - } - - public void setLatitude(Float latitude) { - Float oldValue = getLatitude(); - this.latitude = latitude; - firePropertyChange(PROPERTY_LATITUDE, oldValue, latitude); - } - - public Float getLongitude() { - return longitude; - } - - public void setLongitude(Float longitude) { - Float oldValue = getLongitude(); - this.longitude = longitude; - firePropertyChange(PROPERTY_LONGITUDE, oldValue, longitude); - } - - public Float getVitesse() { - return vitesse; - } - - public void setVitesse(Float vitesse) { - Float oldValue = getVitesse(); - this.vitesse = vitesse; - firePropertyChange(PROPERTY_VITESSE, oldValue, vitesse); - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - Date oldValue = getTime(); - this.time = time; - firePropertyChange(PROPERTY_TIME, oldValue, time); - } - - public abstract boolean isSameLocation(GPSPoint point); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - -} //GPSPoint diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointImpl.java deleted file mode 100644 index 1bd45a4..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.entities.gps; - -import fr.ird.observe.entities.GPSAble; -import fr.ird.type.CoordinateHelper; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSPointImpl extends GPSPoint { - - private static final long serialVersionUID = 1L; - - public GPSPointImpl() { - } - - public GPSPointImpl(GPSAble activity) { - setLongitude(activity.getLongitude()); - setLatitude(activity.getLatitude()); - setTime(activity.getTime()); - } - - @Override - public Integer getQuadrant() { - Integer result = CoordinateHelper.getQuadrant(longitude, latitude); - return result; -// if (latitude == null || longitude == null) { -// return null; -// } -// int result; -// -// if (latitude > 0) { -// result = longitude > 0 ? 1 : 4; -//// result = longitude > 0 ? 1 : 3; -// } else { -// result = longitude > 0 ? 2 : 3; -//// result = longitude > 0 ? 1 : 3; -// } -// return result; - } - - @Override - public void setQuadrant(Integer quadrant) { - // non utilisé - } - - @Override - public boolean isSameLocation(GPSPoint point) { - float latitude = getLatitude() == null ? 0f : getLatitude(); - float longitude = getLongitude() == null ? 0f : getLongitude(); - - float latitude1 = point.getLatitude() == null ? 0f : point.getLatitude(); - float longitude1 = point.getLongitude() == null ? 0f : point.getLongitude(); - - return latitude == latitude1 && longitude == longitude1; - } - -} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointInterval.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointInterval.java deleted file mode 100644 index e6e6529..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointInterval.java +++ /dev/null @@ -1,155 +0,0 @@ -package fr.ird.observe.entities.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Collection; -import java.util.List; - -public abstract class GPSPointInterval implements Serializable { - - private static final long serialVersionUID = 7377852988997002340L; - - public static final String PROPERTY_POINT = "point"; - - protected List<GPSPoint> point; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public GPSPoint getPoint(int index) { - GPSPoint o = getChild(point, index); - return o; - } - - public boolean isPointEmpty() { - return point == null || point.isEmpty(); - } - - public int sizePoint() { - return point == null ? 0 : point.size(); - } - - public void addPoint(GPSPoint point) { - getPoint().add(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public void addAllPoint(Collection<GPSPoint> point) { - getPoint().addAll(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public boolean removePoint(GPSPoint point) { - boolean removed = getPoint().remove(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean removeAllPoint(Collection<GPSPoint> point) { - boolean removed = getPoint().removeAll(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean containsPoint(GPSPoint point) { - boolean contains = getPoint().contains(point); - return contains; - } - - public boolean containsAllPoint(Collection<GPSPoint> point) { - boolean contains = getPoint().containsAll(point); - return contains; - } - - public List<GPSPoint> getPoint() { - return point; - } - - public void setPoint(List<GPSPoint> point) { - List<GPSPoint> oldValue = getPoint(); - this.point = point; - firePropertyChange(PROPERTY_POINT, oldValue, point); - } - - public abstract GPSPoint getFirstPoint(); - - public abstract GPSPoint getLastPoint(); - - public abstract long getDateMin(); - - public abstract long getDateMax(); - - public abstract int getPointSize(); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - - protected <T> T getChild(Collection<T> childs, int index) { - T result = null; - if (childs != null) { - if (childs instanceof List) { - if (index < childs.size()) { - result = ((List<T>) childs).get(index); - } - } else { - int i = 0; - for (T o : childs) { - if (index == i) { - result = o; - break; - } - i++; - } - } - } - return result; - } - -} //GPSPointInterval diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointIntervalImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointIntervalImpl.java deleted file mode 100644 index ed3790f..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSPointIntervalImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.entities.gps; - -import java.util.Date; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSPointIntervalImpl extends GPSPointInterval { - - private static final long serialVersionUID = 1L; - - @Override - public GPSPoint getFirstPoint() { - if (getPoint() == null) { - return null; - } - GPSPoint p = getPoint(0); - return p; - } - - @Override - public GPSPoint getLastPoint() { - if (getPoint() == null) { - return null; - } - GPSPoint p = getPoint(getPoint().size() - 1); - return p; - } - - @Override - public long getDateMin() { - GPSPoint p = getFirstPoint(); - if (p == null) { - throw new NullPointerException("Pas de premier point definie dans l'intervalle " + this); - } - return p.getTime().getTime(); - } - - @Override - public long getDateMax() { - GPSPoint p = getLastPoint(); - if (p == null) { - throw new NullPointerException("Pas de dernier point definie dans l'intervalle " + this); - } - return p.getTime().getTime(); - } - - @Override - public int getPointSize() { - return point == null ? 0 : point.size(); - } - - @Override - public String toString() { - String l; -// if (getPoint() == null || getFirstPoint() == null || getLastPoint() == null) { -// l = super.toString(); -// } - l = String.format("Intervalle %1$td/%1$tm/%1$tY %1$tH\\:%1$tM\\:%1$tS - %2$td/%2$tm/%2$tY %2$tH\\:%2$tM\\:%2$tM ( nombre de point(s) \\: %3$s )", new Date(getDateMin()), new Date(getDateMax()), getPoint().size()); - return l; - } -} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRoute.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRoute.java deleted file mode 100644 index 11aace9..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRoute.java +++ /dev/null @@ -1,276 +0,0 @@ -package fr.ird.observe.entities.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -public abstract class GPSRoute implements Serializable { - - private static final long serialVersionUID = 3702862907863819874L; - - public static final String PROPERTY_POINT = "point"; - - public static final String PROPERTY_ACCEPTED_INTERVAL = "acceptedInterval"; - - public static final String PROPERTY_REJECTED_INTERVAL = "rejectedInterval"; - - protected List<GPSPoint> point; - - protected List<GPSPointInterval> acceptedInterval; - - protected List<GPSPointInterval> rejectedInterval; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public GPSPoint getPoint(int index) { - GPSPoint o = getChild(point, index); - return o; - } - - public boolean isPointEmpty() { - return point == null || point.isEmpty(); - } - - public int sizePoint() { - return point == null ? 0 : point.size(); - } - - public void addPoint(GPSPoint point) { - getPoint().add(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public void addAllPoint(Collection<GPSPoint> point) { - getPoint().addAll(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public boolean removePoint(GPSPoint point) { - boolean removed = getPoint().remove(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean removeAllPoint(Collection<GPSPoint> point) { - boolean removed = getPoint().removeAll(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean containsPoint(GPSPoint point) { - boolean contains = getPoint().contains(point); - return contains; - } - - public boolean containsAllPoint(Collection<GPSPoint> point) { - boolean contains = getPoint().containsAll(point); - return contains; - } - - public List<GPSPoint> getPoint() { - return point; - } - - public void setPoint(List<GPSPoint> point) { - List<GPSPoint> oldValue = getPoint(); - this.point = point; - firePropertyChange(PROPERTY_POINT, oldValue, point); - } - - public GPSPointInterval getAcceptedInterval(int index) { - GPSPointInterval o = getChild(acceptedInterval, index); - return o; - } - - public boolean isAcceptedIntervalEmpty() { - return acceptedInterval == null || acceptedInterval.isEmpty(); - } - - public int sizeAcceptedInterval() { - return acceptedInterval == null ? 0 : acceptedInterval.size(); - } - - public void addAcceptedInterval(GPSPointInterval acceptedInterval) { - getAcceptedInterval().add(acceptedInterval); - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, null, acceptedInterval); - } - - public void addAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - getAcceptedInterval().addAll(acceptedInterval); - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, null, acceptedInterval); - } - - public boolean removeAcceptedInterval(GPSPointInterval acceptedInterval) { - boolean removed = getAcceptedInterval().remove(acceptedInterval); - if (removed) { - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, acceptedInterval, null); - } - return removed; - } - - public boolean removeAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - boolean removed = getAcceptedInterval().removeAll(acceptedInterval); - if (removed) { - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, acceptedInterval, null); - } - return removed; - } - - public boolean containsAcceptedInterval(GPSPointInterval acceptedInterval) { - boolean contains = getAcceptedInterval().contains(acceptedInterval); - return contains; - } - - public boolean containsAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - boolean contains = getAcceptedInterval().containsAll(acceptedInterval); - return contains; - } - - public List<GPSPointInterval> getAcceptedInterval() { - return acceptedInterval; - } - - public void setAcceptedInterval(List<GPSPointInterval> acceptedInterval) { - List<GPSPointInterval> oldValue = getAcceptedInterval(); - this.acceptedInterval = acceptedInterval; - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, oldValue, acceptedInterval); - } - - public GPSPointInterval getRejectedInterval(int index) { - GPSPointInterval o = getChild(rejectedInterval, index); - return o; - } - - public boolean isRejectedIntervalEmpty() { - return rejectedInterval == null || rejectedInterval.isEmpty(); - } - - public int sizeRejectedInterval() { - return rejectedInterval == null ? 0 : rejectedInterval.size(); - } - - public void addRejectedInterval(GPSPointInterval rejectedInterval) { - getRejectedInterval().add(rejectedInterval); - firePropertyChange(PROPERTY_REJECTED_INTERVAL, null, rejectedInterval); - } - - public void addAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - getRejectedInterval().addAll(rejectedInterval); - firePropertyChange(PROPERTY_REJECTED_INTERVAL, null, rejectedInterval); - } - - public boolean removeRejectedInterval(GPSPointInterval rejectedInterval) { - boolean removed = getRejectedInterval().remove(rejectedInterval); - if (removed) { - firePropertyChange(PROPERTY_REJECTED_INTERVAL, rejectedInterval, null); - } - return removed; - } - - public boolean removeAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - boolean removed = getRejectedInterval().removeAll(rejectedInterval); - if (removed) { - firePropertyChange(PROPERTY_REJECTED_INTERVAL, rejectedInterval, null); - } - return removed; - } - - public boolean containsRejectedInterval(GPSPointInterval rejectedInterval) { - boolean contains = getRejectedInterval().contains(rejectedInterval); - return contains; - } - - public boolean containsAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - boolean contains = getRejectedInterval().containsAll(rejectedInterval); - return contains; - } - - public List<GPSPointInterval> getRejectedInterval() { - return rejectedInterval; - } - - public void setRejectedInterval(List<GPSPointInterval> rejectedInterval) { - List<GPSPointInterval> oldValue = getRejectedInterval(); - this.rejectedInterval = rejectedInterval; - firePropertyChange(PROPERTY_REJECTED_INTERVAL, oldValue, rejectedInterval); - } - - public abstract GPSPoint getPoint(Date date); - - public abstract int getBeforePointIndex(GPSPointInterval intervalle, long date); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - - protected <T> T getChild(Collection<T> childs, int index) { - T result = null; - if (childs != null) { - if (childs instanceof List) { - if (index < childs.size()) { - result = ((List<T>) childs).get(index); - } - } else { - int i = 0; - for (T o : childs) { - if (index == i) { - result = o; - break; - } - i++; - } - } - } - return result; - } - -} //GPSRoute diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRouteImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRouteImpl.java deleted file mode 100644 index 73bd435..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GPSRouteImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.entities.gps; - -import java.util.Date; -import java.util.List; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSRouteImpl extends GPSRoute { - - private static final long serialVersionUID = 1L; - - /** - * Permet de construire un point pour une date donnée. - * - * On recherche parmis les intervalles acceptables les deux points entourant - * la date donnée. - * - * Si on a réussi à trouver deux points adéquates, alors on construit un - * nouveau point en utilisant la formule d'interpolation pour calculer les - * coordonnées du point. - * - * @param date la date du point à construire - * @return le nouveau point construit ou {@code null} si on a pas - * trouvé un intervalle de points acdeptables pour la date donnée. - */ - @Override - public GPSPoint getPoint(Date date) { - if (date == null) { - throw new NullPointerException("la date ne peut pas être nulle!"); - } - long tx = date.getTime(); - GPSPoint newPoint = null; - List<GPSPointInterval> intervalles = getAcceptedInterval(); - if (intervalles != null && !intervalles.isEmpty()) { - for (GPSPointInterval intervalle : intervalles) { - int index = getBeforePointIndex(intervalle, tx); - if (index == -1) { - // l'intervalle n'accepte pas la date donnée - continue; - } - // l'intervalle courant est acceptable pour la date donnée - GPSPoint p0 = intervalle.getPoint(index); - GPSPoint p1 = intervalle.getPoint(index + 1); - - //FIXME on devrait peut-être arrondir aux secondes ? - if (p0.getTime().getTime() == tx) { - newPoint = p0; - break; - } - //FIXME on devrait peut-être arrondir aux secondes ? - if (p1.getTime().getTime() == tx) { - newPoint = p1; - break; - } - // on calcule la position du nouveau point - // via la formule d'interpolation - newPoint = newPoint(p0, p1, date); - // on quitte car le point a été trouvé - break; - } - } - return newPoint; - - } - - /** - * Trouve l'index du point juste avant la date donnée (et donc le point - * suivant est après la date donnée). - * - * @param intervalle l'intervalle de points à parcourir - * @param date la date donnée - * @return l'index du point trouvé ou {@code -1} si pas de point - * adéquate trouvé. - */ - @Override - public int getBeforePointIndex(GPSPointInterval intervalle, long date) { - - int result = -1; - long min = intervalle.getDateMin(); - long max = intervalle.getDateMax(); - if (min <= date || date <= max) { - // cet intervalle est pas acceptable pour la date donnée - if (date == min) { - return 0; - } - if (date == max) { - return intervalle.getPoint().size() - 1; - } - List<GPSPoint> points = intervalle.getPoint(); - for (int i = 0, j = points.size(); i < j; i++) { - GPSPoint beforePoint = points.get(i); - long d = beforePoint.getTime().getTime(); - if (d > date) { - // on a trouvé le premier point juste après la date donnée - // on peut s'arreter là - result = i - 1; - break; - } - } - } - return result; - } - - protected GPSPoint newPoint(GPSPoint p0, GPSPoint p1, Date d) { - GPSPoint p = new GPSPointImpl(); - p.setTime(d); - long tx = d.getTime(); - long t0 = p0.getTime().getTime(); - long t1 = p1.getTime().getTime(); - float latitudeX = getInterpolation(t0, t1, tx, p0.getLatitude(), p1.getLatitude()); - float longitudeX = getInterpolation(t0, t1, tx, p0.getLongitude(), p1.getLongitude()); - p.setLongitude(longitudeX); - p.setLatitude(latitudeX); - return p; - } - - protected float getInterpolation(long t0, long t1, long tx, float x0, float x1) { - float result = (tx - t0 - (t1 - t0)) * (x1 - x0) + x0; - return result; - } -} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GpsPoints.java b/observe-entities/src/main/java/fr/ird/observe/entities/gps/GpsPoints.java deleted file mode 100644 index cca4455..0000000 --- a/observe-entities/src/main/java/fr/ird/observe/entities/gps/GpsPoints.java +++ /dev/null @@ -1,177 +0,0 @@ -package fr.ird.observe.entities.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ird.observe.entities.seine.ActivitySeine; -import fr.ird.observe.entities.seine.Route; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.DateUtil; - -import java.util.Date; - -/** - * Created on 8/25/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 3.7 - */ -public class GpsPoints { - - /** Logger. */ - private static final Log log = LogFactory.getLog(GpsPoints.class); - - public static final double MILE_TO_KM = 1.852; - - public static final double EARTH_RADIUS = 3958.75; - - /** le rayon de la terre en kilomètres */ - public static final int R = 6378; - - - /** - * Construit un point à partir de l'entité donnée. - * - * @param route la route qui contient le jour - * @param activity l'activite qui contient l'heure et la position géographique - * @return le nouveau point instancié - * @since 3.8 - */ - public static GPSPoint newPoint(Route route, ActivitySeine activity) { - - Date currentTime = DateUtil.getDateAndTime(route.getDate(), activity.getTime(), false, false); - - GPSPoint gpsPoint = new GPSPointImpl(); - gpsPoint.setTime(currentTime); - gpsPoint.setLatitude(activity.getLatitude()); - gpsPoint.setLongitude(activity.getLongitude()); - - return gpsPoint; - - } - - - /** - * Calcule la distance entre deux points (en kilometres). - * - * Il s'agit d'une approxiation utilisant la méthode d'orthodromie. - * - * http://fr.wikipedia.org/wiki/Orthodromie - * - * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) - * *sin(lat2)) - * - * @param p0 le premier point - * @param p1 le second point - * @return la distance calculée entre les deux points en kilometres. - */ - public static double getDistanceInKm(GPSPoint p0, GPSPoint p1) { - double d = getDistanceInMile(p0, p1) * MILE_TO_KM; - return d; - } - - /** - * Calcule la distance entre deux points (en miles nautique). - * - * Il s'agit d'une approxiation utilisant la méthode d'orthodromie. - * - * http://fr.wikipedia.org/wiki/Orthodromie - * - * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) - * *sin(lat2)) - * - * @param p0 le premier point - * @param p1 le second point - * @return la distance calculée entre les deux points en noeud. - */ - - public static double getDistanceInMile(GPSPoint p0, GPSPoint p1) { - double d; - if (p0.isSameLocation(p1)) { - - // same location : so distance is null for sure - // We use this limit case, otherwise in next computation, tmp - // value can be more than 1 (1.00000000002) and Math.acos(tmp) - // then is NaN - d = 0d; - } else { - double lat1 = p0.getLatitude(); - double lng1 = p0.getLongitude(); - - double lat2 = p1.getLatitude(); - double lng2 = p1.getLongitude(); - -// double earthRadius = 3958.75; - double dLat = Math.toRadians(lat2 - lat1); - double dLng = Math.toRadians(lng2 - lng1); - double sindLat = Math.sin(dLat / 2); - double sindLng = Math.sin(dLng / 2); - double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) - * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)); - double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - d = EARTH_RADIUS * c; - } - return d; - } - - /** - * Calcule la vitesse entre deux points (en noeud). - * - * @param p0 le premier point - * @param p1 le second point - * @return la vitesse calculée entre les deux points en noeud. - */ - public static float getSpeed(GPSPoint p0, GPSPoint p1) { - - if (p0.getTime().after(p1.getTime())) { - - if (log.isWarnEnabled()) { - log.warn("Le point " + p0 + " est chronologiquement après le point " + p1 + " impossible de calculer une vitesse."); - } - return 0; - - } - - // la distance en miles nautique - double d = getDistanceInMile(p0, p1); - // le temps en heure - float delay = (float) getDelay(p0, p1) / (1000 * 60 * 60); - // la vitesse en noeud - double speed = d / delay; - return (float) speed; - } - - /** - * Calcule le temps écoulé entre deux points (en millisecondes). - * - * @param p0 le premier point - * @param p1 le second point - * @return le temps écoulé entre les deux points en millisecondes. - */ - public static long getDelay(GPSPoint p0, GPSPoint p1) { - long d0 = p0.getTime().getTime(); - long d1 = p1.getTime().getTime(); - long delta = d1 - d0; - return delta; - } -} diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java index 8666fcf..15e7851 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineImpl.java @@ -25,7 +25,7 @@ package fr.ird.observe.entities.longline; import com.google.common.base.MoreObjects; import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.referentiel.longline.VesselActivityLongline; -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; import org.nuiton.util.DateUtil; import java.util.Date; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/longline/SetLonglineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/longline/SetLonglineImpl.java index 006448c..a1cc0e9 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/longline/SetLonglineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/longline/SetLonglineImpl.java @@ -24,7 +24,7 @@ package fr.ird.observe.entities.longline; import com.google.common.base.MoreObjects; import fr.ird.observe.entities.Entities; -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; import org.nuiton.util.DateUtil; import java.util.Date; diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/HarbourImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/HarbourImpl.java index b744d16..9029bbf 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/HarbourImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/referentiel/HarbourImpl.java @@ -22,7 +22,7 @@ package fr.ird.observe.entities.referentiel; * #L% */ -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; public class HarbourImpl extends HarbourAbstract { diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java index 5a771ab..dc2cfde 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/ActivitySeineImpl.java @@ -25,7 +25,7 @@ import com.google.common.base.MoreObjects; import fr.ird.observe.entities.Entities; import fr.ird.observe.entities.constants.seine.SchoolTypePersist; import fr.ird.observe.entities.referentiel.seine.VesselActivitySeine; -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.NumberUtil; diff --git a/observe-entities/src/main/java/fr/ird/type/CoordinateHelper.java b/observe-entities/src/main/java/fr/ird/type/CoordinateHelper.java deleted file mode 100644 index 5a519ab..0000000 --- a/observe-entities/src/main/java/fr/ird/type/CoordinateHelper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2010 - 2011 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.type; - -/** - * Helper to deal with coordinates. - * - * @author tchemit - chemit@codelutin.com - * @since 1.2 - */ -public class CoordinateHelper { - - /** - * Calcule le quadrant à partir d'une {@code longitude} et {@code latitude}. - * - * @param longitude la longitude décimale - * @param latitude la latitude décimale - * @return la valeur du quadrant ou {@code null} si l'une des deux - * coordonnées est {@code null}. - * @since 1.2 - */ - public static Integer getQuadrant(Float longitude, Float latitude) { - if (longitude == null || latitude == null) { - return null; - } - int result; - - if (latitude > 0) { - result = longitude > 0 ? 1 : 4; - } else { - result = longitude > 0 ? 2 : 3; - } - return result; - } - -} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GpsPoints.java b/observe-services-model/src/main/java/fr/ird/observe/util/GPSPoint.java similarity index 60% rename from observe-services-model/src/main/java/fr/ird/observe/util/gps/GpsPoints.java rename to observe-services-model/src/main/java/fr/ird/observe/util/GPSPoint.java index a1133c4..f78a01e 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GpsPoints.java +++ b/observe-services-model/src/main/java/fr/ird/observe/util/GPSPoint.java @@ -1,4 +1,4 @@ -package fr.ird.observe.util.gps; +package fr.ird.observe.util; /* * #%L @@ -29,18 +29,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.DateUtil; +import java.io.Serializable; import java.util.Date; -/** - * Created on 8/25/14. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 3.7 - */ -public class GpsPoints { +public class GPSPoint implements Serializable { + + private static final long serialVersionUID = 1L; /** Logger. */ - private static final Log log = LogFactory.getLog(GpsPoints.class); + private static final Log log = LogFactory.getLog(GPSPoint.class); public static final double MILE_TO_KM = 1.852; @@ -49,6 +46,26 @@ public class GpsPoints { /** le rayon de la terre en kilomètres */ public static final int R = 6378; + protected Float latitude; + + protected Float longitude; + + protected Float vitesse; + + protected Date time; + + public static GPSPoint newPoint(Date routeDay, Date activityTime, float activityLatitude, float activityLongitude) { + + Date currentTime = DateUtil.getDateAndTime(routeDay, activityTime, false, false); + + GPSPoint gpsPoint = new GPSPoint(); + gpsPoint.setTime(currentTime); + gpsPoint.setLatitude(activityLatitude); + gpsPoint.setLongitude(activityLongitude); + + return gpsPoint; + + } /** * Construit un point à partir de l'entité donnée. @@ -59,16 +76,7 @@ public class GpsPoints { * @since 3.8 */ public static GPSPoint newPoint(RouteDto route, ActivitySeineDto activity) { - - Date currentTime = DateUtil.getDateAndTime(route.getDate(), activity.getTime(), false, false); - - GPSPoint gpsPoint = new GPSPointImpl(); - gpsPoint.setTime(currentTime); - gpsPoint.setLatitude(activity.getLatitude()); - gpsPoint.setLongitude(activity.getLongitude()); - - return gpsPoint; - + return newPoint(route.getDate(), activity.getTime(), activity.getLatitude(), activity.getLongitude()); } /** @@ -80,18 +88,64 @@ public class GpsPoints { * @since 3.8 */ public static GPSPoint newPoint(RouteDto route, ActivitySeineStubDto activity) { + return newPoint(route.getDate(), activity.getTime(), activity.getLatitude(), activity.getLongitude()); + } - Date currentTime = DateUtil.getDateAndTime(route.getDate(), activity.getTime(), false, false); + public Integer getQuadrant() { + if (longitude == null || latitude == null) { + return null; + } + int result; - GPSPoint gpsPoint = new GPSPointImpl(); - gpsPoint.setTime(currentTime); - gpsPoint.setLatitude(activity.getLatitude()); - gpsPoint.setLongitude(activity.getLongitude()); + if (latitude > 0) { + result = longitude > 0 ? 1 : 4; + } else { + result = longitude > 0 ? 2 : 3; + } + return result; + } - return gpsPoint; + public boolean isSameLocation(GPSPoint point) { + float latitude = getLatitude() == null ? 0f : getLatitude(); + float longitude = getLongitude() == null ? 0f : getLongitude(); + + float latitude1 = point.getLatitude() == null ? 0f : point.getLatitude(); + float longitude1 = point.getLongitude() == null ? 0f : point.getLongitude(); + return latitude == latitude1 && longitude == longitude1; } + public Float getLatitude() { + return latitude; + } + + public void setLatitude(Float latitude) { + this.latitude = latitude; + } + + public Float getLongitude() { + return longitude; + } + + public void setLongitude(Float longitude) { + this.longitude = longitude; + } + + public Float getVitesse() { + return vitesse; + } + + public void setVitesse(Float vitesse) { + this.vitesse = vitesse; + } + + public Date getTime() { + return time; + } + + public void setTime(Date time) { + this.time = time; + } /** * Calcule la distance entre deux points (en kilometres). @@ -103,12 +157,11 @@ public class GpsPoints { * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) * *sin(lat2)) * - * @param p0 le premier point * @param p1 le second point * @return la distance calculée entre les deux points en kilometres. */ - public static double getDistanceInKm(GPSPoint p0, GPSPoint p1) { - double d = getDistanceInMile(p0, p1) * MILE_TO_KM; + public double getDistanceInKm(GPSPoint p1) { + double d = getDistanceInMile(p1) * MILE_TO_KM; return d; } @@ -122,14 +175,13 @@ public class GpsPoints { * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) * *sin(lat2)) * - * @param p0 le premier point * @param p1 le second point * @return la distance calculée entre les deux points en noeud. */ - public static double getDistanceInMile(GPSPoint p0, GPSPoint p1) { + public double getDistanceInMile(GPSPoint p1) { double d; - if (p0.isSameLocation(p1)) { + if (isSameLocation(p1)) { // same location : so distance is null for sure // We use this limit case, otherwise in next computation, tmp @@ -137,8 +189,8 @@ public class GpsPoints { // then is NaN d = 0d; } else { - double lat1 = p0.getLatitude(); - double lng1 = p0.getLongitude(); + double lat1 = latitude; + double lng1 = longitude; double lat2 = p1.getLatitude(); double lng2 = p1.getLongitude(); @@ -149,7 +201,7 @@ public class GpsPoints { double sindLat = Math.sin(dLat / 2); double sindLng = Math.sin(dLng / 2); double a = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) - * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)); + * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); d = EARTH_RADIUS * c; } @@ -159,25 +211,24 @@ public class GpsPoints { /** * Calcule la vitesse entre deux points (en noeud). * - * @param p0 le premier point * @param p1 le second point * @return la vitesse calculée entre les deux points en noeud. */ - public static float getSpeed(GPSPoint p0, GPSPoint p1) { + public float getSpeed(GPSPoint p1) { - if (p0.getTime().after(p1.getTime())) { + if (time.after(p1.getTime())) { if (log.isWarnEnabled()) { - log.warn("Le point " + p0 + " est chronologiquement après le point " + p1 + " impossible de calculer une vitesse."); + log.warn("Le point " + this + " est chronologiquement après le point " + p1 + " impossible de calculer une vitesse."); } return 0; } // la distance en miles nautique - double d = getDistanceInMile(p0, p1); + double d = getDistanceInMile(p1); // le temps en heure - float delay = (float) getDelay(p0, p1) / (1000 * 60 * 60); + float delay = (float) getDelay(p1) / (1000 * 60 * 60); // la vitesse en noeud double speed = d / delay; return (float) speed; @@ -186,14 +237,14 @@ public class GpsPoints { /** * Calcule le temps écoulé entre deux points (en millisecondes). * - * @param p0 le premier point * @param p1 le second point * @return le temps écoulé entre les deux points en millisecondes. */ - public static long getDelay(GPSPoint p0, GPSPoint p1) { - long d0 = p0.getTime().getTime(); + public long getDelay(GPSPoint p1) { + long d0 = getTime().getTime(); long d1 = p1.getTime().getTime(); long delta = d1 - d0; return delta; } + } diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSAble.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSAble.java deleted file mode 100644 index 8428f28..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSAble.java +++ /dev/null @@ -1,59 +0,0 @@ -package fr.ird.observe.util.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.util.Date; - -public interface GPSAble { - -// String PROPERTY_QUADRANT = "quadrant"; - - String PROPERTY_LATITUDE = "latitude"; - - String PROPERTY_LONGITUDE = "longitude"; - - String PROPERTY_VITESSE = "vitesse"; - - String PROPERTY_TIME = "time"; - - Integer getQuadrant(); - - void setQuadrant(Integer quadrant); - - Float getLatitude(); - - void setLatitude(Float latitude); - - Float getLongitude(); - - void setLongitude(Float longitude); - - Float getVitesse(); - - void setVitesse(Float vitesse); - - Date getTime(); - - void setTime(Date time); - -} //GPSAble diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSFileReader.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSFileReader.java deleted file mode 100644 index 3e43297..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSFileReader.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.util.gps; - -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * Classe responsable de la construction du modèle {@link GPSRoute} à partir - * d'un fichier de traces GPS au format {@code GPX}. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSFileReader { - - /** log */ - private static final Log log = LogFactory.getLog(GPSFileReader.class); - - public static final String ROUTE_TAG = "trk"; - - public static final String SEGMENT_TAG = "trkseg"; - - public static final String POINT_TAG = "trkpt"; - - public static final String TIME_TAG = "time"; - - public static final String SPEED_TAG = "speed"; - - public static final String LATITUDE_ATTR = "lat"; - - public static final String LONGITUDE_ATTR = "lon"; - - /** le fichier à importer */ - protected final File source; - - /** le délai en minutes acceptable entre deux points */ - protected final int maxDelay; - - /** la vitesse maximum autorisée entre 2 points en noeud */ - protected final float maxSpeed; - - protected final GPSService service; - - public GPSFileReader(GPSService service, - File source, - int maxDelay, - float maxSpeed) { - this.service = service; - this.source = source; - this.maxDelay = maxDelay; - this.maxSpeed = maxSpeed; - } - - public GPSRoute read() throws Exception { - if (source == null) { - throw new NullPointerException("la source ne doit pas être nulle"); - } - if (!source.exists() || !source.isFile()) { - throw new IllegalArgumentException("le fichier source '" + source + "' n'existe pas ou n'est pas un fichier"); - } - - GPSRoute model = new GPSRouteImpl(); - - XmlPullParserFactory factory = XmlPullParserFactory.newInstance( - System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null); - factory.setNamespaceAware(true); - XmlPullParser xpp = factory.newPullParser(); - FileReader fileReader = new FileReader(source); - - try { - xpp.setInput(fileReader); - - parseFile(xpp, model); - } finally { - fileReader.close(); - } - - return model; - } - - /** - * Détecte sur l'ensemble des points de la route ceux qui sont acceptables, - * c'est à dire que l'on accepte uniquement les points dont les intervalles - * de temps ne dépassent pas {@link #maxDelay}. - * - * Les intervalles de poinbts acceptables seront contenus dans {@link - * GPSRoute#acceptedInterval}, les intervalles rejetés seront sauvés dans - * {@link GPSRoute#rejectedInterval} - * - * @param route la route à traiter - */ - public void detectIntervals(GPSRoute route) { - if (log.isInfoEnabled()) { - log.info("starting... for " + this); - } - List<GPSPointInterval> acceptedList = new ArrayList<>(); - List<GPSPointInterval> rejectedList = new ArrayList<>(); - GPSPointInterval currentAccepted = null; - GPSPointInterval currentRejected = null; - GPSPoint previous = null; - // le delai acceptable entre deux points en millisecondes - long delay = getMaxSpeedAsMilliSecondes(); - - for (GPSPoint p : route.getPoint()) { - if (log.isTraceEnabled()) { - log.trace("test point " + p); - } - if (previous == null) { - // premeir point rencontré, rien à faire - previous = p; - continue; - } - long delta = service.getDelay(previous, p); - if (delta <= delay) { - // le point courant est acceptable - // on l'enregistre dans l'intervalle accepté - if (log.isDebugEnabled()) { - log.debug("accepted point: " + p + ", delta: " + delta); - } - - if (currentRejected != null) { - // on etait sur un intervalle de rejet - // il faut le fermer et l'enregister dans le modèle - rejectedList.add(currentRejected); - currentRejected = null; - } - if (currentAccepted == null) { - currentAccepted = new GPSPointIntervalImpl(); - currentAccepted.setPoint(new ArrayList<>()); - currentAccepted.addPoint(previous); - } - currentAccepted.addPoint(p); - previous = p; - continue; - } - - // le point courant n'est pas acceptable - // on l'enregistre dans l'intervalle courant de rejet - - if (log.isDebugEnabled()) { - log.debug("rejected point: " + p + ", delta: " + delta); - } - if (currentAccepted != null) { - // on était sur un intervall accepté, on doit le fermer - // et l'enregistre dans le modèle - acceptedList.add(currentAccepted); - currentAccepted = null; - } - if (currentRejected == null) { - // nouvelle intervalle de rejet - currentRejected = new GPSPointIntervalImpl(); - currentRejected.setPoint(new ArrayList<>()); - currentRejected.addPoint(previous); - } - currentRejected.addPoint(p); - previous = p; - } - - if (currentAccepted != null) { - // ajout de l'intervalle accepté - acceptedList.add(currentAccepted); - } - - if (currentRejected != null) { - // ajout de l'intervalle rejeté - rejectedList.add(currentRejected); - } - - // on enregistre les intervalles dans le modèle - if (!acceptedList.isEmpty()) { - route.setAcceptedInterval(acceptedList); - } - if (!rejectedList.isEmpty()) { - route.setRejectedInterval(rejectedList); - } - - } - - @Override - public String toString() { - String result = new ToStringBuilder(this).append("source", source). - append("maxDelay (ms)", getMaxSpeedAsMilliSecondes()). - append("maxSpeed (nd)", maxSpeed). - toString(); - return result; - } - - protected long getMaxSpeedAsMilliSecondes() { - return maxDelay * 60 * 1000; - } - - /** - * Parse le fichier xml donné et construit le modèle. - * - * Pour le moment on se limite à traiter le premier segment - * ({@code trkseg}) de la première route ({@code trk}). - * - * Lors de la découverte des points, on ne retient pas les points dont la - * vitesse par rapport au précédent point dépasse {@link - * #getMaxSpeedAsMilliSecondes()}. - * - * @param xpp le parser xml - * @param model le model à remplir - * @throws IOException - * @throws XmlPullParserException - * @throws ParseException - */ - protected void parseFile(XmlPullParser xpp, - GPSRoute model) throws IOException, XmlPullParserException, ParseException { - List<GPSPoint> points = new ArrayList<>(); - GPSPoint previousPoint = null; - GPSPoint currentPoint = null; - boolean findRoute = false; - boolean findSegment = false; - int elementType; - - String localName; - - if (xpp.getEventType() == XmlPullParser.START_DOCUMENT) { - xpp.next(); - } - - // recherche du premier segment de la première route - while (xpp.next() != XmlPullParser.END_DOCUMENT) { - // nouveau tag - localName = xpp.getName(); - if (ROUTE_TAG.equals(localName)) { - findRoute = true; - break; - } - } - if (!findRoute) { - // aucune route trouvée - return; - } - while ((elementType = xpp.next()) != XmlPullParser.END_DOCUMENT) { - // nouveau tag - localName = xpp.getName(); - if (SEGMENT_TAG.equals(localName)) { - findSegment = true; - break; - } - } - if (!findSegment) { - // aucun segment trouvé - return; - } - - String content; - - //format de type : 2007-11-09T04:54:27.000Z - DateFormat df = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSSS'Z'"); - - Float f; - while ((elementType = xpp.next()) != XmlPullParser.END_DOCUMENT) { - localName = xpp.getName(); - if (elementType == XmlPullParser.START_TAG) { - // debut d'un tag - if (POINT_TAG.equals(localName)) { - // debut d'un point - currentPoint = new GPSPointImpl(); - content = xpp.getAttributeValue(null, LATITUDE_ATTR); - f = Float.valueOf(content); - currentPoint.setLatitude(f); - content = xpp.getAttributeValue(null, LONGITUDE_ATTR); - f = Float.valueOf(content); - currentPoint.setLongitude(f); - continue; - } - if (TIME_TAG.equals(localName)) { - // tag de time - content = xpp.nextText(); - - Date d = df.parse(content); - currentPoint.setTime(d); - continue; - } - if (SPEED_TAG.equals(localName)) { - // tag de vitesse - content = xpp.nextText(); - f = Float.valueOf(content); - currentPoint.setVitesse(f); - continue; - } - - // les autres tags en ouverture ne sont pas traités pour le moment - continue; - } - if (elementType == XmlPullParser.END_TAG) { - // fin d'un tag - if (POINT_TAG.equals(localName)) { - // fin d'un point - boolean canAccept = true; - if (previousPoint != null) { - // on vérifie que la vitesse entrez les deux points - // est acceptable - float speed = service.getSpeed(previousPoint, currentPoint); - if (speed > maxSpeed) { - // on ne peut pas accepter ce point - canAccept = false; - } - } - if (canAccept) { - // le point est acceptable, on le conserve - points.add(currentPoint); - // et il passe en nouveau point de reference - previousPoint = currentPoint; - } - currentPoint = null; - continue; - } - if (SEGMENT_TAG.equals(localName)) { - // fin du segment - // on a terminé la lecture du premier segment - // on peut quitter le parsing - break; - } - } - } - model.setPoint(points); - } -} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPoint.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPoint.java deleted file mode 100644 index 7891366..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPoint.java +++ /dev/null @@ -1,118 +0,0 @@ -package fr.ird.observe.util.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Date; - -public abstract class GPSPoint implements GPSAble, Serializable { - - private static final long serialVersionUID = 3761972876361753443L; - - public static final String PROPERTY_LATITUDE = "latitude"; - - public static final String PROPERTY_LONGITUDE = "longitude"; - - public static final String PROPERTY_VITESSE = "vitesse"; - - public static final String PROPERTY_TIME = "time"; - - protected Float latitude; - - protected Float longitude; - - protected Float vitesse; - - protected Date time; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public Float getLatitude() { - return latitude; - } - - public void setLatitude(Float latitude) { - Float oldValue = getLatitude(); - this.latitude = latitude; - firePropertyChange(PROPERTY_LATITUDE, oldValue, latitude); - } - - public Float getLongitude() { - return longitude; - } - - public void setLongitude(Float longitude) { - Float oldValue = getLongitude(); - this.longitude = longitude; - firePropertyChange(PROPERTY_LONGITUDE, oldValue, longitude); - } - - public Float getVitesse() { - return vitesse; - } - - public void setVitesse(Float vitesse) { - Float oldValue = getVitesse(); - this.vitesse = vitesse; - firePropertyChange(PROPERTY_VITESSE, oldValue, vitesse); - } - - public Date getTime() { - return time; - } - - public void setTime(Date time) { - Date oldValue = getTime(); - this.time = time; - firePropertyChange(PROPERTY_TIME, oldValue, time); - } - - public abstract boolean isSameLocation(GPSPoint point); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - -} //GPSPoint diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointImpl.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointImpl.java deleted file mode 100644 index a9714c6..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.util.gps; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSPointImpl extends GPSPoint { - - private static final long serialVersionUID = 1L; - - public GPSPointImpl() { - } - - public GPSPointImpl(GPSAble activity) { - setLongitude(activity.getLongitude()); - setLatitude(activity.getLatitude()); - setTime(activity.getTime()); - } - - @Override - public Integer getQuadrant() { - Integer result = CoordinateHelper.getQuadrant(longitude, latitude); - return result; -// if (latitude == null || longitude == null) { -// return null; -// } -// int result; -// -// if (latitude > 0) { -// result = longitude > 0 ? 1 : 4; -//// result = longitude > 0 ? 1 : 3; -// } else { -// result = longitude > 0 ? 2 : 3; -//// result = longitude > 0 ? 1 : 3; -// } -// return result; - } - - @Override - public void setQuadrant(Integer quadrant) { - // non utilisé - } - - @Override - public boolean isSameLocation(GPSPoint point) { - float latitude = getLatitude() == null ? 0f : getLatitude(); - float longitude = getLongitude() == null ? 0f : getLongitude(); - - float latitude1 = point.getLatitude() == null ? 0f : point.getLatitude(); - float longitude1 = point.getLongitude() == null ? 0f : point.getLongitude(); - - return latitude == latitude1 && longitude == longitude1; - } - -} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointInterval.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointInterval.java deleted file mode 100644 index 40ff7f1..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointInterval.java +++ /dev/null @@ -1,155 +0,0 @@ -package fr.ird.observe.util.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Collection; -import java.util.List; - -public abstract class GPSPointInterval implements Serializable { - - private static final long serialVersionUID = 7377852988997002340L; - - public static final String PROPERTY_POINT = "point"; - - protected List<GPSPoint> point; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public GPSPoint getPoint(int index) { - GPSPoint o = getChild(point, index); - return o; - } - - public boolean isPointEmpty() { - return point == null || point.isEmpty(); - } - - public int sizePoint() { - return point == null ? 0 : point.size(); - } - - public void addPoint(GPSPoint point) { - getPoint().add(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public void addAllPoint(Collection<GPSPoint> point) { - getPoint().addAll(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public boolean removePoint(GPSPoint point) { - boolean removed = getPoint().remove(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean removeAllPoint(Collection<GPSPoint> point) { - boolean removed = getPoint().removeAll(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean containsPoint(GPSPoint point) { - boolean contains = getPoint().contains(point); - return contains; - } - - public boolean containsAllPoint(Collection<GPSPoint> point) { - boolean contains = getPoint().containsAll(point); - return contains; - } - - public List<GPSPoint> getPoint() { - return point; - } - - public void setPoint(List<GPSPoint> point) { - List<GPSPoint> oldValue = getPoint(); - this.point = point; - firePropertyChange(PROPERTY_POINT, oldValue, point); - } - - public abstract GPSPoint getFirstPoint(); - - public abstract GPSPoint getLastPoint(); - - public abstract long getDateMin(); - - public abstract long getDateMax(); - - public abstract int getPointSize(); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - - protected <T> T getChild(Collection<T> childs, int index) { - T result = null; - if (childs != null) { - if (childs instanceof List) { - if (index < childs.size()) { - result = ((List<T>) childs).get(index); - } - } else { - int i = 0; - for (T o : childs) { - if (index == i) { - result = o; - break; - } - i++; - } - } - } - return result; - } - -} //GPSPointInterval diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointIntervalImpl.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointIntervalImpl.java deleted file mode 100644 index 363af69..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSPointIntervalImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.util.gps; - -import java.util.Date; - -import static org.nuiton.i18n.I18n.t; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSPointIntervalImpl extends GPSPointInterval { - - private static final long serialVersionUID = 1L; - - @Override - public GPSPoint getFirstPoint() { - if (getPoint() == null) { - return null; - } - GPSPoint p = getPoint(0); - return p; - } - - @Override - public GPSPoint getLastPoint() { - if (getPoint() == null) { - return null; - } - GPSPoint p = getPoint(getPoint().size() - 1); - return p; - } - - @Override - public long getDateMin() { - GPSPoint p = getFirstPoint(); - if (p == null) { - throw new NullPointerException("Pas de premier point definie dans l'intervalle " + this); - } - return p.getTime().getTime(); - } - - @Override - public long getDateMax() { - GPSPoint p = getLastPoint(); - if (p == null) { - throw new NullPointerException("Pas de dernier point definie dans l'intervalle " + this); - } - return p.getTime().getTime(); - } - - @Override - public int getPointSize() { - return point == null ? 0 : point.size(); - } - - @Override - public String toString() { - String l; -// if (getPoint() == null || getFirstPoint() == null || getLastPoint() == null) { -// l = super.toString(); -// } - l = t("observe.common.gpsPointInterval", new Date(getDateMin()), new Date(getDateMax()), getPoint().size()); - return l; - } -} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRoute.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRoute.java deleted file mode 100644 index 4590179..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRoute.java +++ /dev/null @@ -1,276 +0,0 @@ -package fr.ird.observe.util.gps; - -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2014 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.Serializable; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -public abstract class GPSRoute implements Serializable { - - private static final long serialVersionUID = 3702862907863819874L; - - public static final String PROPERTY_POINT = "point"; - - public static final String PROPERTY_ACCEPTED_INTERVAL = "acceptedInterval"; - - public static final String PROPERTY_REJECTED_INTERVAL = "rejectedInterval"; - - protected List<GPSPoint> point; - - protected List<GPSPointInterval> acceptedInterval; - - protected List<GPSPointInterval> rejectedInterval; - - protected final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - public GPSPoint getPoint(int index) { - GPSPoint o = getChild(point, index); - return o; - } - - public boolean isPointEmpty() { - return point == null || point.isEmpty(); - } - - public int sizePoint() { - return point == null ? 0 : point.size(); - } - - public void addPoint(GPSPoint point) { - getPoint().add(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public void addAllPoint(Collection<GPSPoint> point) { - getPoint().addAll(point); - firePropertyChange(PROPERTY_POINT, null, point); - } - - public boolean removePoint(GPSPoint point) { - boolean removed = getPoint().remove(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean removeAllPoint(Collection<GPSPoint> point) { - boolean removed = getPoint().removeAll(point); - if (removed) { - firePropertyChange(PROPERTY_POINT, point, null); - } - return removed; - } - - public boolean containsPoint(GPSPoint point) { - boolean contains = getPoint().contains(point); - return contains; - } - - public boolean containsAllPoint(Collection<GPSPoint> point) { - boolean contains = getPoint().containsAll(point); - return contains; - } - - public List<GPSPoint> getPoint() { - return point; - } - - public void setPoint(List<GPSPoint> point) { - List<GPSPoint> oldValue = getPoint(); - this.point = point; - firePropertyChange(PROPERTY_POINT, oldValue, point); - } - - public GPSPointInterval getAcceptedInterval(int index) { - GPSPointInterval o = getChild(acceptedInterval, index); - return o; - } - - public boolean isAcceptedIntervalEmpty() { - return acceptedInterval == null || acceptedInterval.isEmpty(); - } - - public int sizeAcceptedInterval() { - return acceptedInterval == null ? 0 : acceptedInterval.size(); - } - - public void addAcceptedInterval(GPSPointInterval acceptedInterval) { - getAcceptedInterval().add(acceptedInterval); - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, null, acceptedInterval); - } - - public void addAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - getAcceptedInterval().addAll(acceptedInterval); - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, null, acceptedInterval); - } - - public boolean removeAcceptedInterval(GPSPointInterval acceptedInterval) { - boolean removed = getAcceptedInterval().remove(acceptedInterval); - if (removed) { - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, acceptedInterval, null); - } - return removed; - } - - public boolean removeAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - boolean removed = getAcceptedInterval().removeAll(acceptedInterval); - if (removed) { - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, acceptedInterval, null); - } - return removed; - } - - public boolean containsAcceptedInterval(GPSPointInterval acceptedInterval) { - boolean contains = getAcceptedInterval().contains(acceptedInterval); - return contains; - } - - public boolean containsAllAcceptedInterval(Collection<GPSPointInterval> acceptedInterval) { - boolean contains = getAcceptedInterval().containsAll(acceptedInterval); - return contains; - } - - public List<GPSPointInterval> getAcceptedInterval() { - return acceptedInterval; - } - - public void setAcceptedInterval(List<GPSPointInterval> acceptedInterval) { - List<GPSPointInterval> oldValue = getAcceptedInterval(); - this.acceptedInterval = acceptedInterval; - firePropertyChange(PROPERTY_ACCEPTED_INTERVAL, oldValue, acceptedInterval); - } - - public GPSPointInterval getRejectedInterval(int index) { - GPSPointInterval o = getChild(rejectedInterval, index); - return o; - } - - public boolean isRejectedIntervalEmpty() { - return rejectedInterval == null || rejectedInterval.isEmpty(); - } - - public int sizeRejectedInterval() { - return rejectedInterval == null ? 0 : rejectedInterval.size(); - } - - public void addRejectedInterval(GPSPointInterval rejectedInterval) { - getRejectedInterval().add(rejectedInterval); - firePropertyChange(PROPERTY_REJECTED_INTERVAL, null, rejectedInterval); - } - - public void addAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - getRejectedInterval().addAll(rejectedInterval); - firePropertyChange(PROPERTY_REJECTED_INTERVAL, null, rejectedInterval); - } - - public boolean removeRejectedInterval(GPSPointInterval rejectedInterval) { - boolean removed = getRejectedInterval().remove(rejectedInterval); - if (removed) { - firePropertyChange(PROPERTY_REJECTED_INTERVAL, rejectedInterval, null); - } - return removed; - } - - public boolean removeAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - boolean removed = getRejectedInterval().removeAll(rejectedInterval); - if (removed) { - firePropertyChange(PROPERTY_REJECTED_INTERVAL, rejectedInterval, null); - } - return removed; - } - - public boolean containsRejectedInterval(GPSPointInterval rejectedInterval) { - boolean contains = getRejectedInterval().contains(rejectedInterval); - return contains; - } - - public boolean containsAllRejectedInterval(Collection<GPSPointInterval> rejectedInterval) { - boolean contains = getRejectedInterval().containsAll(rejectedInterval); - return contains; - } - - public List<GPSPointInterval> getRejectedInterval() { - return rejectedInterval; - } - - public void setRejectedInterval(List<GPSPointInterval> rejectedInterval) { - List<GPSPointInterval> oldValue = getRejectedInterval(); - this.rejectedInterval = rejectedInterval; - firePropertyChange(PROPERTY_REJECTED_INTERVAL, oldValue, rejectedInterval); - } - - public abstract GPSPoint getPoint(Date date); - - public abstract int getBeforePointIndex(GPSPointInterval intervalle, long date); - - public void addPropertyChangeListener(PropertyChangeListener listener) { - pcs.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - pcs.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - pcs.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - pcs.firePropertyChange(propertyName, oldValue, newValue); - } - - protected void firePropertyChange(String propertyName, Object newValue) { - firePropertyChange(propertyName, null, newValue); - } - - protected <T> T getChild(Collection<T> childs, int index) { - T result = null; - if (childs != null) { - if (childs instanceof List) { - if (index < childs.size()) { - result = ((List<T>) childs).get(index); - } - } else { - int i = 0; - for (T o : childs) { - if (index == i) { - result = o; - break; - } - i++; - } - } - } - return result; - } - -} //GPSRoute diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRouteImpl.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRouteImpl.java deleted file mode 100644 index ae0b615..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSRouteImpl.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * #%L - * ObServe :: Entities - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.util.gps; - -import java.util.Date; -import java.util.List; - -/** - * @author Tony Chemit - chemit@codelutin.com - * @since 1.0 - */ -public class GPSRouteImpl extends GPSRoute { - - private static final long serialVersionUID = 1L; - - /** - * Permet de construire un point pour une date donnée. - * - * On recherche parmis les intervalles acceptables les deux points entourant - * la date donnée. - * - * Si on a réussi à trouver deux points adéquates, alors on construit un - * nouveau point en utilisant la formule d'interpolation pour calculer les - * coordonnées du point. - * - * @param date la date du point à construire - * @return le nouveau point construit ou {@code null} si on a pas - * trouvé un intervalle de points acdeptables pour la date donnée. - */ - @Override - public GPSPoint getPoint(Date date) { - if (date == null) { - throw new NullPointerException("la date ne peut pas être nulle!"); - } - long tx = date.getTime(); - GPSPoint newPoint = null; - List<GPSPointInterval> intervalles = getAcceptedInterval(); - if (intervalles != null && !intervalles.isEmpty()) { - for (GPSPointInterval intervalle : intervalles) { - int index = getBeforePointIndex(intervalle, tx); - if (index == -1) { - // l'intervalle n'accepte pas la date donnée - continue; - } - // l'intervalle courant est acceptable pour la date donnée - GPSPoint p0 = intervalle.getPoint(index); - GPSPoint p1 = intervalle.getPoint(index + 1); - - //FIXME on devrait peut-être arrondir aux secondes ? - if (p0.getTime().getTime() == tx) { - newPoint = p0; - break; - } - //FIXME on devrait peut-être arrondir aux secondes ? - if (p1.getTime().getTime() == tx) { - newPoint = p1; - break; - } - // on calcule la position du nouveau point - // via la formule d'interpolation - newPoint = newPoint(p0, p1, date); - // on quitte car le point a été trouvé - break; - } - } - return newPoint; - - } - - /** - * Trouve l'index du point juste avant la date donnée (et donc le point - * suivant est après la date donnée). - * - * @param intervalle l'intervalle de points à parcourir - * @param date la date donnée - * @return l'index du point trouvé ou {@code -1} si pas de point - * adéquate trouvé. - */ - @Override - public int getBeforePointIndex(GPSPointInterval intervalle, long date) { - - int result = -1; - long min = intervalle.getDateMin(); - long max = intervalle.getDateMax(); - if (min <= date || date <= max) { - // cet intervalle est pas acceptable pour la date donnée - if (date == min) { - return 0; - } - if (date == max) { - return intervalle.getPoint().size() - 1; - } - List<GPSPoint> points = intervalle.getPoint(); - for (int i = 0, j = points.size(); i < j; i++) { - GPSPoint beforePoint = points.get(i); - long d = beforePoint.getTime().getTime(); - if (d > date) { - // on a trouvé le premier point juste après la date donnée - // on peut s'arreter là - result = i - 1; - break; - } - } - } - return result; - } - - protected GPSPoint newPoint(GPSPoint p0, GPSPoint p1, Date d) { - GPSPoint p = new GPSPointImpl(); - p.setTime(d); - long tx = d.getTime(); - long t0 = p0.getTime().getTime(); - long t1 = p1.getTime().getTime(); - float latitudeX = getInterpolation(t0, t1, tx, p0.getLatitude(), p1.getLatitude()); - float longitudeX = getInterpolation(t0, t1, tx, p0.getLongitude(), p1.getLongitude()); - p.setLongitude(longitudeX); - p.setLatitude(latitudeX); - return p; - } - - protected float getInterpolation(long t0, long t1, long tx, float x0, float x1) { - float result = (tx - t0 - (t1 - t0)) * (x1 - x0) + x0; - return result; - } -} diff --git a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSService.java b/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSService.java deleted file mode 100644 index f6e6496..0000000 --- a/observe-services-model/src/main/java/fr/ird/observe/util/gps/GPSService.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * #%L - * ObServe :: Business - * %% - * Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ird.observe.util.gps; - -import java.io.File; - -/** - * Service de manipulation GPS. - * - * @author Tony Chemit - chemit@codelutin.com - * @since 1.3 - */ -public class GPSService { - - /** - * Construit la route gps à partir d'un fichier gps donnée et des deux - * indicateurs {@code maxDelay} et {@code maxSpeed} et la retourne. - * - * @param file le fichier contenant les données gps - * @param maxDelay le maximum de temps entre 2 points - * @param maxSpeed le vitesse maximale en 2 points - * @return la route gps calculée - * @throws Exception pour tout probleme lors la construction de la route - */ - public GPSRoute buildRoute(File file, - int maxDelay, - float maxSpeed) throws Exception { - GPSFileReader reader = new GPSFileReader(this, file, maxDelay, maxSpeed); - GPSRoute r = reader.read(); - reader.detectIntervals(r); - return r; - } - - /** - * Calcule la distance entre deux points (en kilometres). - * - * Il s'agit d'une approxiation utilisant la méthode d'orthodromie. - * - * http://fr.wikipedia.org/wiki/Orthodromie - * - * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) - * *sin(lat2)) - * - * @param p0 le premier point - * @param p1 le second point - * @return la distance calculée entre les deux points en kilometres. - */ - public double getDistanceInKm(GPSPoint p0, GPSPoint p1) { - double d = GpsPoints.getDistanceInKm(p0, p1); - return d; - } - - /** - * Calcule la distance entre deux points (en miles nautique). - * - * Il s'agit d'une approxiation utilisant la méthode d'orthodromie. - * - * http://fr.wikipedia.org/wiki/Orthodromie - * - * d = R * arccos(cos(lat1) * cos(lat2) *cos(long2 - long1) + sin(lat1) - * *sin(lat2)) - * - * @param p0 le premier point - * @param p1 le second point - * @return la distance calculée entre les deux points en noeud. - */ - public double getDistanceInMile(GPSPoint p0, GPSPoint p1) { - double d = GpsPoints.getDistanceInMile(p0, p1); - return d; - } - - /** - * Calcule la vitesse entre deux points (en noeud). - * - * @param p0 le premier point - * @param p1 le second point - * @return la vitesse calculée entre les deux points en noeud. - */ - public float getSpeed(GPSPoint p0, GPSPoint p1) { - float d = GpsPoints.getSpeed(p0, p1); - return d; - - } - - /** - * Calcule le temps écoulé entre deux points (en millisecondes). - * - * @param p0 le premier point - * @param p1 le second point - * @return le temps écoulé entre les deux points en millisecondes. - */ - public long getDelay(GPSPoint p0, GPSPoint p1) { - return GpsPoints.getDelay(p0, p1); - } - -} diff --git a/observe-services-topia-validation/pom.xml b/observe-services-topia-validation/pom.xml index d611eb8..ec535c3 100644 --- a/observe-services-topia-validation/pom.xml +++ b/observe-services-topia-validation/pom.xml @@ -46,6 +46,11 @@ <artifactId>observe-entities</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>observe-services-model</artifactId> + <version>${project.version}</version> + </dependency> <!-- Nuiton --> <dependency> diff --git a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySimpleSpeedValidator.java b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySimpleSpeedValidator.java index 341f782..85fb69d 100644 --- a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySimpleSpeedValidator.java +++ b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySimpleSpeedValidator.java @@ -25,11 +25,10 @@ package fr.ird.observe.services.topia.validation.validators; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.validator.ValidationException; import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; -import fr.ird.observe.entities.gps.GPSPoint; -import fr.ird.observe.entities.gps.GpsPoints; import fr.ird.observe.entities.seine.ActivitySeine; import fr.ird.observe.entities.seine.ActivitySeines; import fr.ird.observe.entities.seine.Route; +import fr.ird.observe.util.GPSPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -146,10 +145,10 @@ public class ActivitySimpleSpeedValidator extends FieldValidatorSupport { return; } - GPSPoint currentPoint = GpsPoints.newPoint(route, activity); - GPSPoint previousPoint = GpsPoints.newPoint(route, previousActivity); + GPSPoint currentPoint = GPSPoint.newPoint(route.getDate(), activity.getTime(), activity.getLatitude(), activity.getLongitude()); + GPSPoint previousPoint = GPSPoint.newPoint(route.getDate(), previousActivity.getTime(), previousActivity.getLatitude(), previousActivity.getLongitude()); - float computedSpeed = GpsPoints.getSpeed(previousPoint, currentPoint); + float computedSpeed = previousPoint.getSpeed(currentPoint); if (log.isDebugEnabled()) { log.debug("Speed computed between previous activity point " + decorate(previousPoint) + " to current activity point " + decorate(currentPoint) + ", speed is : " + computedSpeed); diff --git a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySpeedValidator.java b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySpeedValidator.java index 2bddf91..3f5ff34 100644 --- a/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySpeedValidator.java +++ b/observe-services-topia-validation/src/main/java/fr/ird/observe/services/topia/validation/validators/ActivitySpeedValidator.java @@ -25,10 +25,9 @@ package fr.ird.observe.services.topia.validation.validators; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.validator.ValidationException; import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport; -import fr.ird.observe.entities.gps.GPSPoint; -import fr.ird.observe.entities.gps.GpsPoints; import fr.ird.observe.entities.seine.ActivitySeine; import fr.ird.observe.entities.seine.Route; +import fr.ird.observe.util.GPSPoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.validator.xwork2.field.CollectionFieldExpressionValidator; @@ -143,10 +142,10 @@ public class ActivitySpeedValidator extends FieldValidatorSupport { return true; } - GPSPoint previousPoint = GpsPoints.newPoint(route, previousActivity); - GPSPoint currentPoint = GpsPoints.newPoint(route, currentActivity); + GPSPoint previousPoint = GPSPoint.newPoint(route.getDate(), previousActivity.getTime(), previousActivity.getLatitude(), previousActivity.getLongitude()); + GPSPoint currentPoint = GPSPoint.newPoint(route.getDate(), currentActivity.getTime(), currentActivity.getLatitude(), currentActivity.getLongitude()); - float computedSpeed = GpsPoints.getSpeed(previousPoint, currentPoint); + float computedSpeed = previousPoint.getSpeed(currentPoint); if (LOG.isDebugEnabled()) { LOG.debug("Speed computed between previous activity point " + decorate(previousPoint) + " to current activity point " + decorate(currentPoint) + ", speed is : " + computedSpeed); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java index fa454fa..d73dcee 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/longline/ActivityLonglineServiceTopia.java @@ -40,7 +40,7 @@ import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.result.TripChildSaveResultDto; import fr.ird.observe.services.dto.result.TripChildSaveResultDtos; import fr.ird.observe.services.service.DataNotFoundException; -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java index 7071335..91c3303 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/ActivitySeineServiceTopia.java @@ -39,7 +39,7 @@ import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.seine.ActivitySeineDto; import fr.ird.observe.services.dto.seine.RouteDto; import fr.ird.observe.services.service.DataNotFoundException; -import fr.ird.type.CoordinateHelper; +import fr.ird.observe.entities.gps.CoordinateHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.DateUtil; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm