Compare commits
1380 Commits
20250724_1
...
JpaTest
| Author | SHA1 | Date | |
|---|---|---|---|
| 8781b406ff | |||
| c9325674d9 | |||
| 99ca1731b1 | |||
| af6f465c0e | |||
| d981e59a7d | |||
| 6d7212ce97 | |||
| 5103830369 | |||
| 5056d7e0c8 | |||
| 4b5e46de7b | |||
| 4d686ee145 | |||
| e842326f5b | |||
| 63ad11086f | |||
| 21f6fc6717 | |||
| 8c2789b5f3 | |||
| 8f3ef405cf | |||
| 76e76dfcf4 | |||
| 1df5ad7137 | |||
| a43ca46395 | |||
| a63eba544b | |||
| ce912bf103 | |||
| ababbf6142 | |||
| e97fd0aacb | |||
| 51c1ed1d23 | |||
| a9be8f7003 | |||
| 7522092a12 | |||
| 4dc0174800 | |||
| a04b2fa4a1 | |||
| 04317470c6 | |||
| 187216dd9f | |||
| e11172a90f | |||
| 51d5b05bd3 | |||
| 3a2ceaf217 | |||
| c783f69a49 | |||
| 1c8695095b | |||
| fc28af761c | |||
| fd4db5ab3b | |||
| f7e1d1f6ca | |||
| 0b8f82f041 | |||
| 99680dccd8 | |||
| e948855fc0 | |||
| 0854acacfb | |||
| 1aba141c9f | |||
| 741cb960d4 | |||
| 82d7efc00c | |||
| c6c2739525 | |||
| 313bfc21ff | |||
| 36f50ad846 | |||
| 798e5b532e | |||
| c27c96c3d9 | |||
| 4e3d15ebd8 | |||
| 0ba9297f39 | |||
| 7c036172d8 | |||
| 8afa01d8ef | |||
| db1949b5b6 | |||
| bb47dd458e | |||
| 530b6af4ef | |||
| 92cd4b1af5 | |||
| 6b71d6b784 | |||
| de4d8d225f | |||
| 671c2e99d0 | |||
| 755e7394b4 | |||
| ce06683722 | |||
| e8a1a8ca0b | |||
| 7a5c024005 | |||
| c82f2a57d8 | |||
| 78dbf9f7e3 | |||
| b9e863a563 | |||
| 60e4429c3f | |||
| d7012d4e1f | |||
| 1d52f79337 | |||
| 0e1adccb7c | |||
| fa76a8e92d | |||
| 9b34a51bd9 | |||
| b75f7e3810 | |||
| 4aeccdfa76 | |||
| 39db8e6e1b | |||
| 1b87cacca2 | |||
| 326bd4294e | |||
| 6a237ce4d9 | |||
| a64932d918 | |||
| e887aceaaf | |||
| a15d009f76 | |||
| a62f37d930 | |||
| 55f23b2dfc | |||
| a4a2b34379 | |||
| 1ef49b87e8 | |||
| f2d67ea89d | |||
| fda162d867 | |||
| 2008ef0e8f | |||
| 6d8e0e747f | |||
| 5417e28630 | |||
| 4ac4686645 | |||
| 1594154639 | |||
| 3a4a954b91 | |||
| 744f92c881 | |||
| 6e5f099fc2 | |||
| 697cd58e39 | |||
| 4bf1f6021f | |||
| 118d2d83d5 | |||
| 149bdc36b3 | |||
| 89c69bc0d2 | |||
| 240f18d19d | |||
| 9a8a144705 | |||
| 2f412f1ad6 | |||
| 8e8b03889a | |||
| dd4ace59bd | |||
| 52c0e0ca61 | |||
| e2f2b9bde9 | |||
| 4ea9be84db | |||
| 11e4b1cf20 | |||
| a66cfa16d8 | |||
| 9f628973e9 | |||
| 9fa7f9628c | |||
| 1a5156d53c | |||
| ba667fd28e | |||
| cddc7f8979 | |||
| 60c436256e | |||
| 46449c47b9 | |||
| f8b6d3ebe0 | |||
| b3d29219ee | |||
| 2c81a6566b | |||
| f697a122b6 | |||
| 3f4ed16f20 | |||
| cbbfbb16b8 | |||
| 585a04ffba | |||
| b025be1bd9 | |||
| 5453826156 | |||
| 8312d48970 | |||
| b50c348528 | |||
| 64aeff7bf6 | |||
| 2a8cf16ce0 | |||
| 3539e82849 | |||
| f4faa20652 | |||
| e7f5959e27 | |||
| 1d897f1461 | |||
| f3e48b9a3e | |||
| f0e41c6554 | |||
| 3d76dec03a | |||
| 754b58fd37 | |||
| 0627fd59c9 | |||
| 31480b8fbe | |||
| c1efdf48a6 | |||
| e1de9f4db9 | |||
| ce2ec669ba | |||
| c9658954aa | |||
| 5011aa271d | |||
| af4a5511a3 | |||
| fa996c210c | |||
| c5b5fb62a1 | |||
| 3b007c061e | |||
| 8ee9e2fe57 | |||
| 4ddcc6228e | |||
| 7cf9df3549 | |||
| 8e8d6cf2c3 | |||
| 2a5314fd1e | |||
| 9363e674b5 | |||
| e7252f7fea | |||
| b5e1d2e1ce | |||
| 53ef2539f5 | |||
| 6136d9b848 | |||
| fe2be9b926 | |||
| 1b113999b2 | |||
| 4ebcae77ca | |||
| 8d35f9284a | |||
| b953349afc | |||
| 6c2eaaa37a | |||
| 9b8824e681 | |||
| fb03aa1ea7 | |||
| c16e23d3bf | |||
| 27055f8e5e | |||
| b8ac769ffd | |||
| 0216bc5d53 | |||
| db3973637d | |||
| 7dab29e8c2 | |||
| 809ffe73b9 | |||
| 4d13d17095 | |||
| f749356735 | |||
| b2d24ab6b4 | |||
| 6bb7b55618 | |||
| 920257812c | |||
| 00efbe6fcf | |||
| cacb24a563 | |||
| 5da098e058 | |||
| 3e0c443ce3 | |||
| b4442bc251 | |||
| eec353c6a5 | |||
| 8b50f54881 | |||
| 42f50e0d80 | |||
| cbeae87d23 | |||
| 71cb1db5ef | |||
| bb642d92db | |||
| ddd3b95d17 | |||
| ff5428f8bd | |||
| d3b39ad878 | |||
| 99a366d875 | |||
| abc4f1c966 | |||
| fc1c2f192e | |||
| ac4afa9a2b | |||
| c5a315e070 | |||
| 1d0fd3341d | |||
| b44685335a | |||
| e5689da13d | |||
| f57710cb32 | |||
| ceb5dc817c | |||
| 3a934813d8 | |||
| d56fe38e2c | |||
| 5555a40731 | |||
| acf5daf673 | |||
| 939c4ab236 | |||
| 49237b9585 | |||
| abbf298b4f | |||
| 34985c9fd3 | |||
| 401f0330de | |||
| 7815fb72f1 | |||
| 0e8cc5b2de | |||
| 9a18dd6ebd | |||
| 3f0b9315a2 | |||
| 32a15a4f3e | |||
| 932f99c147 | |||
| 1fc7d01b9c | |||
| 46e47a9549 | |||
| ba1bbbafe0 | |||
| fa54de3d76 | |||
| 1550de37e6 | |||
| 450f9f4dd4 | |||
| f1da5057d6 | |||
| a3d15aeb32 | |||
| c933c02727 | |||
| 28b94b228a | |||
| c291db3e34 | |||
| 3f9a451a70 | |||
| 9f39c5bc2d | |||
| 6a455db664 | |||
| c33c1da199 | |||
| d0769ea1bd | |||
| f3f768380a | |||
| cb2cf06200 | |||
| a81fc6813c | |||
| 5c03b928b6 | |||
| 16b478a511 | |||
| c2ef09a604 | |||
| f2de64de75 | |||
| b877347a77 | |||
| 2d43952d96 | |||
| ee171374c8 | |||
| f0d1cdc81a | |||
| 1758dcabbb | |||
| 8231716e97 | |||
| 2603cda317 | |||
| 77c79c6247 | |||
| 532a9cc3f4 | |||
| c26f7feb35 | |||
| 15a63cff14 | |||
| b53d76358b | |||
| f9ded1153a | |||
| 81ddb42e5c | |||
| 5ac4d4be63 | |||
| 0b432960ec | |||
| 159436247d | |||
| 2a2435f64d | |||
| fba5e331b5 | |||
| 21cc88f295 | |||
| de21ce7cb8 | |||
| 33f24290a9 | |||
| dc83e89392 | |||
| d525048bb3 | |||
| f5d46be57d | |||
| ca4c3c3412 | |||
| e5c16c6e4e | |||
| 42bef35d5f | |||
| 44e3de6a0f | |||
| 9942f92440 | |||
| e34bb01aea | |||
| 6f11e08807 | |||
| aa9529f551 | |||
| bcb8f4475d | |||
| 8a83213384 | |||
| 2433c98ab1 | |||
| 595fe77472 | |||
| 29f9335876 | |||
| e975964f53 | |||
| 9d82cbc610 | |||
| 0a12dc23f2 | |||
| 1719f2ba37 | |||
| ddd9c73f49 | |||
| 1b0f5d5d29 | |||
| 6991e60ec5 | |||
| 8a87d428ae | |||
| 0058373710 | |||
| d9f93b14e1 | |||
| dea6b14323 | |||
| d01b4aef8f | |||
| b2c3008464 | |||
| d02f44237e | |||
| 675e919652 | |||
| 9d9d4e3d87 | |||
| 19e17f76d4 | |||
| df18330a01 | |||
| da61cb5439 | |||
| 975e4f2be4 | |||
| e31b0bc1a0 | |||
| 84ccdafd90 | |||
| 97de2f0e71 | |||
| 1ee321b253 | |||
| 7912d29f00 | |||
| ecd8bca2aa | |||
| 1a64179099 | |||
| 54588d20bd | |||
| 84f3823597 | |||
| 0022e620da | |||
| 62a1f5a85f | |||
| cd389dc83f | |||
| 974b5f61af | |||
| a10876effc | |||
| 4385520480 | |||
| a1b892a75e | |||
| 92dcc45638 | |||
| a178ec5017 | |||
| 1456e094a2 | |||
| 58b89777bb | |||
| f4da09eacc | |||
| 6f47434d6f | |||
| 8fb8e4c05a | |||
| d18ac96cc4 | |||
| 9b26849cb6 | |||
| fcbee627b0 | |||
| b17d807ca3 | |||
| 5b017fdad1 | |||
| 4957cba34b | |||
| 85e59e577f | |||
| 5c60cd2558 | |||
| 5a824d0b3a | |||
| f60c3337b1 | |||
| 4ee64127b1 | |||
| b587e38cc8 | |||
| be4c2d149e | |||
| ccb8b81597 | |||
| 68a45a9eea | |||
| d419c38220 | |||
| 8fe752e595 | |||
| 71ffc5b4cf | |||
| f00f0cf975 | |||
| 19e8949d86 | |||
| cc189f4761 | |||
| bd3bf9a8dc | |||
| bee29e357e | |||
| 461b949581 | |||
| 7fd4b6236c | |||
| 5075e17078 | |||
| c6e2230052 | |||
| f9794850c4 | |||
| ee18ecb15e | |||
| 656f2018a2 | |||
| 2b4cea4ada | |||
| 2aa6384f69 | |||
| 72ebb39b22 | |||
| 8e01509e99 | |||
| e4de8e4287 | |||
| 18da8c2763 | |||
| a770e150a4 | |||
| 96993755da | |||
| 30db0f9182 | |||
| 8064e87017 | |||
| ef399668c4 | |||
| 72059e4623 | |||
| db5ee20a39 | |||
| ee4bf3d501 | |||
| 7b40578ea4 | |||
| 9685bff5ef | |||
| 3bff9a6fdc | |||
| bfa48cbbb1 | |||
| 4f2b251d20 | |||
| a1f1ffba95 | |||
| 1ab59fa9a6 | |||
| 800407ebd7 | |||
| 3dad6790fc | |||
| d073a8fd17 | |||
| a9068c45cd | |||
| ca78b09ad8 | |||
| 3e17a7239a | |||
| d78597cba4 | |||
| 91f28a8c82 | |||
| 03a7877899 | |||
| 46e8a19c53 | |||
| 81a42fc1d9 | |||
| fdbcc0c539 | |||
| 7d51ddb868 | |||
| 9f25bd2bf6 | |||
| a9ce0d82b6 | |||
| 83d2f329ce | |||
| 7e06512598 | |||
| b5776e82c9 | |||
| 05dd42b0bf | |||
| 636774ed86 | |||
| 6649af6e92 | |||
| acfff8e8d6 | |||
| 44c1bd7cee | |||
| c712e729cc | |||
| b684129f39 | |||
| 1b339289c1 | |||
| b246991600 | |||
| dc578d1f17 | |||
| 6c6f6d4d7e | |||
| 50dcb999f1 | |||
| c656cc95de | |||
| 0b0b5bbf33 | |||
| c2310327d2 | |||
| 9962471f71 | |||
| 8ad86f71d3 | |||
| 3a42baab00 | |||
| a1bfd0150c | |||
| 2e420fc540 | |||
| f591246ae3 | |||
| d4c02cf504 | |||
| e15878a9eb | |||
| 39f43b3361 | |||
| 18a6756860 | |||
| 3640b08041 | |||
| 928d47f772 | |||
| 28478cb11d | |||
| 0c48df7895 | |||
| 327f5af3dd | |||
| 62234f2edf | |||
| 2fcba55965 | |||
| d29768776a | |||
| 3dcf6d3ee0 | |||
| 7c2aa55eb8 | |||
| e92d64a05e | |||
| 0fa021be3e | |||
| 086bd574d5 | |||
| b46f26790d | |||
| c364d57e86 | |||
| 6d89e4d09b | |||
| 3391051bb8 | |||
| acba051357 | |||
| 785ae254ee | |||
| 21a189ea66 | |||
| 3a4a11d9e8 | |||
| 6d5d021884 | |||
| 185d403d7a | |||
| 349d983b7f | |||
| 85ed6b54f9 | |||
| 9b6b0c87aa | |||
| fd68a9b73a | |||
| 433ab4b0ec | |||
| df9fbc7f65 | |||
| a8253614b4 | |||
| 9977cae821 | |||
| 344010ed90 | |||
| 1c51fb717a | |||
| 81827a8368 | |||
| 21222a25e9 | |||
| 838f32e04c | |||
| d24a033e01 | |||
| bdaf4a5ac6 | |||
| 5e76d8db2a | |||
| bae92e626b | |||
| 0d471db37d | |||
| c4c6875e16 | |||
| 3515e5c976 | |||
| 84a6f4c4f1 | |||
| ee9ec1a8a7 | |||
| 1884a9184e | |||
| caa62588b6 | |||
| 8bb9803f5b | |||
| ea27c26597 | |||
| 80aaa94036 | |||
| a82c0de415 | |||
| 762ae4827f | |||
| 68b12b0cba | |||
| f61577ee64 | |||
| 87e4d8704c | |||
| a5f22e68d2 | |||
| cf261ab427 | |||
| 5bd3b02ff0 | |||
| 10f62b669c | |||
| 565aec0739 | |||
| 7112cf15da | |||
| 03a061ae1f | |||
| 1e21e37e3c | |||
| 9da3fe3daa | |||
| b127ca2222 | |||
| be688efd2c | |||
| 94b1318a56 | |||
| 2e9e120cdb | |||
| 1000b1abbe | |||
| 0f2246f033 | |||
| 9dfee9d605 | |||
| 3ecd9e365e | |||
| 78a13ae89b | |||
| 6f8ddf6aa5 | |||
| 03f9de19b3 | |||
| a74e9aeb92 | |||
| 709422856b | |||
| 034a3cb2b5 | |||
| a9caf10897 | |||
| 659908ecf7 | |||
| 7ebecd94cd | |||
| 5bcb9000a9 | |||
| fe622dd742 | |||
| ab5d7e74a2 | |||
| 68e6dd246f | |||
| 8fe2b50d5c | |||
| ebc8401989 | |||
| 67765fc7d2 | |||
| a303459b7d | |||
| 2b68967ce0 | |||
| b0194e569a | |||
| 164516166f | |||
| 3339cf1c9d | |||
| d635079e50 | |||
| 069ee22499 | |||
| e7082aef49 | |||
| ebf3a750a2 | |||
| a25dc83d30 | |||
| 7d0bc83b67 | |||
| 38a5b2510a | |||
| fe2d868ca6 | |||
| aca7cc07e6 | |||
| a1618ad2ad | |||
| 67756553f3 | |||
| 473c2e05b5 | |||
| 84560a94ea | |||
| 9a35af5b20 | |||
| ba899f3309 | |||
| 8b9454a684 | |||
| 612bc1e3de | |||
| 6f198e7d5a | |||
| 0c6f7f769b | |||
| 19e709fc3d | |||
| fd4636e6a6 | |||
| 62458a0640 | |||
| 43efca4045 | |||
| 5106ff9f12 | |||
| 3516a8c8de | |||
| 62857a9bb0 | |||
|
|
e1b85b8879 | ||
| 3f4a8b38eb | |||
| 99047236fc | |||
| 0f3c828c1f | |||
| 6d950cee38 | |||
| 2b426103cd | |||
| 876daa7df4 | |||
| cca26eb472 | |||
| a1c7f63976 | |||
| e83e7f03c8 | |||
| e4b08b9a61 | |||
| b4f8fa49da | |||
| 5842cf0048 | |||
| d75dd5ead7 | |||
| b6eed691d0 | |||
| 49626f4371 | |||
| 6e1d889eb8 | |||
| 0cf5dbd24b | |||
| 19d4c6b929 | |||
| a040670c5b | |||
| b9fd701098 | |||
| d39134c47e | |||
| fa0b2e338b | |||
| 0efc991231 | |||
| 965e9ee3b4 | |||
| 59aabd6a43 | |||
| 40f5649a5f | |||
| 45d067673c | |||
| 9634306d01 | |||
| d8e24764dc | |||
| 5cd2151f6c | |||
| 449aa664ab | |||
| 91f7269af4 | |||
| 29a8f6efc6 | |||
| be3b57b1c5 | |||
| cd5cfa88bc | |||
| d28e3578e4 | |||
| af6b053215 | |||
| cd3468fd50 | |||
| ac5361b9a8 | |||
| e7b3d65628 | |||
| 164f105878 | |||
| 605ec9a910 | |||
| 8d83789356 | |||
| 623d9d316a | |||
| bba6ae5d9b | |||
| db32ba0e15 | |||
| 02e2e73259 | |||
| 1bc1caa528 | |||
| 3637ba0048 | |||
| 7409d15cce | |||
| 563902d29e | |||
| c2994b8767 | |||
| 7a9b1fba4d | |||
| 88743f65c6 | |||
| 61cf7b8601 | |||
| 2663f039a0 | |||
| 0bac28fc98 | |||
| 9f696ec2cd | |||
| 8983748314 | |||
| bcb39b8829 | |||
| 3abf35028f | |||
| 58c7d31fea | |||
| 68db2d9591 | |||
| d6d342ba42 | |||
| 9b7ba6e6f4 | |||
| fc3fcaf80c | |||
| 8a2029f396 | |||
| 3b4d29d1c4 | |||
| 952e1b22f2 | |||
| 3151755a1f | |||
| 2659bbdc83 | |||
| d60ffea913 | |||
| 0144d6d7ef | |||
| 755132a1b9 | |||
| 0b1292ec55 | |||
| 4b4ba7bc10 | |||
| 8f365e77be | |||
| 5052f6dc2d | |||
| 42a9756d94 | |||
| 41fbeb333f | |||
| 279257a35d | |||
| 5d7d2cb99f | |||
| 9676b65be3 | |||
| 27f28abb9b | |||
| b3e390a634 | |||
| 2ae58205d8 | |||
| ea025c1f31 | |||
| 0a03b1d489 | |||
| 9d14673771 | |||
| ee9f4b08ff | |||
| cdc81c58e7 | |||
| 4c4b364177 | |||
| 0a46eda642 | |||
| 53fb1cb58e | |||
| 74dcedeba9 | |||
| 5848f82e4a | |||
| 797c5c7736 | |||
| b666064d15 | |||
| 532aa91b23 | |||
| 7f2c83ea69 | |||
| 307840c236 | |||
| 25321a9941 | |||
| dcbf627840 | |||
| 3e069d1c39 | |||
| 988712b234 | |||
| 123c7835d6 | |||
| d9d2b5bef7 | |||
| 99740104b9 | |||
| 3606aa99d9 | |||
| 673de9d9b1 | |||
| 0bebf87fa4 | |||
| 87cb0f8302 | |||
| 6b80520d8d | |||
| ab956b4a6e | |||
| 2831137dac | |||
| dabf6a0a54 | |||
| 7a6ddde702 | |||
| 17f4e1ad49 | |||
| 74227e6bf1 | |||
| fc2eee29a6 | |||
| 8cf75f9497 | |||
| 5b40bd4780 | |||
| 9899944a04 | |||
| 58335a5102 | |||
| 3507bc531c | |||
| 4bb4a6b34b | |||
| fe0927c0eb | |||
| 0d93dd2b1c | |||
| dad53637e8 | |||
| 853470701b | |||
| b1ee861a5c | |||
| 05857e2b11 | |||
| 60fb37ad8b | |||
| dae03dc91f | |||
| 5c81248472 | |||
| 7184c24f16 | |||
| a2be331295 | |||
| 18403554e7 | |||
| b1e189321c | |||
| e61b2532b1 | |||
| db56575b8f | |||
| 7832095b86 | |||
| 2bd8b6392c | |||
| 442af631aa | |||
| 2666e9a7ef | |||
| 7b3395dec8 | |||
| 7a15a94b38 | |||
| da8884dcdc | |||
| 54a09c2300 | |||
| 8818a42457 | |||
| d4a035fc0e | |||
| 3c5a0ba1f1 | |||
| c49f135e49 | |||
| a4d7d09c0b | |||
| 73b26249eb | |||
| 2581f537b1 | |||
| 8c14cd1937 | |||
| 597c2fe2a2 | |||
| 785b03455e | |||
| e7a581f326 | |||
| db85805afd | |||
| 3350677b23 | |||
| 8413be30a0 | |||
| 9033da0bf2 | |||
| 6dfd56c58e | |||
| 98e251478c | |||
| d31a28d3b5 | |||
| fd5867e5f1 | |||
| 13311f191e | |||
| 1f2ace8258 | |||
| 0aaba82e57 | |||
| 3888c1ce25 | |||
| 954eb96a2a | |||
| 057e3ac3c1 | |||
| 49cad4a71a | |||
| 8b593a3b21 | |||
| 6072ab57c9 | |||
| 120d85c1d3 | |||
| 13e2b1b3a4 | |||
| 6c705ab96b | |||
| 28e0c448f4 | |||
| 0b22aa9764 | |||
| a1b813f051 | |||
| 516874a6e5 | |||
| 5b31befcec | |||
| 19335be66b | |||
| 9ac451693b | |||
| 399f712024 | |||
| db38f84fca | |||
| fa94de4135 | |||
| 81b01dd5a8 | |||
| 085d6af657 | |||
| 5421cb12d2 | |||
| cd98c3884f | |||
| 92e60c95e3 | |||
| 227025b526 | |||
| 4647125b61 | |||
| 1217922b90 | |||
| 731c28f382 | |||
| 2c5deeceb6 | |||
| 8e727aeb73 | |||
| 273b76715a | |||
| 7aa8c71b3f | |||
| ac235c2b56 | |||
| b78ab2e308 | |||
| a44a307dd1 | |||
| c25d08c9ac | |||
| 695e784c73 | |||
| 0c3415b7d6 | |||
| b412860f1f | |||
| 85f5129057 | |||
| 74bfc38cd5 | |||
| 3ec6deaec6 | |||
| e2113d0660 | |||
| 8199b354d8 | |||
| 4e795f6a0a | |||
| 5f8732299a | |||
| 8babc6acfb | |||
| f193d21ffa | |||
| 6361e790b2 | |||
| 206927622a | |||
| b1ee82f0dc | |||
| 2529660f3b | |||
| 5c784a3f90 | |||
| d493749445 | |||
| 7e9c36ab77 | |||
| 904f5115b9 | |||
| 4387c4d1c3 | |||
| 9c481c5380 | |||
| 8eda08d060 | |||
|
|
ea493b3fa2 | ||
| e8bd3c0c99 | |||
| ac7bb55874 | |||
| 626a728529 | |||
| 9f9e1ef12d | |||
| c6526f6574 | |||
| a919c323ae | |||
| 00cb459c66 | |||
| e1bee4b70f | |||
| cd81b92bfe | |||
| 4120f20c5a | |||
| d43345c5fc | |||
| c0ad1f0770 | |||
| a2bd7bc9aa | |||
| 02eb94fdef | |||
| c6380a9e05 | |||
| 08b2cb3289 | |||
| 65009a6693 | |||
| cb0f18eb0b | |||
| 30108563a0 | |||
| bec0430942 | |||
| ed9952d37d | |||
| a656c81373 | |||
| d6c0271129 | |||
| d3ba9aae5f | |||
| 809a31ea87 | |||
| 63cf1920a9 | |||
| 3c79fb6745 | |||
| 4a86118707 | |||
| 9dfd8623a7 | |||
| 7e8b8a8bc4 | |||
| 554a78e40f | |||
| 32022652b3 | |||
| 3560f2a661 | |||
| 63265571ac | |||
| 73049f32eb | |||
| 1e9b48811c | |||
| 2312323649 | |||
| 9c634059ab | |||
| 57892e22ee | |||
| 9d6dd2ff5f | |||
| 2d1d15da98 | |||
| 08af6fddb2 | |||
| 1a97940826 | |||
| b2e6b0bd87 | |||
| c161857422 | |||
| 69343830a9 | |||
| f3644dcc3f | |||
| b8782a14c1 | |||
| 4825d59616 | |||
| e10f2d3a0c | |||
| 18f4f2770a | |||
|
|
fbf26157c1 | ||
| ee2e5c5938 | |||
| 8602bbf09d | |||
| 38ef2b297d | |||
| 452a2d2555 | |||
| d6794a904f | |||
| 18c2ae047e | |||
| 5581055f07 | |||
| fc0ac2ec4b | |||
| b64cd203eb | |||
| e436b9773e | |||
| 37cb5d90f4 | |||
| 15e598df7e | |||
| b43b6be4ac | |||
| 4036d2a04f | |||
| 90bc764e61 | |||
| 37fcfba74e | |||
| 9e5bfc6655 | |||
| 295fd59729 | |||
| 8c2cf7d9fe | |||
| efb786ed0d | |||
| 514500de0b | |||
| 304f0a53db | |||
| 645b269fc8 | |||
| 94ceff0753 | |||
| 7f16ca80f4 | |||
| 14c57d6ab5 | |||
| ce56820405 | |||
| 4e46f89440 | |||
| fa337ffb16 | |||
| bd3b915963 | |||
| 032a4e3aca | |||
| 3c4d62cde2 | |||
| d1a7a166a8 | |||
| e0a3dbcea2 | |||
| 112f083c9a | |||
| adccf68c45 | |||
| f84a18b9b6 | |||
| d7ef52f164 | |||
| 5a91589ac6 | |||
| 942dbeef5e | |||
| a18156014b | |||
| c5cbfd406f | |||
| abc2a0bb1e | |||
| 3568b6b17e | |||
| 93261bdb87 | |||
| 202261afc1 | |||
| 75d42d04ee | |||
| 6898cfc92c | |||
| e85b00c457 | |||
| ba1e8bb41c | |||
| 32ad423fc2 | |||
| 1661d60b94 | |||
| 438d62a362 | |||
| 0bb2cf76bf | |||
| 987a576bfd | |||
| 91ea98d9f2 | |||
| b64c01e7ce | |||
| be1ee50f32 | |||
| d2955085c5 | |||
| 10ed26c023 | |||
| 98cf6d5192 | |||
| 7e0ee7192e | |||
| f68690a01b | |||
| fcdbe8ab94 | |||
| 19568d1394 | |||
| 425b4b544f | |||
| 5dc8949215 | |||
| 1497a55607 | |||
| 6f94a290ee | |||
| 911271a6b1 | |||
| d955609d93 | |||
| eddd9ff8e7 | |||
| dcd3b0aace | |||
| 77a2fef606 | |||
| d54da02dc0 | |||
| 7e4c36a785 | |||
| 1bee7e59ab | |||
| d629f0a21d | |||
| eecadba27d | |||
| ab764a9a50 | |||
| 6027df9ee5 | |||
| 7d831c59e7 | |||
| eaf8e4779e | |||
| 84669f3929 | |||
| 9b3184281c | |||
| 7dff05df5c | |||
| b88a5bface | |||
| 48b87b7b48 | |||
| bc512ab8f2 | |||
| b73d2e9bac | |||
| bc18dc3231 | |||
| d660bb592b | |||
| a5478ef619 | |||
| c8034042aa | |||
| bff520b2ab | |||
| 71eeba9091 | |||
| f30284a30b | |||
| 8932e3ac98 | |||
| 856b759acc | |||
| c6271341b8 | |||
| b68a7aebd4 | |||
| c682331a22 | |||
| af6bc8ebe9 | |||
| 685fa64f46 | |||
| 1456749587 | |||
| dac957e5b0 | |||
| f8fd7820bc | |||
| db35c3d914 | |||
| fde32f2314 | |||
| dee4485a89 | |||
| ef58f2e65c | |||
| d5763c1d03 | |||
| 26d83ddabf | |||
| d0369d85c5 | |||
| dbba2e3fb3 | |||
| 6248e0da07 | |||
| c9fac89d16 | |||
| 11431e37c9 | |||
| 827fc6836c | |||
| 262d6d0f08 | |||
| ea5c880b0a | |||
| 182bd07d6c | |||
| 66a514468f | |||
| ff41b7e0dd | |||
| de6e0865ac | |||
| 6b8a2fb4c0 | |||
| 86e0750f03 | |||
| d0bb5e9342 | |||
| 9712d81a7d | |||
| cea2af9237 | |||
| 6734cfdde2 | |||
| 8f6ce309a2 | |||
| d551f029a8 | |||
| 87204b30bd | |||
| 28faad2491 | |||
| 839942ea40 | |||
| d24f5387dc | |||
| 521cc48e56 | |||
| 44a9d7dbd2 | |||
| 74d3dc0a67 | |||
| acc35b8cc8 | |||
| b9b756a811 | |||
| c1e979391d | |||
| 5fd28fddd1 | |||
| 8a1ef5c6cf | |||
| da57dfed5b | |||
| d60b57ff02 | |||
| 9c85f5da3c | |||
| 8357a33df8 | |||
| 7a150516b4 | |||
| ddf518d11a | |||
| cf69cccbce | |||
| 68c220b8a8 | |||
| 1b05d58049 | |||
| 925e08ffc7 | |||
| 90f86858e9 | |||
| 6c1652e955 | |||
| af364d4220 | |||
| b97bd848a8 | |||
| 4dedea79cf | |||
| 29963759f2 | |||
| 70c1723c5d | |||
| c0b67577a7 | |||
| 82a74cbf1c | |||
| 56fbc96d9a | |||
| 7d629b5753 | |||
| 56d7876eb5 | |||
| af0f1e14b0 | |||
| 20c6adc41f | |||
| cfe0ae52e8 | |||
| 49cbc45ac0 | |||
| 8672c7df11 | |||
| 6177a4b3c4 | |||
| 50c57d1977 | |||
| 79355eab19 | |||
| d4f2032aa7 | |||
| d1a1aad1d8 | |||
| d94f0f1a7e | |||
| 7507ab834c | |||
| a2c007119b | |||
| 7e421762d7 | |||
| a24e26b436 | |||
| 1008229297 | |||
| cf492ee2a0 | |||
| dac93e9e30 | |||
| aaac5bebb7 | |||
| 46002e7580 | |||
| 5982c8e966 | |||
| 6889372e40 | |||
| 158ccaa3ce | |||
| a0014d5ccd | |||
| 44091910ff | |||
| b25dff5d48 | |||
| 163613f836 | |||
| b163c74771 | |||
| 8068110cf3 | |||
| 78f91d2cfe | |||
| b39f07414b | |||
| e3be231990 | |||
| 3ee2272886 | |||
| 6c58a19495 | |||
| 2d11f53330 | |||
| ad7274fdbf | |||
| fd2f4772ce | |||
| 2f649932b6 | |||
| 198e1d284b | |||
| 5041244f63 | |||
| 592c4f4b9a | |||
| cb7a45d83e | |||
| 6c95492412 | |||
| e026f9a0ea | |||
| 17c5b96c98 | |||
| eddad11630 | |||
| 0f65aaffab | |||
| 8723751f78 | |||
| 24db8fbcec | |||
| c687831f4f | |||
| b878529840 | |||
| e6ee9c7090 | |||
| ab9672cae3 | |||
| 3dc3aea47b | |||
| c8fdf2634d | |||
| 295afc7acc | |||
| 450848b080 | |||
| d154ee9852 | |||
| ff2420c551 | |||
| 096650b4f6 | |||
| b5a2d999e6 | |||
| 92bc126e24 | |||
| 966f73aef3 | |||
| 77ff799dba | |||
| 4804ec24c1 | |||
| b1c3935457 | |||
| 6301305b1a | |||
| 5d0b300e2a | |||
| eac86126c2 | |||
| a3552e0926 | |||
| 3bd6521967 | |||
| e189aa4f6c | |||
| e318d8625b | |||
| 0f91128b8e | |||
| d5eb4c62f6 | |||
| 360fa9e59f | |||
| a3df8d0822 | |||
| b902879a26 | |||
|
|
e570b32e05 | ||
| c2612e40b4 | |||
| c9ee41a1b1 | |||
| cc8b20d065 | |||
| 6cade2576e | |||
| a64e219632 | |||
| 3884a6736f | |||
| 03664cd9a5 | |||
| ee48302a0b | |||
| 9d724911ad | |||
| 3fcd649cce | |||
| 3a05e2c10d | |||
| e02fe6c36c | |||
| eaf10604ef | |||
| 26ca33258c | |||
| 4a0382cafc | |||
| 450252ff24 | |||
| f399b1a4cf | |||
| aaed6e7e0a | |||
| 9ef98b50e3 | |||
| 52b712ce32 | |||
| cd00a16aa3 | |||
| 80429f1700 | |||
| 73d80ef2bc | |||
| 36a66ee50d | |||
| 4a954c5870 | |||
| 9e4f099515 | |||
| bb21bc678e | |||
| 8e3a4afb5b | |||
| 55975c45c9 | |||
| 52adf80a2e | |||
| bc349742ef | |||
| 9fdc1f6b0e | |||
| 5cfff0e143 | |||
| bfce428f2c | |||
| 1e8745fc31 | |||
| 39ffb2ea49 | |||
| 69cb18762a | |||
| 1ba5e25eba | |||
| fe6343f4e4 | |||
| 772242fcae | |||
| 777c3e7aac | |||
| e799d0e577 | |||
| c3e8ccf0c2 | |||
| ce198e1da9 | |||
| 17b821157e | |||
| 32c7424c89 | |||
| df4e76f05e | |||
| cce5fa85d3 | |||
| f13b021fcd | |||
| 49499c1b91 | |||
| ea62524763 | |||
| 0b0942b995 | |||
| b530ec1821 | |||
| bc502cbf74 | |||
| 811b686f17 | |||
| 4fd2d5494e | |||
| f857b2ed95 | |||
| 3a64d116e6 | |||
| b44f2bb2f9 | |||
| 39d63497bb | |||
| b2250bf3cf | |||
| 54517ba92e | |||
| 3ae1d3cefe | |||
| a3eade290e | |||
| d6ac2f00b6 | |||
| 63727411c4 | |||
| 4100c9cc03 | |||
| f58282e73b | |||
| 566f748fb3 | |||
| 4630a53881 | |||
| 6fca8f90e6 | |||
| 9700db0dbc | |||
| 1fb09d1a41 | |||
| da8bc54f90 | |||
| 4b823e3b82 | |||
| 726aa7f080 | |||
| 14062da824 | |||
| 4bdf4ab779 | |||
| d454b4b8b1 | |||
| b4e22ca7a4 | |||
| e7abca0cc0 | |||
| 6ad433488e | |||
| 1c63622538 | |||
| 55f05f0541 | |||
| 192a45786d | |||
| 79f3105797 | |||
| 70e5dad7c1 | |||
| 63b46cd93f | |||
| 7872a82cc1 | |||
| 05ea13b155 | |||
| bcc00e39da | |||
| 5d3a79827c | |||
| 6f04ea323c | |||
| eb7c41841b | |||
| bbfcbeb906 | |||
| 36c0e3c9d1 | |||
| e3f2eab10b | |||
| b81c7febbe | |||
| 97c7ac188c | |||
| 4d7a856ffb | |||
| 94add3ecde | |||
| 89ba0a60bf | |||
| be1480e2f0 | |||
| 5e4ec2c630 | |||
| 1a76055a09 | |||
| 2b4e97d90d | |||
| dfae26c49e | |||
| d78010662a | |||
| 79df2c503f | |||
| a42736bf91 | |||
| e53bd108ba | |||
| e9f47d4651 | |||
| 951f220626 | |||
| 3106ce46d9 | |||
| f8f22ee3b3 | |||
| 79576c06f7 | |||
| 7058231691 | |||
| 6f876edfa8 | |||
| 6b2ca47a8a | |||
| 92f5f7b290 | |||
| a6103e037d | |||
| b6299d6dd1 | |||
| 9f76fcfc72 | |||
| 08b5d93be3 | |||
| 77a1a965ca | |||
| a4d78c740d | |||
| 65fb43f87a | |||
| 9f27301e8b | |||
| ce583d2500 | |||
| 8c4430d68a | |||
| 65c26a1f91 | |||
| 653f3a023a | |||
| 3c241ea168 | |||
| 4f88d08a39 | |||
| 1bcffcc36a | |||
| 6eeb10868d | |||
| 4b1af00c23 | |||
| fd4d79c3be | |||
| 4d4ca3917f | |||
| f5f86985c9 | |||
| e2f5b5b0a1 | |||
| 00405d67bb | |||
| b3475b9fcb | |||
| 6fc946d817 | |||
| 7893e6d808 | |||
| a205f222b0 | |||
| e99bf3403b | |||
| 124a4fe04c | |||
| 3a18dd2c71 | |||
| 6e7167f0f2 | |||
| 2188fa86a5 | |||
| e41883bd73 | |||
| eddaadc3ba | |||
| 7c08f0ed48 | |||
| 77c8896de5 | |||
| b078028c24 | |||
| b40e26fc5e | |||
| 5a2f5328b4 | |||
| 33dc3129b3 | |||
| 0dc6e9555f | |||
| 6df7c809a2 | |||
| 8c451e3996 | |||
| 468a453b94 | |||
| 6f52677301 | |||
| 63a891d061 | |||
| 15b80239d1 | |||
| 044540ff10 | |||
| 90f3a636db | |||
| 592d8726d2 | |||
| 048c639e72 | |||
| 1111093b38 | |||
| 87461ce43a | |||
| 247ecb69a3 | |||
| b414942de9 | |||
| 5b1b5c5cde | |||
| b9a53ec7a2 | |||
| f1f779b436 | |||
| 06e9bb1c51 | |||
| 833d87f08d | |||
| 3627c38df6 | |||
| e5c64dc0fd | |||
| 4ca6e3e5e9 | |||
| ab0b17470e | |||
| 70e8857031 | |||
| db2b8214a4 | |||
| bfd102a4a2 | |||
| 59780fef0c | |||
| aea6d9dc68 | |||
| 1454144502 | |||
| ac997e5e52 | |||
| 2831f675f2 | |||
| 214c6f6bf1 | |||
| 2d109a57e6 | |||
| c9b98963ae | |||
| 945aeab210 | |||
| 956acd02ad | |||
| ff84144dbf | |||
| cfc60bb78d | |||
| 371ba4848c | |||
| 1963825bf5 | |||
| 7421ebeea9 | |||
| edff5ae3ec | |||
| d8ede199ed | |||
| 5fdd9d447a | |||
| a21c13f798 | |||
| 94f21f78a8 | |||
| 77549064f1 | |||
| 05a092a664 | |||
| 934463a2a4 | |||
| c62112e9d6 | |||
| 36b2d99f5a | |||
| b828a31544 | |||
| 4656fbb61b | |||
| 7e9e207b66 | |||
| 47755e2c56 | |||
| 33582c62d4 | |||
| 46ef9bd59e | |||
| 25d549f681 | |||
| 5cbede1c68 | |||
| 5feea9ced0 | |||
| c77f212ca1 | |||
| 7dcdb85ee0 | |||
| 402ddc0009 | |||
| aff3eaa959 | |||
| 61de052e30 | |||
| e838df2876 | |||
| 4f65d93a65 | |||
| 1f3517a10b | |||
| 3df0a0058d | |||
| 096c25955c | |||
| 6f3d8a7ef5 | |||
| 8448a8798d | |||
| 36acbe175a | |||
| f08b5fe07e | |||
| 54804ec4d6 | |||
| 269d0d4aff | |||
| f24ebd5cbc | |||
| 48070baf25 | |||
| d266c8c9e1 | |||
| 6c15210a22 | |||
| 8eddffdc7c | |||
| 0187c33730 | |||
| acb33cad0f | |||
| 17fca32238 | |||
| 8997e8187e | |||
| 0729d1c0b6 | |||
| a15bf9957a | |||
| 9c48a57743 | |||
| 7a97a55df1 | |||
| ab7aa9e0bf | |||
| a6a9a3cbd8 | |||
| 122e56bfe7 | |||
| de9d870ef3 | |||
| 274bb29f8f | |||
| 5e145dd854 | |||
| 6b9a0d7e3e | |||
| 625b715924 | |||
| d2bff17463 | |||
| 910ab51654 | |||
| 70979f1509 | |||
| 18ae32a815 | |||
| 8fcc9a4bf8 | |||
| cb221ce6f3 | |||
| db884eb487 | |||
| 2faf943cb9 | |||
| 5d1a052416 | |||
| e32099263d | |||
| 27ef2e7e16 | |||
| 0b94f3125c | |||
| 71e075fe02 | |||
| 0b8b1cb756 | |||
| 47be0ec2b8 | |||
| 89f16ff2a3 | |||
| c4eced0d37 | |||
| 4def90c387 | |||
| 51dd49cc8f | |||
| 04c5b8c849 | |||
| 1d0fed90ae | |||
| 88a518d0ad | |||
| 304abac5bb | |||
| ca323b87f6 | |||
| 4e4cab2cbd | |||
| a3130d68c2 | |||
| 72c7a3a281 | |||
| 5b78ac6a34 | |||
| 62ba5f28a1 | |||
| 0d85a0b790 | |||
| e818130c1d | |||
| add08fc985 | |||
| e762d706d9 | |||
| d94bd75770 | |||
| 376aaf7f28 | |||
| 2a4ae878bb | |||
| b87f320664 | |||
| aca25727c0 | |||
| a9cbbed8e2 | |||
| 32c38b85aa | |||
| c7bd74553e | |||
| 76972b00a1 | |||
| f5b812ebdf | |||
| 7eddb4fe7c | |||
| c7a96834a2 | |||
| a7c3163d84 | |||
| bd4390c08b | |||
| 85bd22feb3 | |||
| ecd0675c78 | |||
| 0826bea857 | |||
| a0983b0572 | |||
| 8efceb6405 | |||
| ebc26db5f0 | |||
| b9fc94b383 | |||
| 3bcfc65dcb | |||
| 611616e719 | |||
| c4455218dd |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -122,3 +122,5 @@ fabric.properties
|
|||||||
/temp
|
/temp
|
||||||
/docker/tomcat/conf/integry/logs.db
|
/docker/tomcat/conf/integry/logs.db
|
||||||
/docker/tomcat/conf/integry/logs.db-journal
|
/docker/tomcat/conf/integry/logs.db-journal
|
||||||
|
copilot.*.xml
|
||||||
|
/.idea/dataSources.xml
|
||||||
|
|||||||
6
.idea/copilot.data.migration.edit.xml
generated
Normal file
6
.idea/copilot.data.migration.edit.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EditMigrationStateService">
|
||||||
|
<option name="migrationStatus" value="COMPLETED" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
18
.idea/copilotDiffState.xml
generated
Normal file
18
.idea/copilotDiffState.xml
generated
Normal file
File diff suppressed because one or more lines are too long
33
.idea/dataSources.xml
generated
33
.idea/dataSources.xml
generated
@@ -1,11 +1,40 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
<data-source source="LOCAL" name="@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
|
<data-source source="LOCAL" name="Biolevante@SERVERDB2019" uuid="ff4f0bad-7271-429e-a4e1-bae28629efc8">
|
||||||
<driver-ref>sqlserver.ms</driver-ref>
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
<jdbc-url>jdbc:sqlserver://SERVERDB2019</jdbc-url>
|
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Biolevante</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="Gramm@SERVERDB2019" uuid="02282d62-6d2a-4b83-bdcf-b558fa6db140">
|
||||||
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlserver://SERVERDB2019\MSSQLSERVER;database=Gramm</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="vgalimenti@SERVERDB" uuid="eaf0bcaf-4620-478b-b63c-42e77902813f">
|
||||||
|
<driver-ref>sqlserver.ms</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlserver://SERVERDB\MSSQLSERVER;database=vgalimenti</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
8
.idea/data_source_mapping.xml
generated
Normal file
8
.idea/data_source_mapping.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourcePerFileMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query.sql" value="ff4f0bad-7271-429e-a4e1-bae28629efc8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_1.sql" value="02282d62-6d2a-4b83-bdcf-b558fa6db140" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" value="eaf0bcaf-4620-478b-b63c-42e77902813f" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/db-forest-config.xml
generated
Normal file
6
.idea/db-forest-config.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="db-tree-configuration">
|
||||||
|
<option name="data" value="---------------------------------------- 1:0:ff4f0bad-7271-429e-a4e1-bae28629efc8 2:0:02282d62-6d2a-4b83-bdcf-b558fa6db140 3:0:eaf0bcaf-4620-478b-b63c-42e77902813f " />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1822
.idea/inspectionProfiles/LocalDate_Checks.xml
generated
Normal file
1822
.idea/inspectionProfiles/LocalDate_Checks.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
2485
.idea/inspectionProfiles/Project_Default.xml
generated
2485
.idea/inspectionProfiles/Project_Default.xml
generated
File diff suppressed because it is too large
Load Diff
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="PROJECT_PROFILE" value="LocalDate Checks" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="central" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Tomcat 9 (RistoCash)" type="Remote">
|
<configuration default="false" name="Tomcat 9 (AnydeskTunnel)" type="Remote">
|
||||||
<module name="ems-engine" />
|
<module name="ems-engine" />
|
||||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||||
<option name="SERVER_MODE" value="false" />
|
<option name="SERVER_MODE" value="false" />
|
||||||
<option name="SHMEM_ADDRESS" />
|
<option name="SHMEM_ADDRESS" />
|
||||||
<option name="HOST" value="127.0.0.1" />
|
<option name="HOST" value="localhost" />
|
||||||
<option name="PORT" value="8001" />
|
<option name="PORT" value="8001" />
|
||||||
<option name="AUTO_RESTART" value="false" />
|
<option name="AUTO_RESTART" value="false" />
|
||||||
<RunnerSettings RunnerId="Debug">
|
<RunnerSettings RunnerId="Debug">
|
||||||
16
.idea/runConfigurations/Tomcat__AnydeskTunnel_.xml
generated
16
.idea/runConfigurations/Tomcat__AnydeskTunnel_.xml
generated
@@ -1,16 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="Tomcat (AnydeskTunnel)" type="Remote">
|
|
||||||
<module name="ems-engine" />
|
|
||||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
|
||||||
<option name="SERVER_MODE" value="false" />
|
|
||||||
<option name="SHMEM_ADDRESS" />
|
|
||||||
<option name="HOST" value="servertomcat" />
|
|
||||||
<option name="PORT" value="8001" />
|
|
||||||
<option name="AUTO_RESTART" value="false" />
|
|
||||||
<RunnerSettings RunnerId="Debug">
|
|
||||||
<option name="DEBUG_PORT" value="8001" />
|
|
||||||
<option name="LOCAL" value="false" />
|
|
||||||
</RunnerSettings>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
8
.idea/sqldialects.xml
generated
Normal file
8
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query.sql" dialect="TSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_1.sql" dialect="TSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/.idea/queries/Query_2.sql" dialect="TSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
30
.idea/structuralSearch.xml
generated
Normal file
30
.idea/structuralSearch.xml
generated
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="StructuralSearch">
|
||||||
|
<searchConfiguration name="LocalDate passato a SimpleDateFormat" text="$formatter$.format($date$)" recursive="true" caseInsensitive="true" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="formatter" nameOfExprType="java\.text\.SimpleDateFormat" within="" contains="" />
|
||||||
|
<constraint name="date" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="LocalDate equals java.util.Date inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="java.util.Date equals LocalDate inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.time\.LocalDate" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="java.util.Date equals LocalDateTime inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.time\.LocalDateTime" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
<searchConfiguration name="LocalDateTime equals java.util.Date inspection" text="$d1$.equals($d2$)" recursive="true" caseInsensitive="false" type="JAVA" pattern_context="default">
|
||||||
|
<constraint name="__context__" within="" contains="" />
|
||||||
|
<constraint name="d1" nameOfExprType="java\.time\.LocalDateTime" within="" contains="" />
|
||||||
|
<constraint name="d2" nameOfExprType="java\.util\.Date" within="" contains="" />
|
||||||
|
</searchConfiguration>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
42
Dockerfile
42
Dockerfile
@@ -1,11 +1,45 @@
|
|||||||
FROM tomcat:9-jre8-alpine
|
FROM tomcat:9-jre8
|
||||||
|
|
||||||
RUN apk add --no-cache fontconfig ttf-dejavu
|
|
||||||
|
|
||||||
ENV TZ="Europe/Rome"
|
ENV TZ="Europe/Rome"
|
||||||
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx1G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
ENV JAVA_OPTS="-DDISABLE_DROOLS_COMPILE=TRUE -Xms512M -Xmx2G -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
|
||||||
ENV USERDOMAIN="STUDIO-ML"
|
ENV USERDOMAIN="STUDIO-ML"
|
||||||
|
|
||||||
|
# Install Samba
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y samba samba-common-bin && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Ensure log directory exists and is readable
|
||||||
|
RUN mkdir -p /usr/local/tomcat/logs && \
|
||||||
|
chmod -R 755 /usr/local/tomcat/logs
|
||||||
|
|
||||||
|
# Create samba user (no login) and add to root group
|
||||||
|
RUN useradd -M -s /usr/sbin/nologin sambauser && \
|
||||||
|
printf "sambapass\nsambapass\n" | smbpasswd -a -s sambauser && \
|
||||||
|
usermod -aG root sambauser
|
||||||
|
|
||||||
|
# Samba configuration
|
||||||
|
RUN printf "\
|
||||||
|
[global]\n\
|
||||||
|
workgroup = STUDIO-ML\n\
|
||||||
|
security = user\n\
|
||||||
|
map to guest = never\n\
|
||||||
|
server role = standalone server\n\
|
||||||
|
unix extensions = no\n\
|
||||||
|
client min protocol = NT1\n\
|
||||||
|
\n\
|
||||||
|
[tomcat-logs]\n\
|
||||||
|
comment = Tomcat logs (read-only)\n\
|
||||||
|
path = /usr/local/tomcat/logs\n\
|
||||||
|
browseable = yes\n\
|
||||||
|
read only = yes\n\
|
||||||
|
guest ok = no\n\
|
||||||
|
valid users = sambauser\n\
|
||||||
|
force user = root\n\
|
||||||
|
create mask = 0644\n\
|
||||||
|
directory mask = 0755\n\
|
||||||
|
" > /etc/samba/smb.conf
|
||||||
|
|
||||||
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems.properties /usr/local/tomcat/conf/integry/
|
||||||
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems_automated_operations.json /usr/local/tomcat/conf/integry/
|
||||||
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
COPY docker/tomcat/conf/integry/ems_settings.json /usr/local/tomcat/conf/integry/
|
||||||
|
|||||||
@@ -10,12 +10,29 @@ pipeline {
|
|||||||
stage('PreBuild Steps (Master)') {
|
stage('PreBuild Steps (Master)') {
|
||||||
when {
|
when {
|
||||||
expression {
|
expression {
|
||||||
return env.GIT_BRANCH == "master"
|
return env.GIT_BRANCH == "master" || env.GIT_BRANCH == "feature/RefactoringGestioneColli"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
echo "Creo version tag su Git"
|
echo "Creo version tag su Git"
|
||||||
bat 'build\\create_build_tag.bat'
|
script {
|
||||||
|
def date = new Date()
|
||||||
|
def formattedDate = date.format('yyyyMMdd_HHmm')
|
||||||
|
|
||||||
|
def tagName = "${env.GIT_BRANCH.toLowerCase().replace('/', '-')}-${formattedDate}"
|
||||||
|
def tagMessage = "Build #${env.BUILD_NUMBER} - ${env.GIT_BRANCH}"
|
||||||
|
|
||||||
|
def envPropertiesText = "project.version=${formattedDate}"
|
||||||
|
|
||||||
|
writeFile(
|
||||||
|
'file': 'ems-core\\src\\main\\resources\\configs\\env.properties',
|
||||||
|
'text': envPropertiesText
|
||||||
|
)
|
||||||
|
|
||||||
|
bat "git add . -A"
|
||||||
|
bat "git tag -a ${tagName} -m \"${tagMessage}\""
|
||||||
|
bat "git push origin ${tagName}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Maven Build') {
|
stage('Maven Build') {
|
||||||
@@ -25,7 +42,7 @@ pipeline {
|
|||||||
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
bat(script: 'mvn clean install -t toolchains-jenkins.xml', returnStdout: true)
|
||||||
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
archiveArtifacts(artifacts: 'ems-engine/target/ems-api.war', onlyIfSuccessful: true)
|
||||||
}
|
}
|
||||||
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'docker-files'
|
stash includes: 'ems-engine/target/ems-api.war,docker/**,Dockerfile', name: 'container-files'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +118,7 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
|||||||
steps {
|
steps {
|
||||||
node('server-build') {
|
node('server-build') {
|
||||||
echo "Building Docker image"
|
echo "Building Docker image"
|
||||||
unstash 'docker-files'
|
unstash 'container-files'
|
||||||
|
|
||||||
script {
|
script {
|
||||||
def branchVersion = ""
|
def branchVersion = ""
|
||||||
@@ -110,7 +127,9 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
|||||||
branchVersion = "-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}"
|
branchVersion = "-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}"
|
||||||
}
|
}
|
||||||
|
|
||||||
bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
// bat "docker buildx build --platform linux/amd64,linux/arm64 --push -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||||
|
bat "podman build -t \"git.studioml.it/integry/ems-api${branchVersion}:latest\" ."
|
||||||
|
bat "podman push \"git.studioml.it/integry/ems-api${branchVersion}:latest\""
|
||||||
|
|
||||||
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
//containerImageLink "git.studioml.it/integry/ems-api-${env.GIT_BRANCH.toLowerCase().replace('/', '-')}:latest}"
|
||||||
}
|
}
|
||||||
@@ -169,14 +188,14 @@ sleep 10''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaul
|
|||||||
success {
|
success {
|
||||||
script {
|
script {
|
||||||
if (env.GIT_BRANCH == "master" || env.GIT_BRANCH == "develop") {
|
if (env.GIT_BRANCH == "master" || env.GIT_BRANCH == "develop") {
|
||||||
office365ConnectorSend adaptiveCards: true, color: '#008000', message: 'EMS-API ` stato compilato con successo', status: 'SUCCESS', webhookUrl: 'https://prod-197.westeurope.logic.azure.com:443/workflows/69a7b8ee3c284175bd6da7127c7eb3cf/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_-eMfvsQGkIidHWzzlhGFgiZG28ujHZ41QqzuqD9YGw'
|
office365ConnectorSend adaptiveCards: true, color: '#008000', message: 'EMS-API è stato compilato con successo', status: 'SUCCESS', webhookUrl: 'https://prod-197.westeurope.logic.azure.com:443/workflows/69a7b8ee3c284175bd6da7127c7eb3cf/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_-eMfvsQGkIidHWzzlhGFgiZG28ujHZ41QqzuqD9YGw'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unstable {
|
unstable {
|
||||||
script {
|
script {
|
||||||
if (env.GIT_BRANCH == "master" || env.GIT_BRANCH == "develop") {
|
if (env.GIT_BRANCH == "master" || env.GIT_BRANCH == "develop") {
|
||||||
office365ConnectorSend adaptiveCards: true, color: '#FFDE21', message: 'EMS-API ` INSTABILE', status: 'UNSTABLE', webhookUrl: 'https://prod-197.westeurope.logic.azure.com:443/workflows/69a7b8ee3c284175bd6da7127c7eb3cf/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_-eMfvsQGkIidHWzzlhGFgiZG28ujHZ41QqzuqD9YGw'
|
office365ConnectorSend adaptiveCards: true, color: '#FFDE21', message: 'EMS-API è INSTABILE', status: 'UNSTABLE', webhookUrl: 'https://prod-197.westeurope.logic.azure.com:443/workflows/69a7b8ee3c284175bd6da7127c7eb3cf/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_-eMfvsQGkIidHWzzlhGFgiZG28ujHZ41QqzuqD9YGw'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
REM SET YEAR
|
|
||||||
set YEAR=%date:~6,4%
|
|
||||||
|
|
||||||
REM SET MONTH
|
|
||||||
set MONTH=%date:~3,2%
|
|
||||||
if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
|
|
||||||
if %MONTH% LSS 10 set MONTH=0%MONTH%
|
|
||||||
|
|
||||||
REM SET DAY
|
|
||||||
set DAY=%date:~0,2%
|
|
||||||
if %DAY% LSS 10 set DAY=%DAY:~1,2%
|
|
||||||
if %DAY% LSS 10 set DAY=0%DAY%
|
|
||||||
|
|
||||||
REM SET HOUR
|
|
||||||
set HOUR=%time:~0,2%
|
|
||||||
if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
|
|
||||||
if %HOUR% LSS 10 set HOUR=0%HOUR%
|
|
||||||
|
|
||||||
REM SET MINUTE
|
|
||||||
set MINUTE=%time:~3,2%
|
|
||||||
if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
|
|
||||||
if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
|
|
||||||
|
|
||||||
REM SET SECOND
|
|
||||||
set SECOND=%time:~6,2%
|
|
||||||
if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
|
|
||||||
if %SECOND% LSS 10 set SECOND=0%SECOND%
|
|
||||||
|
|
||||||
set mydate=%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo #spring.profiles.active=@activatedProperties@ > ems-core\src\main\resources\configs\env.properties
|
|
||||||
echo project.version=%mydate% >> ems-core\src\main\resources\configs\env.properties
|
|
||||||
|
|
||||||
|
|
||||||
git add . -A
|
|
||||||
git commit -m "%mydate%"
|
|
||||||
git tag "%mydate%"
|
|
||||||
|
|
||||||
|
|
||||||
git push https://git.studioml.it/Integry/IntegryManagementSystem.git --tags
|
|
||||||
git push https://git.studioml.it/Integry/IntegryManagementSystem.git --all
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -229,6 +229,11 @@
|
|||||||
<artifactId>arial-rounded</artifactId>
|
<artifactId>arial-rounded</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.integry.font</groupId>
|
||||||
|
<artifactId>NotoSerif</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.groovy</groupId>
|
<groupId>org.apache.groovy</groupId>
|
||||||
@@ -355,11 +360,6 @@
|
|||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
|
||||||
<version>${jackson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
<artifactId>jackson-dataformat-csv</artifactId>
|
<artifactId>jackson-dataformat-csv</artifactId>
|
||||||
@@ -368,6 +368,11 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
<version>2.20</version> <!-- Versione scritta a mano perché qui non hanno usato lo 0 finale -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@@ -399,6 +404,17 @@
|
|||||||
<artifactId>spring-orm</artifactId>
|
<artifactId>spring-orm</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-jpa</artifactId>
|
||||||
|
<version>2.7.18</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<version>5.6.15.Final</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
@@ -567,7 +583,7 @@
|
|||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt-jackson</artifactId>
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
<version>0.11.5</version>
|
<version>0.11.5</version>
|
||||||
<scope>runtime</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--Expiring Map-->
|
<!--Expiring Map-->
|
||||||
|
|||||||
@@ -768,7 +768,7 @@ public class WooCommerceService {
|
|||||||
|
|
||||||
private void sendErrorMail(String errorMsg, String service, byte[] content, String filename, List<AnomalieDTO> anomalie) {
|
private void sendErrorMail(String errorMsg, String service, byte[] content, String filename, List<AnomalieDTO> anomalie) {
|
||||||
try {
|
try {
|
||||||
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager, service, "WOOCOMMERCE", "Errore WooCommerce",
|
mailService.sendErrorMailByGestNameSection(multiDBTransactionManager.getPrimaryConnection(), service, "WOOCOMMERCE", "Errore WooCommerce",
|
||||||
null, content, filename, anomalie);
|
null, content, filename, anomalie);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
logger.error(service, exception);
|
logger.error(service, exception);
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package it.integry.annotations;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import org.springframework.stereotype.Indexed;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Indexed
|
||||||
|
public @interface CustomerComponent {
|
||||||
|
IntegryCustomer value();
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package it.integry.annotations;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@CustomerComponent(IntegryCustomer.Integry) // Valore di default, verrà sovrascritto
|
||||||
|
public @interface CustomerService {
|
||||||
|
@AliasFor(
|
||||||
|
annotation = CustomerComponent.class
|
||||||
|
)
|
||||||
|
IntegryCustomer value();
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final String INTEGRY = "integry";
|
public static final String INTEGRY = "integry";
|
||||||
public static final String PROFILE_DB = "profileDb";
|
public static final String PROFILE_DB = "profileDb";
|
||||||
|
public static final String COD_MDEP = "codMdep";
|
||||||
public static final String WHERE_COND = "whereCond";
|
public static final String WHERE_COND = "whereCond";
|
||||||
public static final String EMPTY_STRING = "";
|
public static final String EMPTY_STRING = "";
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ public class CommonConstants {
|
|||||||
public static final String TIMESTAMP = "timestamp";
|
public static final String TIMESTAMP = "timestamp";
|
||||||
|
|
||||||
|
|
||||||
|
public static final String DATE_FORMAT_YMD_SLASHED = "yyyy/MM/dd";
|
||||||
public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
|
public static final String DATE_FORMAT_YMD = "yyyy-MM-dd";
|
||||||
public static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
public static final String DATE_FORMAT_DMY = "dd/MM/yyyy";
|
||||||
public static final String DATE_FORMAT_DMY_DASHED = "dd-MM-yyyy";
|
public static final String DATE_FORMAT_DMY_DASHED = "dd-MM-yyyy";
|
||||||
@@ -27,7 +29,7 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final String TIME_FORMAT = "HH:mm:ss";
|
public static final String TIME_FORMAT = "HH:mm:ss";
|
||||||
|
|
||||||
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_YMD = String.format("%s %s", DATE_FORMAT_YMD_SLASHED, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY_SLASHED = String.format("%s %s", DATE_FORMAT_DMY, TIME_FORMAT);
|
||||||
public static final String DATETIME_FORMAT_DMY_DASHED = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
public static final String DATETIME_FORMAT_DMY_DASHED = String.format("%s %s", DATE_FORMAT_DMY_DASHED, TIME_FORMAT);
|
||||||
@@ -46,6 +48,10 @@ public class CommonConstants {
|
|||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
|
||||||
|
public static final DateTimeFormatter DATE_YMD_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD_SLASHED)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
public static final DateTimeFormatter DATETIME_YMD_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
public static final DateTimeFormatter DATE_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_YMD)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
public static final DateTimeFormatter DATETIME_YMD_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_YMD)
|
||||||
@@ -53,6 +59,8 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY)
|
public static final DateTimeFormatter DATE_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
public static final DateTimeFormatter DATE_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATE_FORMAT_DMY_DASHED)
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_SLASHED)
|
public static final DateTimeFormatter DATETIME_DMY_SLASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_SLASHED)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
public static final DateTimeFormatter DATETIME_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_DASHED)
|
public static final DateTimeFormatter DATETIME_DMY_DASHED_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.DATETIME_FORMAT_DMY_DASHED)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||||
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import it.integry.ems.json.JsonObjectMapperConfig;
|
import it.integry.ems.json.JsonObjectMapperConfig;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
@@ -24,6 +25,7 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
|||||||
protected String format;
|
protected String format;
|
||||||
protected boolean headless;
|
protected boolean headless;
|
||||||
protected ImportRequestDTO requestDto;
|
protected ImportRequestDTO requestDto;
|
||||||
|
protected RequestDataDTO requestDataDTO;
|
||||||
protected MultiDBTransactionManager multiDBTransactionManager;
|
protected MultiDBTransactionManager multiDBTransactionManager;
|
||||||
protected List<AnomalieDTO> anomalie = new ArrayList<AnomalieDTO>();
|
protected List<AnomalieDTO> anomalie = new ArrayList<AnomalieDTO>();
|
||||||
|
|
||||||
@@ -77,6 +79,12 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEntityImporter<T> setRequestDataDTO(RequestDataDTO requestDataDTO) {
|
||||||
|
this.requestDataDTO = requestDataDTO;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AnomalieDTO> getAnomalie() {
|
public List<AnomalieDTO> getAnomalie() {
|
||||||
return anomalie;
|
return anomalie;
|
||||||
}
|
}
|
||||||
@@ -100,4 +108,6 @@ public abstract class BaseEntityImporter<T> implements IEntityImporter<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.integry.ems.Import.base;
|
|||||||
|
|
||||||
import it.integry.ems.Import.dto.AnomalieDTO;
|
import it.integry.ems.Import.dto.AnomalieDTO;
|
||||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||||
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
@@ -26,10 +27,14 @@ public interface IEntityImporter<T> {
|
|||||||
|
|
||||||
IEntityImporter<T> setRequestDTO(ImportRequestDTO requestDto);
|
IEntityImporter<T> setRequestDTO(ImportRequestDTO requestDto);
|
||||||
|
|
||||||
|
IEntityImporter<T> setRequestDataDTO(RequestDataDTO requestDataDTO);
|
||||||
|
|
||||||
List<AnomalieDTO> getAnomalie();
|
List<AnomalieDTO> getAnomalie();
|
||||||
|
|
||||||
T doImport() throws Exception;
|
T doImport() throws Exception;
|
||||||
|
|
||||||
String renameFile(String orginalFileName, List<EntityBase> entities) throws Exception;
|
String renameFile(String orginalFileName, List<EntityBase> entities) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ public enum EntityImportType {
|
|||||||
MOVIMENTI_CONTABILI("MOVIMENTI CONTABILI"),
|
MOVIMENTI_CONTABILI("MOVIMENTI CONTABILI"),
|
||||||
GRIGLIA_VENDITA("GRIGLIA VENDITA"),
|
GRIGLIA_VENDITA("GRIGLIA VENDITA"),
|
||||||
GRIGLIA_ACQUISTO("GRIGLIA ACQUISTO"),
|
GRIGLIA_ACQUISTO("GRIGLIA ACQUISTO"),
|
||||||
SCADENZE("SCADENZE");
|
SCADENZE("SCADENZE"),
|
||||||
|
BILANCE("BILANCE"),
|
||||||
|
BANCA("BANCA");
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ package it.integry.ems._context;
|
|||||||
|
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.common.var.EmsDBConst;
|
import it.integry.common.var.EmsDBConst;
|
||||||
import it.integry.ems.datasource.DataSource;
|
|
||||||
import it.integry.ems.expansion.RunnableArgsThrowable;
|
import it.integry.ems.expansion.RunnableArgsThrowable;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -15,7 +13,6 @@ import it.integry.ems.task.TaskExecutorService;
|
|||||||
import it.integry.ems.user.service.UserCacheService;
|
import it.integry.ems.user.service.UserCacheService;
|
||||||
import it.integry.ems_model.entity.Azienda;
|
import it.integry.ems_model.entity.Azienda;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -58,6 +55,8 @@ public class EmsCoreDBLoader {
|
|||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
this.settingsController.addOnConfigUpdated(() -> {
|
this.settingsController.addOnConfigUpdated(() -> {
|
||||||
try {
|
try {
|
||||||
|
connectionPool.destroy();
|
||||||
|
connectionPool.init();
|
||||||
load(null);
|
load(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -66,13 +65,10 @@ public class EmsCoreDBLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load(final RunnableArgsThrowable<MultiDBTransactionManager> onComplete) throws Exception {
|
public void load(final RunnableArgsThrowable<MultiDBTransactionManager> onComplete) throws Exception {
|
||||||
connectionPool.init();
|
|
||||||
|
|
||||||
taskExecutorService.executeTask(() -> {
|
taskExecutorService.executeTask(() -> {
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionPool)){
|
||||||
discoverAllConnections(multiDBTransactionManager);
|
discoverAllConnections(multiDBTransactionManager);
|
||||||
setupAzienda(multiDBTransactionManager);
|
setupAzienda(multiDBTransactionManager);
|
||||||
userCacheService.discoverAllUsers(multiDBTransactionManager);
|
|
||||||
|
|
||||||
if (onComplete != null) onComplete.run(multiDBTransactionManager);
|
if (onComplete != null) onComplete.run(multiDBTransactionManager);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -86,19 +82,13 @@ public class EmsCoreDBLoader {
|
|||||||
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
private void discoverAllConnections(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
|
|
||||||
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
for (AvailableConnectionModel model : settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true)) {
|
||||||
|
|
||||||
AtomicReference<AvailableConnectionsModel> modelAtomicReference = new AtomicReference<>(model);
|
AtomicReference<AvailableConnectionModel> modelAtomicReference = new AtomicReference<>(model);
|
||||||
|
|
||||||
futureTasks.add(() -> {
|
futureTasks.add(() -> {
|
||||||
try {
|
try {
|
||||||
final DataSource ds = connectionPool.getConnection(modelAtomicReference.get().getProfileName());
|
multiDBTransactionManager.addConnection(modelAtomicReference.get());
|
||||||
|
|
||||||
String sql = "SELECT db_distributore FROM azienda";
|
|
||||||
String dbDistributore = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(ds.getConnection(), sql);
|
|
||||||
|
|
||||||
multiDBTransactionManager.addConnection(modelAtomicReference.get().getProfileName(), ds, modelAtomicReference.get().getDbName().equalsIgnoreCase(dbDistributore));
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new Exception("[" + modelAtomicReference.get().getProfileName() + "] " + ex.getMessage(), ex.getCause());
|
throw new Exception("[" + modelAtomicReference.get().getProfileName() + "] " + ex.getMessage(), ex.getCause());
|
||||||
@@ -113,13 +103,11 @@ public class EmsCoreDBLoader {
|
|||||||
|
|
||||||
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
ArrayList<Callable<Void>> futureTasks = new ArrayList<>();
|
||||||
|
|
||||||
for (final AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
|
for (final Connection connection : multiDBTransactionManager.getActiveConnections()) {
|
||||||
AtomicReference<AdvancedDataSource> atomicAdvancedDataSource = new AtomicReference<>(advancedDataSource);
|
|
||||||
|
|
||||||
futureTasks.add(() -> {
|
futureTasks.add(() -> {
|
||||||
Connection conn = atomicAdvancedDataSource.get().getConnection();
|
Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||||
Azienda azienda = Azienda.getDefaultAzienda(conn);
|
String dbName = connection.getDbName();
|
||||||
String dbName = atomicAdvancedDataSource.get().getDataSource().getDbName();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (azienda != null) {
|
if (azienda != null) {
|
||||||
@@ -131,7 +119,7 @@ public class EmsCoreDBLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> gestSetupValues =
|
HashMap<String, String> gestSetupValues =
|
||||||
setupGest.getSetupSection(conn, "DATI_AZIENDA", "FATTURAZIONE_ELETTRONICA");
|
setupGest.getSetupSection(connection, "DATI_AZIENDA", "FATTURAZIONE_ELETTRONICA");
|
||||||
|
|
||||||
emsDBConst.getConsts(dbName)
|
emsDBConst.getConsts(dbName)
|
||||||
.setApplicationDbName(applicationDbName)
|
.setApplicationDbName(applicationDbName)
|
||||||
@@ -142,7 +130,7 @@ public class EmsCoreDBLoader {
|
|||||||
throw new Exception("Non è stato possibile leggere i dati dalla tabella azienda");
|
throw new Exception("Non è stato possibile leggere i dati dalla tabella azienda");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new Exception("[" + atomicAdvancedDataSource.get().getProfileName() + "] " + ex.getMessage(), ex.getCause());
|
throw new Exception("[" + connection.getProfileName() + "] " + ex.getMessage(), ex.getCause());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.adapter;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class LongDeserializer extends JsonDeserializer<Long> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long deserialize(JsonParser parser, DeserializationContext context)
|
||||||
|
throws IOException {
|
||||||
|
String string = parser.getText();
|
||||||
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(string)) {
|
||||||
|
if (string.equalsIgnoreCase("null")) {
|
||||||
|
return EmsRestConstants.LONG_NULL;
|
||||||
|
}
|
||||||
|
return new Long(string);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package it.integry.ems.adapter;
|
||||||
|
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class XmlLocalDateAdapter extends XmlAdapter<String, LocalDate> {
|
||||||
|
|
||||||
|
private DateTimeFormatter sdf;
|
||||||
|
|
||||||
|
public XmlLocalDateAdapter() {
|
||||||
|
sdf = DateTimeFormatter.ofPattern("dd-MM-yyyy");
|
||||||
|
}
|
||||||
|
|
||||||
|
public XmlLocalDateAdapter(String format) {
|
||||||
|
sdf = DateTimeFormatter.ofPattern(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String marshal(LocalDate arg0) throws Exception {
|
||||||
|
return arg0.format(sdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDate unmarshal(String arg0) throws Exception {
|
||||||
|
String format = UtilityString.determineDateFormat(arg0);
|
||||||
|
if (format != null && !"dd-MM-yyyy".equals(format))
|
||||||
|
sdf = DateTimeFormatter.ofPattern(format);
|
||||||
|
return LocalDate.parse(arg0,sdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package it.integry.ems.adapter;
|
||||||
|
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class XmlLocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime> {
|
||||||
|
|
||||||
|
private DateTimeFormatter sdf;
|
||||||
|
|
||||||
|
public XmlLocalDateTimeAdapter() {
|
||||||
|
sdf = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
public XmlLocalDateTimeAdapter(String format) {
|
||||||
|
sdf = DateTimeFormatter.ofPattern(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String marshal(LocalDateTime arg0) throws Exception {
|
||||||
|
return arg0.format(sdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime unmarshal(String arg0) throws Exception {
|
||||||
|
String format = UtilityString.determineDateFormat(arg0);
|
||||||
|
if (format != null && !"dd-MM-yyyy HH:mm:ss".equals(format))
|
||||||
|
sdf = DateTimeFormatter.ofPattern(format);
|
||||||
|
return LocalDateTime.parse(arg0,sdf);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package it.integry.ems.configuration;
|
||||||
|
|
||||||
|
import it.integry.annotations.CustomerComponent;
|
||||||
|
import it.integry.annotations.CustomerService;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomer;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||||
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
|
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configurazione per registrare gli scope personalizzati per customer specifici
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class CustomerServicesConfig implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsModel settingsModel;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
|
// Assicuriamoci che sia il context principale e non un sub-context
|
||||||
|
if (event.getApplicationContext() == applicationContext) {
|
||||||
|
registerCustomerBeans();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCustomerBeans() {
|
||||||
|
ClassPathScanningCandidateComponentProvider scanner =
|
||||||
|
new ClassPathScanningCandidateComponentProvider(false);
|
||||||
|
|
||||||
|
// Aggiungo filtri per le annotazioni custom
|
||||||
|
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomerService.class));
|
||||||
|
scanner.addIncludeFilter(new AnnotationTypeFilter(CustomerComponent.class));
|
||||||
|
|
||||||
|
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory();
|
||||||
|
|
||||||
|
// Scansiono tutti i package del progetto
|
||||||
|
for (BeanDefinition bd : scanner.findCandidateComponents("it.integry")) {
|
||||||
|
try {
|
||||||
|
Class<?> clazz = Class.forName(bd.getBeanClassName());
|
||||||
|
String beanName = generateBeanName(clazz);
|
||||||
|
|
||||||
|
IntegryCustomer customer = extractCustomer(clazz);
|
||||||
|
|
||||||
|
// Ora SettingsModel è completamente inizializzato con @PostConstruct chiamato
|
||||||
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(customer.toString())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evito duplicati controllando se il bean esiste già
|
||||||
|
if (!registry.containsBeanDefinition(beanName)) {
|
||||||
|
logger.trace("Registering custom bean for customer: " + customer + " - Class: " + clazz.getSimpleName());
|
||||||
|
|
||||||
|
// Creo la definizione del bean
|
||||||
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||||
|
.genericBeanDefinition(clazz);
|
||||||
|
|
||||||
|
// Registro il bean nel registry di Spring
|
||||||
|
registry.registerBeanDefinition(beanName, builder.getBeanDefinition());
|
||||||
|
|
||||||
|
// Determino lo scope del bean per decidere se istanziarlo immediatamente
|
||||||
|
String beanScope = determineBeanScope(clazz);
|
||||||
|
|
||||||
|
if (shouldInstantiateImmediately(beanScope)) {
|
||||||
|
// Forzo l'istanziazione immediata solo per bean con scope appropriati
|
||||||
|
try {
|
||||||
|
Object beanInstance = applicationContext.getBean(beanName);
|
||||||
|
logger.info("Bean customer {} istanziato con successo: {} (scope: {})",
|
||||||
|
customer, beanInstance.getClass().getSimpleName(), beanScope);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Errore durante l'istanziazione del bean {} (scope: {}): {}",
|
||||||
|
beanName, beanScope, e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.info("Bean customer {} registrato ma non istanziato (scope: {}). " +
|
||||||
|
"Verrà istanziato quando richiesto", customer, beanScope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
logger.error("Impossibile caricare la classe: " + bd.getBeanClassName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Genera il nome del bean basato sul nome della classe
|
||||||
|
*/
|
||||||
|
private String generateBeanName(Class<?> clazz) {
|
||||||
|
String simpleName = clazz.getSimpleName();
|
||||||
|
return Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntegryCustomer extractCustomer(Class<?> clazz) {
|
||||||
|
if (clazz.isAnnotationPresent(CustomerService.class)) {
|
||||||
|
CustomerService cs = clazz.getAnnotation(CustomerService.class);
|
||||||
|
return cs.value();
|
||||||
|
} else if (clazz.isAnnotationPresent(CustomerComponent.class)) {
|
||||||
|
CustomerComponent cc = clazz.getAnnotation(CustomerComponent.class);
|
||||||
|
return cc.value();
|
||||||
|
}
|
||||||
|
return IntegryCustomer.Integry; // Valore di default
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determina lo scope del bean analizzando le annotazioni della classe
|
||||||
|
*/
|
||||||
|
private String determineBeanScope(Class<?> clazz) {
|
||||||
|
// Controllo per @Scope
|
||||||
|
if (clazz.isAnnotationPresent(org.springframework.context.annotation.Scope.class)) {
|
||||||
|
org.springframework.context.annotation.Scope scopeAnnotation =
|
||||||
|
clazz.getAnnotation(org.springframework.context.annotation.Scope.class);
|
||||||
|
return scopeAnnotation.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controllo per @RequestScope
|
||||||
|
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.RequestScope.class)) {
|
||||||
|
return "request";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controllo per @SessionScope
|
||||||
|
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.SessionScope.class)) {
|
||||||
|
return "session";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controllo per @ApplicationScope
|
||||||
|
if (clazz.isAnnotationPresent(org.springframework.web.context.annotation.ApplicationScope.class)) {
|
||||||
|
return "application";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default è singleton
|
||||||
|
return "singleton";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determina se il bean può essere istanziato immediatamente in base al suo scope
|
||||||
|
*/
|
||||||
|
private boolean shouldInstantiateImmediately(String scope) {
|
||||||
|
switch (scope.toLowerCase()) {
|
||||||
|
case "request":
|
||||||
|
case "session":
|
||||||
|
// I bean con scope request/session non possono essere istanziati
|
||||||
|
// al di fuori del contesto web
|
||||||
|
return false;
|
||||||
|
case "prototype":
|
||||||
|
// I bean prototype non vengono istanziati automaticamente
|
||||||
|
return false;
|
||||||
|
case "singleton":
|
||||||
|
case "application":
|
||||||
|
default:
|
||||||
|
// Singleton e application possono essere istanziati immediatamente
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ public class ExecutorServiceConfig {
|
|||||||
|
|
||||||
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
|
private final int corePoolSize = Runtime.getRuntime().availableProcessors();
|
||||||
private final int maxPoolSize = (int) (corePoolSize * 1.5f);
|
private final int maxPoolSize = (int) (corePoolSize * 1.5f);
|
||||||
private final int queueSize = 500;
|
private final int queueSize = 1_000_000;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ExecutorService taskExecutor() {
|
public ExecutorService taskExecutor() {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package it.integry.ems.configuration;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableScheduling // Equivale a <task:annotation-driven/>
|
||||||
|
public class SchedulerConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ThreadPoolTaskScheduler taskScheduler() {
|
||||||
|
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||||
|
scheduler.setPoolSize(5); // Equivale a pool-size="5"
|
||||||
|
scheduler.setThreadNamePrefix("taskScheduler-");
|
||||||
|
scheduler.initialize();
|
||||||
|
return scheduler;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,8 +70,8 @@ import java.math.BigDecimal;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -227,7 +227,7 @@ public class EmsController {
|
|||||||
response = new ServiceRestResponse(EsitoType.OK);
|
response = new ServiceRestResponse(EsitoType.OK);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), new Exception("Il contenuto del file non è valido"));
|
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), new Exception("Il contenuto del file non è valido"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,11 +298,11 @@ public class EmsController {
|
|||||||
sql = sql.replaceAll("select", "select TOP " + numResult + " ");
|
sql = sql.replaceAll("select", "select TOP " + numResult + " ");
|
||||||
sql = sql.replaceAll("SELECT", "SELECT TOP " + numResult + " ");
|
sql = sql.replaceAll("SELECT", "SELECT TOP " + numResult + " ");
|
||||||
}
|
}
|
||||||
objs = entityProcessor.selectRawData(sql, multiDBTransactionManager.getPrimaryDatasource());
|
objs = entityProcessor.selectRawData(sql, multiDBTransactionManager.getPrimaryConnection());
|
||||||
response = new ServiceRestResponse(EsitoType.OK, objs);
|
response = new ServiceRestResponse(EsitoType.OK, objs);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ public class EmsController {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
|
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
|
||||||
@@ -386,7 +386,7 @@ public class EmsController {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
|
if (entity.getOperation() == OperationType.SELECT_OBJECT) {
|
||||||
@@ -483,7 +483,7 @@ public class EmsController {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
response = new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@@ -552,7 +552,7 @@ public class EmsController {
|
|||||||
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
||||||
@RequestBody(required = false) JsonNode body) throws Exception {
|
@RequestBody(required = false) JsonNode body) throws Exception {
|
||||||
|
|
||||||
EntityExportResponse<?> entityExportResponse = emsServices.export(typeExport, formatExport, body, headless);
|
EntityExportResponse<?> entityExportResponse = emsServices.export(multiDBTransactionManager, requestDataDTO, typeExport, formatExport, body, headless);
|
||||||
List<AnomalieDTO> anomalie = new ArrayList<>();
|
List<AnomalieDTO> anomalie = new ArrayList<>();
|
||||||
|
|
||||||
if (entityExportResponse != null && entityExportResponse.getAnomalie() != null && !entityExportResponse.getAnomalie().isEmpty())
|
if (entityExportResponse != null && entityExportResponse.getAnomalie() != null && !entityExportResponse.getAnomalie().isEmpty())
|
||||||
@@ -608,7 +608,7 @@ public class EmsController {
|
|||||||
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
@RequestParam(required = false, defaultValue = "true") boolean headless,
|
||||||
@RequestBody(required = false) ImportRequestDTO requestBody) throws Exception {
|
@RequestBody(required = false) ImportRequestDTO requestBody) throws Exception {
|
||||||
|
|
||||||
EntityImportResponse<List<EntityBase>> importResponse = emsServices.importEntity(importType, importFormat, requestBody, headless);
|
EntityImportResponse<List<EntityBase>> importResponse = emsServices.importEntity(multiDBTransactionManager, requestDataDTO, importType, importFormat, requestBody, headless);
|
||||||
List<EntityBase> entities = importResponse.getResponse();
|
List<EntityBase> entities = importResponse.getResponse();
|
||||||
|
|
||||||
|
|
||||||
@@ -687,7 +687,7 @@ public class EmsController {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryConnection().getProfileName(), entity);
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
if (forceTransaction) {
|
if (forceTransaction) {
|
||||||
break;
|
break;
|
||||||
@@ -700,16 +700,6 @@ public class EmsController {
|
|||||||
logger.error(request.getRequestURI(), e);
|
logger.error(request.getRequestURI(), e);
|
||||||
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
} finally {
|
|
||||||
if (multiDBTransactionManager != null) {
|
|
||||||
try {
|
|
||||||
multiDBTransactionManager.closeAll();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(request.getRequestURI(), e);
|
|
||||||
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
|
|
||||||
responseList.add(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseList;
|
return responseList;
|
||||||
@@ -743,7 +733,7 @@ public class EmsController {
|
|||||||
@PathVariable String filename,
|
@PathVariable String filename,
|
||||||
@RequestParam(name = "contentDisposition", defaultValue = "attachment") String contentDispositionType,
|
@RequestParam(name = "contentDisposition", defaultValue = "attachment") String contentDispositionType,
|
||||||
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
||||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(idAttach, requestThumbnail);
|
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(multiDBTransactionManager, idAttach, requestThumbnail);
|
||||||
|
|
||||||
if (attachmentDTO != null) {
|
if (attachmentDTO != null) {
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
@@ -760,13 +750,31 @@ public class EmsController {
|
|||||||
return ResponseEntity.notFound().build();
|
return ResponseEntity.notFound().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "downloadFileFromRefUuid")
|
||||||
|
public ResponseEntity<byte[]> downloadFileFromRefUuid(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
|
@RequestParam() String refUuid,
|
||||||
|
@RequestParam() String fileName) throws Exception {
|
||||||
|
AttachmentDTO attached = emsServices.downloadFileFromRefUuid(multiDBTransactionManager, refUuid, fileName);
|
||||||
|
|
||||||
|
if (attached == null) return ResponseEntity.notFound().build();
|
||||||
|
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.parseMediaType(attached.getMimeType()))
|
||||||
|
.contentLength(attached.getFileSize())
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
|
.attachment()
|
||||||
|
.filename(attached.getFileName())
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(attached.getFileContent());
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.GET)
|
||||||
public ResponseEntity<byte[]> downloadStbFileAttachmentPath(
|
public ResponseEntity<byte[]> downloadStbFileAttachmentPath(
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
@RequestParam String idAttach,
|
@RequestParam String idAttach,
|
||||||
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
@RequestParam(defaultValue = "false") boolean requestThumbnail) throws Exception {
|
||||||
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(idAttach, requestThumbnail);
|
AttachmentDTO attachmentDTO = emsServices.downloadStbFileAttachment(multiDBTransactionManager, idAttach, requestThumbnail);
|
||||||
|
|
||||||
if (attachmentDTO != null) {
|
if (attachmentDTO != null) {
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
@@ -785,9 +793,8 @@ public class EmsController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_EMAIL_CONTENT, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_EMAIL_CONTENT, method = RequestMethod.GET)
|
||||||
public byte[] downloadStbEmailContent(HttpServletRequest request, HttpServletResponse response,
|
public ResponseEntity<byte[]> downloadStbEmailContent(@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
@RequestParam Integer idEmail) throws Exception {
|
||||||
@RequestParam Integer idEmail) throws Exception {
|
|
||||||
StbEmailContent stbEmailContent = new StbEmailContent();
|
StbEmailContent stbEmailContent = new StbEmailContent();
|
||||||
stbEmailContent.setIdEmail(idEmail);
|
stbEmailContent.setIdEmail(idEmail);
|
||||||
stbEmailContent.setOperation(OperationType.SELECT_OBJECT);
|
stbEmailContent.setOperation(OperationType.SELECT_OBJECT);
|
||||||
@@ -795,11 +802,7 @@ public class EmsController {
|
|||||||
stbEmailContent = entityProcessor.processEntity(stbEmailContent, multiDBTransactionManager);
|
stbEmailContent = entityProcessor.processEntity(stbEmailContent, multiDBTransactionManager);
|
||||||
|
|
||||||
if (stbEmailContent != null) {
|
if (stbEmailContent != null) {
|
||||||
response.setContentType("application/octet-stream");
|
byte[] byteArr;
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
|
||||||
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment().filename("email.eml").build().toString());
|
|
||||||
|
|
||||||
byte[] byteArr = null;
|
|
||||||
|
|
||||||
String pattern = "[^\\x00-\\x7F]";
|
String pattern = "[^\\x00-\\x7F]";
|
||||||
Pattern pat = Pattern.compile(pattern);
|
Pattern pat = Pattern.compile(pattern);
|
||||||
@@ -811,13 +814,18 @@ public class EmsController {
|
|||||||
byteArr = Base64.decodeBase64(stbEmailContent.getEmailContent());
|
byteArr = Base64.decodeBase64(stbEmailContent.getEmailContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setContentLength(byteArr != null ? byteArr.length : 0);
|
return ResponseEntity.ok()
|
||||||
return byteArr;
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
.contentLength(byteArr != null ? byteArr.length : 0)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
|
.builder("attachment")
|
||||||
|
.filename("email.eml")
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(byteArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "Allegato non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_DOC_PDF, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_DOC_PDF, method = RequestMethod.GET)
|
||||||
@@ -876,12 +884,13 @@ public class EmsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_ORD_PDF, method = RequestMethod.GET)
|
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_DTB_ORD_PDF, method = RequestMethod.GET)
|
||||||
public byte[] downloadDtbOrdPdf(HttpServletRequest request, HttpServletResponse response,
|
public ResponseEntity<byte[]> downloadDtbOrdPdf(
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||||
@RequestParam String gestione,
|
@RequestParam String gestione,
|
||||||
@RequestParam String dataOrd,
|
@RequestParam String dataOrd,
|
||||||
@RequestParam Integer numOrd,
|
@RequestParam Integer numOrd,
|
||||||
@RequestParam Integer versione) throws Exception {
|
@RequestParam Integer versione) throws Exception {
|
||||||
|
|
||||||
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
DtbOrdPdf dtbOrdPdf = new DtbOrdPdf();
|
||||||
dtbOrdPdf.setGestione(gestione);
|
dtbOrdPdf.setGestione(gestione);
|
||||||
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
dtbOrdPdf.setDataOrd(UtilityDate.RecognizeDate(dataOrd));
|
||||||
@@ -892,17 +901,20 @@ public class EmsController {
|
|||||||
dtbOrdPdf = entityProcessor.processEntity(dtbOrdPdf, multiDBTransactionManager);
|
dtbOrdPdf = entityProcessor.processEntity(dtbOrdPdf, multiDBTransactionManager);
|
||||||
|
|
||||||
if (dtbOrdPdf != null) {
|
if (dtbOrdPdf != null) {
|
||||||
response.setContentType("application/octet-stream");
|
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
|
||||||
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment().filename(dtbOrdPdf.getFilename()).build().toString());
|
|
||||||
|
|
||||||
byte[] byteArr = dtbOrdPdf.getFilecontentByteArr(true);
|
byte[] byteArr = dtbOrdPdf.getFilecontentByteArr(true);
|
||||||
response.setContentLength(byteArr != null ? byteArr.length : 0);
|
|
||||||
return byteArr;
|
return ResponseEntity.ok()
|
||||||
|
.contentType(MediaType.APPLICATION_PDF)
|
||||||
|
.contentLength(byteArr != null ? byteArr.length : 0)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
|
.builder("attachment")
|
||||||
|
.filename(ContentDisposition.attachment().filename(dtbOrdPdf.getFilename()).build().toString())
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(byteArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "Allegato non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.POST)
|
@RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.POST)
|
||||||
@@ -919,7 +931,7 @@ public class EmsController {
|
|||||||
throw new Exception("Sono stati inviati più file del previsto");
|
throw new Exception("Sono stati inviati più file del previsto");
|
||||||
}
|
}
|
||||||
|
|
||||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(idAttach,
|
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(multiDBTransactionManager, idAttach,
|
||||||
files[0].getOriginalFilename(),
|
files[0].getOriginalFilename(),
|
||||||
files[0].getBytes(),
|
files[0].getBytes(),
|
||||||
descrizione,
|
descrizione,
|
||||||
@@ -1098,7 +1110,7 @@ public class EmsController {
|
|||||||
.setCodDtip(codDtip);
|
.setCodDtip(codDtip);
|
||||||
drlDocAttached.setOperation(OperationType.INSERT);
|
drlDocAttached.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(idAttach,
|
StbFilesAttached stbFilesAttached = emsServices.uploadStbFilesAttached(multiDBTransactionManager, idAttach,
|
||||||
files[0].getOriginalFilename(),
|
files[0].getOriginalFilename(),
|
||||||
files[0].getBytes(),
|
files[0].getBytes(),
|
||||||
descrizione,
|
descrizione,
|
||||||
@@ -1117,7 +1129,7 @@ public class EmsController {
|
|||||||
@RequestMapping(value = "createZipFromFiles", method = RequestMethod.POST)
|
@RequestMapping(value = "createZipFromFiles", method = RequestMethod.POST)
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ServiceRestResponse createZipFromFiles(@RequestBody CreateZipDTO createZipDTO) throws Exception {
|
ServiceRestResponse createZipFromFiles(@RequestBody CreateZipDTO createZipDTO) throws Exception {
|
||||||
return ServiceRestResponse.createPositiveResponse(emsServices.createZipFromFiles(createZipDTO));
|
return ServiceRestResponse.createPositiveResponse(emsServices.createZipFromFiles(multiDBTransactionManager, createZipDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_EMAIL_CONTENT, method = RequestMethod.POST)
|
// @RequestMapping(value = EmsRestConstants.PATH_UPLOAD_STB_EMAIL_CONTENT, method = RequestMethod.POST)
|
||||||
@@ -1163,22 +1175,10 @@ public class EmsController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_CLEAN_DIRECTORIES, method = RequestMethod.POST)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse cleanDirectories(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
|
||||||
try {
|
|
||||||
emsServices.cleanDirectories();
|
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_SERVER_INFO_ISCC, method = RequestMethod.POST)
|
@RequestMapping(value = EmsRestConstants.PATH_EXPORT_SERVER_INFO_ISCC, method = RequestMethod.POST)
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ServiceRestResponse exportServerInfoISCC(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
ServiceRestResponse exportServerInfoISCC(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||||
emsServices.checkServerVariables();
|
emsServices.checkServerVariables(multiDBTransactionManager);
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1190,7 +1190,7 @@ public class EmsController {
|
|||||||
return ServiceRestResponse.createPositiveResponse(mapping);
|
return ServiceRestResponse.createPositiveResponse(mapping);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1202,7 +1202,7 @@ public class EmsController {
|
|||||||
return ServiceRestResponse.createPositiveResponse(historyProfileDb);
|
return ServiceRestResponse.createPositiveResponse(historyProfileDb);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,7 +1219,7 @@ public class EmsController {
|
|||||||
return ServiceRestResponse.createPositiveResponse(entityFields);
|
return ServiceRestResponse.createPositiveResponse(entityFields);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryDatasource().getProfile(), e);
|
return new ServiceRestResponse(EsitoType.KO, multiDBTransactionManager.getPrimaryConnection().getProfileName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
package it.integry.ems.controller;
|
|
||||||
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.service.MapService;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
|
||||||
import it.integry.ems_model.types.LatLng;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Scope("request")
|
|
||||||
public class MapController {
|
|
||||||
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MapService mapService;
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_MAP_GETCOORDINATE_BY_CITY, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse getCoordinateByCity(HttpServletRequest request,
|
|
||||||
@RequestParam String cityName) {
|
|
||||||
ServiceRestResponse resp;
|
|
||||||
try {
|
|
||||||
LatLng coordinates = mapService.getCoordinateByCity(cityName);
|
|
||||||
resp = ServiceRestResponse.createPositiveResponse(coordinates);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(request.getRequestURI(), e);
|
|
||||||
resp = ServiceRestResponse.createNegativeResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,140 +1,172 @@
|
|||||||
package it.integry.ems.datasource;
|
package it.integry.ems.datasource;
|
||||||
|
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import javax.annotation.PreDestroy;
|
import java.util.HashMap;
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.DriverManager;
|
public class DataSource extends BasicDataSource {
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
private final int POOL_SIZE;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
private AvailableConnectionModel connectionModel;
|
||||||
|
|
||||||
@Service
|
/**
|
||||||
@Scope(value = "request")
|
* Instanzia un nuovo datasource.
|
||||||
public class DataSource {
|
*
|
||||||
|
* @deprecated Il datasource non deve essere istanziato direttamente ma bisogna utilizzare il metodo
|
||||||
private AvailableConnectionsModel connectionModel;
|
* {@link it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool#getConnection(AvailableConnectionModel)} per ottenere una connessione.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
private String profile;
|
public DataSource() {
|
||||||
private Short sessionID;
|
super();
|
||||||
private Connection connection = null;
|
POOL_SIZE = 5;
|
||||||
private String applicationName;
|
}
|
||||||
|
|
||||||
public String getDbName() {
|
@Deprecated
|
||||||
return connectionModel.getDbName();
|
public DataSource(int poolSize) {
|
||||||
}
|
super();
|
||||||
|
POOL_SIZE = poolSize;
|
||||||
public String getProfile() {
|
}
|
||||||
return profile;
|
|
||||||
}
|
public EmsRestConstants.DB_TYPE getTypeDB() {
|
||||||
|
return connectionModel.getConnectionType();
|
||||||
public EmsRestConstants.DB_TYPE getTypeDB() {
|
}
|
||||||
return connectionModel.getConnectionType();
|
|
||||||
}
|
/**
|
||||||
|
* Ottiene una connessione dal pool. La connessione è wrappata in it.integry.ems.sync.MultiDBTransaction.Connection.
|
||||||
public String getApplicationName() {
|
* È responsabilità del chiamante chiudere la connessione per restituirla al pool.
|
||||||
return applicationName;
|
*
|
||||||
}
|
* @return una connessione dal pool
|
||||||
|
* @throws SQLException se si verifica un errore di accesso al database
|
||||||
public int getSessionID() {
|
*/
|
||||||
return sessionID;
|
|
||||||
}
|
public Connection getConnection() throws SQLException {
|
||||||
|
// Restituisce una nuova connessione dal pool di BasicDataSource, wrappata nel nostro tipo Connection
|
||||||
public synchronized Connection getConnection() throws IOException, SQLException {
|
final Connection connection = Connection.fromConnection(super.getConnection());
|
||||||
return connection;
|
// Prova a ottenere una connessione per verificare la configurazione e ottenere il sessionID
|
||||||
}
|
|
||||||
|
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
||||||
public boolean isClosed() throws SQLException {
|
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select CAST(@@spid AS BIGINT) AS session_id," +
|
||||||
return !(connection != null && !connection.isClosed());
|
" user_name() AS [user_name]," +
|
||||||
}
|
" suser_name() AS [suser_name]," +
|
||||||
|
" current_user AS [current_user]," +
|
||||||
private void init(String applicationName) throws SQLException, IOException {
|
" system_user AS [system_user]," +
|
||||||
this.applicationName = applicationName;
|
" session_user AS [session_user]," +
|
||||||
|
" user AS [user]");
|
||||||
connection = Connection.fromConnection(
|
|
||||||
DriverManager.getConnection(connectionModel.getDbConnectionString(applicationName), connectionModel.getUsername(), connectionModel.getPasswordDecrypted())
|
connection.setSessionId(UtilityHashMap.getValueIfExists(resultSessionData, "session_id"));
|
||||||
);
|
}
|
||||||
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
|
||||||
connection.setAutoCommit(false);
|
connection.setProfileName(connectionModel.getProfileName())
|
||||||
|
.setInternalDb(connectionModel.getInternalDb());
|
||||||
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
|
||||||
try (final PreparedStatement setNocountOn = connection.prepareStatement("SET NOCOUNT ON")) {
|
return connection;
|
||||||
boolean resultNoCount = setNocountOn.execute();
|
}
|
||||||
}
|
|
||||||
|
public synchronized void initialize(String profileDB) throws Exception {
|
||||||
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
|
initialize(profileDB, null);
|
||||||
" user_name() AS [user_name]," +
|
}
|
||||||
" suser_name() AS [suser_name]," +
|
|
||||||
" current_user AS [current_user]," +
|
public synchronized void initialize(String profileDB, String customAppName) throws Exception {
|
||||||
" system_user AS [system_user]," +
|
AvailableConnectionModel connectionsModel = SettingsModel.getInstance().findConnectionModel(profileDB);
|
||||||
" session_user AS [session_user]," +
|
|
||||||
" user AS [user]");
|
initialize(connectionsModel, customAppName);
|
||||||
|
}
|
||||||
this.sessionID = UtilityHashMap.getValueIfExists(resultSessionData, "session_id");
|
|
||||||
}
|
public synchronized void initialize(AvailableConnectionModel connectionModel) throws Exception {
|
||||||
}
|
initialize(connectionModel, null);
|
||||||
|
}
|
||||||
@PreDestroy
|
|
||||||
private void destroy() throws SQLException {
|
public synchronized void initialize(AvailableConnectionModel connectionModel, String customAppName) throws Exception {
|
||||||
forceClose();
|
if (connectionModel == null) {
|
||||||
}
|
throw new Exception("Configurazione DB non trovata");
|
||||||
|
}
|
||||||
public synchronized void initialize(String profileDB, String connectionName, boolean autoOpenConnection) throws Exception {
|
|
||||||
if (UtilityString.isNullOrEmpty(profileDB)) {
|
this.connectionModel = connectionModel;
|
||||||
throw new Exception("Profile DB non valorizzato - controllare la chiamata del servizio");
|
|
||||||
}
|
this.setDriverClassName(connectionModel.getDriverClassName());
|
||||||
|
|
||||||
this.profile = profileDB;
|
this.setUrl(connectionModel.getDbConnectionString(UtilityString.isNull(customAppName, "EMS Connection")));
|
||||||
this.sessionID = -1;
|
this.setUsername(connectionModel.getUsername());
|
||||||
|
this.setPassword(connectionModel.getPasswordDecrypted());
|
||||||
|
this.setDefaultCatalog(connectionModel.getDbName());
|
||||||
AvailableConnectionsModel connectionModel = null;
|
|
||||||
List<AvailableConnectionsModel> availableConnectionsModels = SettingsModel.getInstance().getAvailableConnections();
|
this.setDefaultTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||||
|
this.setDefaultAutoCommit(false);
|
||||||
if (!UtilityString.isNullOrEmpty(profileDB)) {
|
|
||||||
for (AvailableConnectionsModel connectionsModel : availableConnectionsModels) {
|
// ===== OTTIMIZZAZIONI CRITICHE =====
|
||||||
if (connectionsModel.getProfileName().equalsIgnoreCase(profileDB)) {
|
|
||||||
connectionModel = connectionsModel;
|
// Pool sizing ottimizzato per READ_UNCOMMITTED (meno locking = più connessioni possibili)
|
||||||
}
|
this.setInitialSize(POOL_SIZE); // Inizia con più connessioni
|
||||||
}
|
this.setMaxTotal(-1); // Aumentato il massimo
|
||||||
}
|
this.setMinIdle(POOL_SIZE); // Non scendere sotto 5
|
||||||
|
this.setMaxIdle(-1); // Mantieni più connessioni idle
|
||||||
if (connectionModel == null) {
|
|
||||||
throw new Exception(String.format("Configurazione DB non trovata o dati mancanti (%s)", profileDB));
|
// Timeout ottimizzati per performance massime
|
||||||
}
|
// this.setMaxWaitMillis(-1L); // Infinito (DEFAULT)
|
||||||
|
|
||||||
this.connectionModel = connectionModel;
|
// Validazione veloce ed efficiente
|
||||||
|
this.setValidationQuery("SELECT 1");
|
||||||
if (autoOpenConnection) {
|
this.setValidationQueryTimeout(30); // Ridotto a 1 secondo
|
||||||
init(connectionName);
|
this.setTestWhileIdle(true); // Testa connessioni idle
|
||||||
}
|
|
||||||
}
|
// Eviction ottimizzata per READ_UNCOMMITTED
|
||||||
|
// this.setTimeBetweenEvictionRunsMillis(1 * 1000); // Ogni 30 secondi
|
||||||
public synchronized void initialize(String profileDB, boolean autoOpenConnection) throws Exception {
|
// this.setMinEvictableIdleTimeMillis(1 * 60 * 1000); // 3 minuti (ridotto da 5)
|
||||||
initialize(profileDB, "EMS Connection", autoOpenConnection);
|
// this.setNumTestsPerEvictionRun(5); // Testa più connessioni per volta
|
||||||
}
|
|
||||||
|
// Connection leak protection
|
||||||
public synchronized void initialize(String profileDB) throws Exception {
|
this.setRemoveAbandonedOnBorrow(true);
|
||||||
initialize(profileDB, "EMS Connection", true);
|
this.setRemoveAbandonedOnMaintenance(true);
|
||||||
}
|
this.setRemoveAbandonedTimeout(3 * 60 * 10); // 3 minuti
|
||||||
|
this.setLogAbandoned(true); // Disabilita in produzione per performance
|
||||||
public void forceClose() throws SQLException {
|
|
||||||
if (connection != null) {
|
// Performance boosts massimi
|
||||||
synchronized (connection) {
|
// this.setPoolPreparedStatements(true);
|
||||||
connection.close();
|
// this.setMaxOpenPreparedStatements(200);
|
||||||
}
|
// this.setCacheState(true);
|
||||||
}
|
this.setFastFailValidation(true);
|
||||||
|
|
||||||
}
|
// Ottimizzazioni specifiche per SQL Server con READ_UNCOMMITTED
|
||||||
|
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
||||||
|
// Impostazioni connection specifiche per SQL Server
|
||||||
|
//this.setConnectionInitSqls(java.util.Arrays.asList(
|
||||||
|
//"SET NOCOUNT ON",
|
||||||
|
//"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED",
|
||||||
|
//"SET ARITHABORT ON"
|
||||||
|
//));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logging ottimizzato (disabilita in produzione)
|
||||||
|
this.setLogExpiredConnections(true);
|
||||||
|
|
||||||
|
// ==================== ULTERIORI OTTIMIZZAZIONI ====================
|
||||||
|
|
||||||
|
// Connection properties specifiche per performance
|
||||||
|
this.setDefaultReadOnly(false);
|
||||||
|
|
||||||
|
// Ottimizzazioni DBCP2 avanzate
|
||||||
|
// this.setLifo(false); // FIFO per distribuzione equa delle connessioni
|
||||||
|
// this.setSoftMinEvictableIdleTimeMillis(120000); // 2 minuti soft eviction
|
||||||
|
|
||||||
|
|
||||||
|
// if (!connectionModel.getInternalDb() ||
|
||||||
|
// UtilityDebug.isDebugExecution() ||
|
||||||
|
// UtilityDebug.isIntegryServerDev() ||
|
||||||
|
// !SettingsModel.getInstance().isPrimaryInstance()) {
|
||||||
|
// this.setInitialSize(0);
|
||||||
|
//// this.setMaxTotal(5);
|
||||||
|
// this.setMinIdle(0);
|
||||||
|
// this.setMaxIdle(1);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,302 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component;
|
||||||
|
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||||
|
import it.integry.ems.datasource.DataSource;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.ChangeTrackingConfigDTO;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.DetectedChangeDataDTO;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DbmsChangeTracker {
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
private final int CHANGE_RETENTION_HOURS = 1;
|
||||||
|
private final boolean AUTO_CLEANUP = true;
|
||||||
|
|
||||||
|
private Connection integryConnection;
|
||||||
|
private boolean trackerEnabled = false;
|
||||||
|
private long currentVersion;
|
||||||
|
|
||||||
|
|
||||||
|
private Listener eventListener;
|
||||||
|
|
||||||
|
public DbmsChangeTracker(String profileDb) throws Exception {
|
||||||
|
createDataSource(profileDb);
|
||||||
|
createConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDataSource(String profileDb) throws Exception {
|
||||||
|
DataSource ds = new DataSource(1);
|
||||||
|
ds.initialize(profileDb, "Integry Changes Tracker");
|
||||||
|
this.dataSource = ds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createConnection() throws SQLException {
|
||||||
|
integryConnection = dataSource.getConnection();
|
||||||
|
if (!(integryConnection.isWrapperFor(SQLServerConnection.class))) {
|
||||||
|
integryConnection.close();
|
||||||
|
|
||||||
|
throw new SQLException("Connection is not a SQL Server connection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkConnection() {
|
||||||
|
try {
|
||||||
|
UtilityDB.executeSimpleQuery(integryConnection, "SELECT 1");
|
||||||
|
if (integryConnection.isClosed())
|
||||||
|
createConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
integryConnection.close();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
//ignore
|
||||||
|
}
|
||||||
|
createConnection();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
logger.error("Unable to reestablish DB connection for Change Tracker", ex);
|
||||||
|
throw new RuntimeException("Unable to reestablish DB connection for Change Tracker");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enableTrackerInDbms() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
final ChangeTrackingConfigDTO currentConfig = retrieveTrackerCurrentConfig();
|
||||||
|
if (currentConfig != null) {
|
||||||
|
logInfo("Changes Tracker is already enabled (with " + currentConfig.getRetentionPeriod() + " " + currentConfig.getRetentionPeriodUnit().toLowerCase() + " retention and auto cleanup " + (currentConfig.isAutoCleanupOn() ? "ON" : "OFF") + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String enableSql = "ALTER DATABASE [" + integryConnection.getDbName() + "] \n" +
|
||||||
|
"SET CHANGE_TRACKING = ON (" +
|
||||||
|
"CHANGE_RETENTION = " + CHANGE_RETENTION_HOURS + " HOURS, " +
|
||||||
|
"AUTO_CLEANUP = " + (AUTO_CLEANUP ? "ON" : "OFF") +
|
||||||
|
");\n";
|
||||||
|
|
||||||
|
//COMMIT necessario perché ALTER DATABASE richiede che non ci siano altre transazioni attive
|
||||||
|
UtilityDB.executeStatement(integryConnection, "COMMIT", enableSql);
|
||||||
|
|
||||||
|
logInfo("Changes Tracker is now enabled (with " + CHANGE_RETENTION_HOURS + " hours retention and auto cleanup " + (AUTO_CLEANUP ? "ON" : "OFF") + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void enableTrackerOnTable(String tableName) throws SQLException {
|
||||||
|
if (isTableTrackingEnabled(tableName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||||
|
"ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON);", "COMMIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void disableTrackerOnNotUsedTables(List<String> usedTables) throws SQLException {
|
||||||
|
final List<String> trackedTables = retrieveTrackedTables();
|
||||||
|
|
||||||
|
trackedTables.removeAll(usedTables);
|
||||||
|
|
||||||
|
for (String tableName : trackedTables) {
|
||||||
|
disableTrackerOnTable(tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableTrackerOnTable(String tableName) throws SQLException {
|
||||||
|
if (!isTableTrackingEnabled(tableName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UtilityDB.executeStatement(integryConnection, "ALTER TABLE dbo." + tableName + "\n" +
|
||||||
|
"DISABLE CHANGE_TRACKING;", "COMMIT");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void startTracking() throws SQLException {
|
||||||
|
currentVersion = retrieveCurrentVersion();
|
||||||
|
trackerEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkForChanges() throws Exception {
|
||||||
|
if (!trackerEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
checkConnection();
|
||||||
|
|
||||||
|
final List<String> trackedTables = retrieveTrackedTables();
|
||||||
|
|
||||||
|
HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion = new HashMap<>();
|
||||||
|
|
||||||
|
for (String trackedTable : trackedTables) {
|
||||||
|
long minValidVersion = getMinValidVersion(trackedTable);
|
||||||
|
|
||||||
|
if (currentVersion < minValidVersion) {
|
||||||
|
if (eventListener != null) {
|
||||||
|
eventListener.onTrackingResetted();
|
||||||
|
currentVersion = retrieveCurrentVersion();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<DetectedChangeDataDTO> detectedChanges = retrieveChangeList(trackedTable);
|
||||||
|
|
||||||
|
detectedChanges.forEach(detectedChangeDataDTO -> {
|
||||||
|
changesByVersion.putIfAbsent(detectedChangeDataDTO.getSysChangeVersion(), new ArrayList<>());
|
||||||
|
changesByVersion.get(detectedChangeDataDTO.getSysChangeVersion()).add(detectedChangeDataDTO);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logTrace("Detected " + changesByVersion.size() + " changes since version " + currentVersion);
|
||||||
|
|
||||||
|
dispatchChanges(changesByVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchChanges(HashMap<Long, List<DetectedChangeDataDTO>> changesByVersion) throws Exception {
|
||||||
|
final List<Long> sortedChanges = changesByVersion.keySet().stream()
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
for (Long changeId : sortedChanges) {
|
||||||
|
final List<DetectedChangeDataDTO> detectedChanges = changesByVersion.get(changeId);
|
||||||
|
|
||||||
|
for (DetectedChangeDataDTO detectedChange : detectedChanges) {
|
||||||
|
switch (detectedChange.getSysChangeOperation()) {
|
||||||
|
case INSERT:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onInsertDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UPDATE:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onUpdateDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DELETE:
|
||||||
|
if (eventListener != null)
|
||||||
|
eventListener.onDeleteDetected(detectedChange.getTableName(), detectedChange.getPrimaryKey());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentVersion = changeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<DetectedChangeDataDTO> retrieveChangeList(String tableName) throws SQLException {
|
||||||
|
String sql = "SELECT *\n" +
|
||||||
|
"FROM CHANGETABLE(CHANGES dbo." + tableName + ", " + currentVersion + ") AS c";
|
||||||
|
final List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(integryConnection, sql);
|
||||||
|
|
||||||
|
return result.stream()
|
||||||
|
.map(x -> {
|
||||||
|
DetectedChangeDataDTO detectedChangeDataDTO = new DetectedChangeDataDTO()
|
||||||
|
.setTableName(tableName);
|
||||||
|
|
||||||
|
Long sysChangeVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_VERSION");
|
||||||
|
detectedChangeDataDTO.setSysChangeVersion(sysChangeVersion);
|
||||||
|
|
||||||
|
|
||||||
|
Long sysChangeCreationVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_CREATION_VERSION");
|
||||||
|
detectedChangeDataDTO.setSysChangeCreationVersion(sysChangeCreationVersion);
|
||||||
|
|
||||||
|
detectedChangeDataDTO.setSysChangeOperation(DetectedChangeDataDTO.Operation.from(UtilityHashMap.<String>getValueIfExists(x, "SYS_CHANGE_OPERATION")));
|
||||||
|
|
||||||
|
List<String> keysToRemove = new ArrayList<>();
|
||||||
|
for (String colName : x.keySet()) {
|
||||||
|
if (colName.startsWith("SYS_"))
|
||||||
|
keysToRemove.add(colName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String colName : keysToRemove) {
|
||||||
|
x.remove(colName);
|
||||||
|
}
|
||||||
|
|
||||||
|
detectedChangeDataDTO.setPrimaryKey(x);
|
||||||
|
|
||||||
|
return detectedChangeDataDTO;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private long retrieveCurrentVersion() throws SQLException {
|
||||||
|
String sql = "SELECT CHANGE_TRACKING_CURRENT_VERSION() AS current_version";
|
||||||
|
|
||||||
|
long currentVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getMinValidVersion(String table) throws SQLException {
|
||||||
|
String sql = "SELECT CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID(" + UtilityDB.valueToString(table) + "))";
|
||||||
|
|
||||||
|
long minValidVersion = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return minValidVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> retrieveTrackedTables() throws SQLException {
|
||||||
|
String sql = "SELECT OBJECT_NAME(object_id) AS table_name\n" +
|
||||||
|
" FROM sys.change_tracking_tables";
|
||||||
|
|
||||||
|
List<String> trackedTables = UtilityDB.executeSimpleQueryOnlyFirstColumn(integryConnection, sql);
|
||||||
|
return trackedTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTableTrackingEnabled(String tableName) throws SQLException {
|
||||||
|
String sql = "SELECT CAST(COUNT(is_track_columns_updated_on) AS BIT) AS enabled\n" +
|
||||||
|
" FROM sys.change_tracking_tables \n" +
|
||||||
|
" WHERE object_id = OBJECT_ID('dbo." + tableName + "')";
|
||||||
|
|
||||||
|
boolean enabled = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(integryConnection, sql);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChangeTrackingConfigDTO retrieveTrackerCurrentConfig() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String checkSql = "SELECT DB_NAME(database_id) as database_name,\n" +
|
||||||
|
"CAST(is_auto_cleanup_on AS BIT) AS is_auto_cleanup_on,\n" +
|
||||||
|
"retention_period,\n" +
|
||||||
|
"retention_period_units_desc,\n" +
|
||||||
|
"max_cleanup_version\n" +
|
||||||
|
"FROM sys.change_tracking_databases \n" +
|
||||||
|
"WHERE DB_NAME(database_id)=DB_NAME()";
|
||||||
|
|
||||||
|
final ChangeTrackingConfigDTO currentConfig = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(integryConnection, checkSql, ChangeTrackingConfigDTO.class);
|
||||||
|
|
||||||
|
return currentConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void logInfo(String message) {
|
||||||
|
logger.info("[" + integryConnection.getProfileName() + "] " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logTrace(String message) {
|
||||||
|
logger.trace("[" + integryConnection.getProfileName() + "] " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DbmsChangeTracker setEventListener(Listener eventListener) {
|
||||||
|
this.eventListener = eventListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Listener {
|
||||||
|
void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) throws Exception;
|
||||||
|
|
||||||
|
void onTrackingResetted() throws Exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component;
|
||||||
|
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableTrackingResettedEvent;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems_model.entity.*;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DbmsChangeTrackerComponent {
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private final HashMap<IntegryCustomerDB, DbmsChangeTracker> activeChangeTrackers = new HashMap<>();
|
||||||
|
|
||||||
|
private final ArrayList<String> trackedTables = new ArrayList<String>() {{
|
||||||
|
add(MtbDepo.ENTITY);
|
||||||
|
add(MtbDepoPosizioni.ENTITY);
|
||||||
|
add(StbEditLimit.ENTITY);
|
||||||
|
add(StbGestSetup.ENTITY);
|
||||||
|
add(StbGestSetupDepo.ENTITY);
|
||||||
|
add(StbUser.ENTITY);
|
||||||
|
add(WtbClie.ENTITY);
|
||||||
|
add(WtbDepo.ENTITY);
|
||||||
|
add(WtbGestSetupUser.ENTITY);
|
||||||
|
}};
|
||||||
|
|
||||||
|
|
||||||
|
private final ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
public DbmsChangeTrackerComponent(ApplicationEventPublisher applicationEventPublisher) {
|
||||||
|
this.applicationEventPublisher = applicationEventPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostContextConstruct(priority = 10)
|
||||||
|
public void init() throws Exception {
|
||||||
|
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||||
|
activeChangeTrackers.put(customerDB, new DbmsChangeTracker(conn.getProfileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
enableAllChangeTracking();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void enableAllChangeTracking() throws Exception {
|
||||||
|
for (Map.Entry<IntegryCustomerDB, DbmsChangeTracker> entrySet : activeChangeTrackers.entrySet()) {
|
||||||
|
final IntegryCustomerDB customerDB = entrySet.getKey();
|
||||||
|
final DbmsChangeTracker dbmsChangeTracker = entrySet.getValue();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
dbmsChangeTracker.enableTrackerInDbms();
|
||||||
|
|
||||||
|
for (String tableName : trackedTables) {
|
||||||
|
dbmsChangeTracker.enableTrackerOnTable(tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbmsChangeTracker.disableTrackerOnNotUsedTables(trackedTables);
|
||||||
|
|
||||||
|
dbmsChangeTracker.setEventListener(new DbmsChangeTracker.Listener() {
|
||||||
|
@Override
|
||||||
|
public void onInsertDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemInserted(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemUpdated(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeleteDetected(String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
onItemDeleted(customerDB, tableName, primaryKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackingResetted() throws Exception {
|
||||||
|
requestGlobalReset(customerDB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dbmsChangeTracker.startTracking();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Exception("Errore durante l'abilitazione del DbmsChangeTracker per il customer: " + customerDB.getValue(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS)
|
||||||
|
private void checkAllChanges() throws Exception {
|
||||||
|
for (DbmsChangeTracker dbmsChangeTracker : activeChangeTrackers.values()) {
|
||||||
|
try {
|
||||||
|
dbmsChangeTracker.checkForChanges();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Errore durante il controllo delle modifiche nel DbmsChangeTracker.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onItemInserted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item inserted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordInsertedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemUpdated(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item updated in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordUpdatedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onItemDeleted(IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
logger.trace("Item deleted in profileDb {} table {} with primaryKey {}", customerDB.getValue(), tableName, primaryKey);
|
||||||
|
applicationEventPublisher.publishEvent(new TableRecordDeletedEvent(this, customerDB, tableName, primaryKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestGlobalReset(IntegryCustomerDB customerDB) {
|
||||||
|
logger.warn("Table tracking resetted in profileDb {} ", customerDB.getValue());
|
||||||
|
applicationEventPublisher.publishEvent(new TableTrackingResettedEvent(this, customerDB));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.component.exception;
|
||||||
|
|
||||||
|
public class DbmsChangeTrackerInvalidMinVersionException extends Exception {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final long currentVersion;
|
||||||
|
private final long minValidVersion;
|
||||||
|
|
||||||
|
public DbmsChangeTrackerInvalidMinVersionException(String tableName, long currentVersion, long minValidVersion) {
|
||||||
|
super("Change Tracking on table " + tableName + " has been reset. Current version: " + currentVersion + ", Min valid version: " + minValidVersion);
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.minValidVersion = minValidVersion;
|
||||||
|
this.currentVersion = currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCurrentVersion() {
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMinValidVersion() {
|
||||||
|
return minValidVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
|
||||||
|
public class ChangeTrackingConfigDTO {
|
||||||
|
|
||||||
|
@SqlField("database_name")
|
||||||
|
private String databaseName;
|
||||||
|
|
||||||
|
@SqlField("is_auto_cleanup_on")
|
||||||
|
private boolean autoCleanupOn;
|
||||||
|
|
||||||
|
@SqlField("retention_period")
|
||||||
|
private int retentionPeriod;
|
||||||
|
|
||||||
|
@SqlField("retention_period_units_desc")
|
||||||
|
private String retentionPeriodUnit;
|
||||||
|
|
||||||
|
// @SqlField("max_cleanup_version")
|
||||||
|
private Object maxCleanupVersion;
|
||||||
|
|
||||||
|
|
||||||
|
public String getDatabaseName() {
|
||||||
|
return databaseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setDatabaseName(String databaseName) {
|
||||||
|
this.databaseName = databaseName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoCleanupOn() {
|
||||||
|
return autoCleanupOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setAutoCleanupOn(boolean autoCleanupOn) {
|
||||||
|
this.autoCleanupOn = autoCleanupOn;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRetentionPeriod() {
|
||||||
|
return retentionPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setRetentionPeriod(int retentionPeriod) {
|
||||||
|
this.retentionPeriod = retentionPeriod;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRetentionPeriodUnit() {
|
||||||
|
return retentionPeriodUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setRetentionPeriodUnit(String retentionPeriodUnit) {
|
||||||
|
this.retentionPeriodUnit = retentionPeriodUnit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getMaxCleanupVersion() {
|
||||||
|
return maxCleanupVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangeTrackingConfigDTO setMaxCleanupVersion(Object maxCleanupVersion) {
|
||||||
|
this.maxCleanupVersion = maxCleanupVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import it.integry.ems_model.entity._enum.IBaseEnum;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class DetectedChangeDataDTO {
|
||||||
|
|
||||||
|
private long sysChangeVersion;
|
||||||
|
private Long sysChangeCreationVersion;
|
||||||
|
private Operation sysChangeOperation;
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
private HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
|
||||||
|
public long getSysChangeVersion() {
|
||||||
|
return sysChangeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeVersion(long sysChangeVersion) {
|
||||||
|
this.sysChangeVersion = sysChangeVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSysChangeCreationVersion() {
|
||||||
|
return sysChangeCreationVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeCreationVersion(Long sysChangeCreationVersion) {
|
||||||
|
this.sysChangeCreationVersion = sysChangeCreationVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operation getSysChangeOperation() {
|
||||||
|
return sysChangeOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setSysChangeOperation(Operation sysChangeOperation) {
|
||||||
|
this.sysChangeOperation = sysChangeOperation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectedChangeDataDTO setPrimaryKey(HashMap<String, Object> primaryKey) {
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum Operation implements IBaseEnum<Operation> {
|
||||||
|
INSERT('I'),
|
||||||
|
UPDATE('U'),
|
||||||
|
DELETE('D');
|
||||||
|
|
||||||
|
private final char value;
|
||||||
|
|
||||||
|
Operation(char value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Operation from(Object value) {
|
||||||
|
if (value instanceof String && ((String) value).length() == 1) {
|
||||||
|
value = ((String) value).charAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char castValue = (char) value;
|
||||||
|
for (Operation b : Operation.values()) {
|
||||||
|
if (b.value == castValue)
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public char getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation fromInternal(Object val) {
|
||||||
|
return from(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.valueOf(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordDeletedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordDeletedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, integryCustomerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordInsertedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordInsertedEvent(Object source, IntegryCustomerDB integryCustomerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, integryCustomerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class TableRecordUpdatedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
private final String tableName;
|
||||||
|
private final HashMap<String, Object> primaryKey;
|
||||||
|
|
||||||
|
public TableRecordUpdatedEvent(Object source, IntegryCustomerDB customerDB, String tableName, HashMap<String, Object> primaryKey) {
|
||||||
|
super(source, customerDB);
|
||||||
|
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getPrimaryKey() {
|
||||||
|
return primaryKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package it.integry.ems.dbms_change_tracker.model.events;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.event.BaseCustomerDBEvent;
|
||||||
|
|
||||||
|
public class TableTrackingResettedEvent extends BaseCustomerDBEvent {
|
||||||
|
|
||||||
|
public TableTrackingResettedEvent(Object source, IntegryCustomerDB customerDB) {
|
||||||
|
super(source, customerDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@ public class DevicesRequestInterceptor implements HandlerInterceptor {
|
|||||||
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
RequestDataDTO requestDataDTO = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||||
|
|
||||||
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
if (requestDataDTO.isValidProfileDB() && requestDataDTO.isValidDeviceId()) {
|
||||||
deviceService.updateUsage(requestDataDTO.getApplication(), requestDataDTO.getDeviceId());
|
deviceService.updateUsage(requestDataDTO.getDeviceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ package it.integry.ems.directory;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems.datasource.DataSource;
|
|
||||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||||
import it.integry.ems.properties.EmsProperties;
|
import it.integry.ems.properties.EmsProperties;
|
||||||
import it.integry.ems.response.EsitoType;
|
import it.integry.ems.response.EsitoType;
|
||||||
import it.integry.ems.response.FileItem;
|
import it.integry.ems.response.FileItem;
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import it.integry.security.utility.RestUtil;
|
import it.integry.security.utility.RestUtil;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -30,17 +31,18 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class EmailWatcherListener extends TimerTask {
|
public class EmailWatcherListener extends TimerTask {
|
||||||
|
|
||||||
private Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
private EmailListenerInfo emailListenerInfo;
|
private final EmailListenerInfo emailListenerInfo;
|
||||||
private EmsProperties prop;
|
private final EmsProperties prop;
|
||||||
private SetupGest setupGest;
|
private final SetupGest setupGest;
|
||||||
private ResponseJSONObjectMapper jsonObjectMapper;
|
private final ResponseJSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
public EmailWatcherListener(EmailListenerInfo emailListenerInfo, EmsProperties prop,
|
public EmailWatcherListener(EmailListenerInfo emailListenerInfo, EmsProperties prop,
|
||||||
SetupGest setupGest, ResponseJSONObjectMapper jsonObjectMapper) {
|
SetupGest setupGest, ResponseJSONObjectMapper jsonObjectMapper) {
|
||||||
@@ -53,42 +55,44 @@ public class EmailWatcherListener extends TimerTask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
try {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(emailListenerInfo.getDatabase())) {
|
||||||
|
Connection conn = multiDBTransactionManager.getPrimaryConnection();
|
||||||
|
|
||||||
String flagAttivo = null, username = null, password = null,
|
String flagAttivo = null, username = null, password = null,
|
||||||
imap = null, pop3 = null, pop3Port = null, imapPort = null;
|
imap = null, pop3 = null, pop3Port = null, imapPort = null;
|
||||||
|
|
||||||
DataSource ds = new DataSource();
|
|
||||||
ds.initialize(emailListenerInfo.getDatabase());
|
|
||||||
|
|
||||||
String[] params = emailListenerInfo.getSetupGestBranch().split("\\|");
|
String[] params = emailListenerInfo.getSetupGestBranch().split("\\|");
|
||||||
|
|
||||||
if (params.length >= 2) {
|
if (params.length >= 2) {
|
||||||
flagAttivo = setupGest.getSetup(ds.getConnection(), params[0], params[1], "ATTIVO");
|
final HashMap<String, String> setupData = setupGest.getSetupSection(conn, params[0], params[1]);
|
||||||
username = setupGest.getSetup(ds.getConnection(), params[0], params[1], "USERNAME");
|
|
||||||
|
flagAttivo = UtilityHashMap.getValueIfExists(setupData, "ATTIVO");
|
||||||
|
username = UtilityHashMap.getValueIfExists(setupData, "USERNAME");
|
||||||
if (UtilityString.isNullOrEmpty(username))
|
if (UtilityString.isNullOrEmpty(username))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/USERNAME non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/USERNAME non configurato correttamente");
|
||||||
|
|
||||||
password = setupGest.getSetup(ds.getConnection(), params[0], params[1], "PASSWORD");
|
password = UtilityHashMap.getValueIfExists(setupData, "PASSWORD");
|
||||||
if (UtilityString.isNullOrEmpty(password))
|
if (UtilityString.isNullOrEmpty(password))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/PASSWORD non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/PASSWORD non configurato correttamente");
|
||||||
|
|
||||||
pop3 = setupGest.getSetup(ds.getConnection(), params[0], params[1], "POP3");
|
pop3 = UtilityHashMap.getValueIfExists(setupData, "POP3");
|
||||||
if (UtilityString.isNullOrEmpty(pop3))
|
if (UtilityString.isNullOrEmpty(pop3))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/POP3 non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/POP3 non configurato correttamente");
|
||||||
|
|
||||||
pop3Port = setupGest.getSetup(ds.getConnection(), params[0], params[1], "POP3_PORT");
|
pop3Port = UtilityHashMap.getValueIfExists(setupData, "POP3_PORT");
|
||||||
if (UtilityString.isNullOrEmpty(pop3Port))
|
if (UtilityString.isNullOrEmpty(pop3Port))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/POP3_PORT non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/POP3_PORT non configurato correttamente");
|
||||||
|
|
||||||
imap = setupGest.getSetup(ds.getConnection(), params[0], params[1], "IMAP");
|
imap = UtilityHashMap.getValueIfExists(setupData, "IMAP");
|
||||||
if (UtilityString.isNullOrEmpty(imap))
|
if (UtilityString.isNullOrEmpty(imap))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/IMAP non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/IMAP non configurato correttamente");
|
||||||
|
|
||||||
imapPort = setupGest.getSetup(ds.getConnection(), params[0], params[1], "IMAP_PORT");
|
imapPort = UtilityHashMap.getValueIfExists(setupData, "IMAP_PORT");
|
||||||
if (UtilityString.isNullOrEmpty(imapPort))
|
if (UtilityString.isNullOrEmpty(imapPort))
|
||||||
throw new Exception(params[0] + "/" + params[1] + "/IMAP_PORT non configurato correttamente");
|
throw new Exception(params[0] + "/" + params[1] + "/IMAP_PORT non configurato correttamente");
|
||||||
}
|
}
|
||||||
ds.forceClose();
|
|
||||||
if (!UtilityString.isNullOrEmpty(flagAttivo) && "S".equals(flagAttivo)) {
|
if (!UtilityString.isNullOrEmpty(flagAttivo) && "S".equals(flagAttivo)) {
|
||||||
Properties sysProperties = System.getProperties();
|
Properties sysProperties = System.getProperties();
|
||||||
Session session = Session.getDefaultInstance(sysProperties);
|
Session session = Session.getDefaultInstance(sysProperties);
|
||||||
@@ -160,7 +164,7 @@ public class EmailWatcherListener extends TimerTask {
|
|||||||
|
|
||||||
String value = response.readEntity(String.class);
|
String value = response.readEntity(String.class);
|
||||||
|
|
||||||
String emailDbg = setupGest.getSetup(ds.getConnection(), params[0], params[1], "EMAIL_DBG");
|
String emailDbg = setupGest.getSetup(conn, params[0], params[1], "EMAIL_DBG");
|
||||||
if (value.charAt(0) == '{') {
|
if (value.charAt(0) == '{') {
|
||||||
ServiceRestResponse respWra = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
ServiceRestResponse respWra = jsonObjectMapper.readValue(value, ServiceRestResponse.class);
|
||||||
if (respWra.getEsito() == EsitoType.KO) {
|
if (respWra.getEsito() == EsitoType.KO) {
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.http.ContentDisposition;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@@ -28,26 +32,26 @@ public class DownloadController {
|
|||||||
private MimeTypesHandler mimetypesFileTypeMap;
|
private MimeTypesHandler mimetypesFileTypeMap;
|
||||||
|
|
||||||
@RequestMapping(value = "download/{uuid}/{fileName}", method = RequestMethod.GET)
|
@RequestMapping(value = "download/{uuid}/{fileName}", method = RequestMethod.GET)
|
||||||
public byte[] download(HttpServletResponse response,
|
public ResponseEntity<byte[]> download(@PathVariable String uuid,
|
||||||
@PathVariable String uuid,
|
@PathVariable String fileName) throws Exception {
|
||||||
@PathVariable String fileName) throws Exception {
|
|
||||||
|
|
||||||
byte[] fileContent = downloadFileHandlerService.getDownloadFileContent(uuid);
|
byte[] fileContent = downloadFileHandlerService.getDownloadFileContent(uuid);
|
||||||
|
|
||||||
if (fileContent != null) {
|
if (fileContent != null) {
|
||||||
String filename = downloadFileHandlerService.getDownloadFileName(uuid);
|
String filename = downloadFileHandlerService.getDownloadFileName(uuid);
|
||||||
|
|
||||||
String mimeType = Files.probeContentType(Paths.get(fileName));
|
MediaType mediaType = mimetypesFileTypeMap.getContentType(fileName);
|
||||||
|
|
||||||
response.setContentType(mimeType);
|
return ResponseEntity.ok()
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
.contentType(mediaType)
|
||||||
response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
|
.contentLength(fileContent.length)
|
||||||
|
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
|
||||||
response.setContentLength(fileContent.length);
|
.builder("attachment")
|
||||||
return fileContent;
|
.filename(filename)
|
||||||
|
.build()
|
||||||
|
.toString())
|
||||||
|
.body(fileContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.sendError(404, "File non trovato");
|
return ResponseEntity.notFound().build();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import it.integry.ems.utility.UtilityFile;
|
|||||||
import it.integry.ems_model.entity.StbFilesAttached;
|
import it.integry.ems_model.entity.StbFilesAttached;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -16,7 +15,6 @@ import java.io.IOException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DownloadFileHandlerService {
|
public class DownloadFileHandlerService {
|
||||||
@@ -26,12 +24,6 @@ public class DownloadFileHandlerService {
|
|||||||
|
|
||||||
private final HashMap<String, CachedFileDto> mFileMap = new HashMap<>();
|
private final HashMap<String, CachedFileDto> mFileMap = new HashMap<>();
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 1, timeUnit = TimeUnit.HOURS, zone = "Europe/Rome")
|
|
||||||
public void clean() {
|
|
||||||
UtilityFile.cleanDirectory(getTempPath(), 1, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DownloadFileDto generateDownloadItem(File file) throws IOException {
|
public DownloadFileDto generateDownloadItem(File file) throws IOException {
|
||||||
return generateDownloadItem(file.getName(), FileUtils.readFileToByteArray(file), false);
|
return generateDownloadItem(file.getName(), FileUtils.readFileToByteArray(file), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.dto;
|
package it.integry.ems.dto;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ExtendedStbActivity {
|
public class ExtendedStbActivity {
|
||||||
@@ -14,11 +15,9 @@ public class ExtendedStbActivity {
|
|||||||
private String userCreator;
|
private String userCreator;
|
||||||
private String note;
|
private String note;
|
||||||
private String activityDescription;
|
private String activityDescription;
|
||||||
private Date dataInsAct;
|
|
||||||
private int priorita;
|
private int priorita;
|
||||||
private Date alarmDate;
|
private LocalDateTime alarmTime;
|
||||||
private Date alarmTime;
|
private LocalDateTime oraInsAct;
|
||||||
private Date oraInsAct;
|
|
||||||
private String activityTypeId;
|
private String activityTypeId;
|
||||||
private String parentActivityId;
|
private String parentActivityId;
|
||||||
private StbActivityEmailObject emailObject;
|
private StbActivityEmailObject emailObject;
|
||||||
@@ -116,15 +115,6 @@ public class ExtendedStbActivity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDataInsAct() {
|
|
||||||
return dataInsAct;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedStbActivity setDataInsAct(Date dataInsAct) {
|
|
||||||
this.dataInsAct = dataInsAct;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPriorita() {
|
public int getPriorita() {
|
||||||
return priorita;
|
return priorita;
|
||||||
}
|
}
|
||||||
@@ -134,29 +124,20 @@ public class ExtendedStbActivity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getAlarmDate() {
|
public LocalDateTime getAlarmTime() {
|
||||||
return alarmDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExtendedStbActivity setAlarmDate(Date alarmDate) {
|
|
||||||
this.alarmDate = alarmDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getAlarmTime() {
|
|
||||||
return alarmTime;
|
return alarmTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtendedStbActivity setAlarmTime(Date alarmTime) {
|
public ExtendedStbActivity setAlarmTime(LocalDateTime alarmTime) {
|
||||||
this.alarmTime = alarmTime;
|
this.alarmTime = alarmTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getOraInsAct() {
|
public LocalDateTime getOraInsAct() {
|
||||||
return oraInsAct;
|
return oraInsAct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtendedStbActivity setOraInsAct(Date oraInsAct) {
|
public ExtendedStbActivity setOraInsAct(LocalDateTime oraInsAct) {
|
||||||
this.oraInsAct = oraInsAct;
|
this.oraInsAct = oraInsAct;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package it.integry.ems.dto;
|
package it.integry.ems.dto.info;
|
||||||
|
|
||||||
|
|
||||||
public class ApplicationInfoDTO {
|
public class ApplicationInfoDTO {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package it.integry.ems.dto;
|
package it.integry.ems.dto.info;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package it.integry.ems.dto;
|
package it.integry.ems.dto.info;
|
||||||
|
|
||||||
public class DatabaseInfoDTO {
|
public class DatabaseInfoDTO {
|
||||||
|
|
||||||
114
ems-core/src/main/java/it/integry/ems/dto/info/PvmInfoDTO.java
Normal file
114
ems-core/src/main/java/it/integry/ems/dto/info/PvmInfoDTO.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package it.integry.ems.dto.info;
|
||||||
|
|
||||||
|
public class PvmInfoDTO {
|
||||||
|
private String phpVersion;
|
||||||
|
private String timezone;
|
||||||
|
private String imagick;
|
||||||
|
private boolean sodiumMissing;
|
||||||
|
private int maxExecutionTime;
|
||||||
|
private boolean magicQuotesGpc;
|
||||||
|
private String defaultCharset;
|
||||||
|
private String memoryLimit;
|
||||||
|
private String postMaxSize;
|
||||||
|
private String uploadMaxSize;
|
||||||
|
private int maxInputVars;
|
||||||
|
|
||||||
|
public String getPhpVersion() {
|
||||||
|
return phpVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setPhpVersion(String phpVersion) {
|
||||||
|
this.phpVersion = phpVersion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimezone() {
|
||||||
|
return timezone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setTimezone(String timezone) {
|
||||||
|
this.timezone = timezone;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImagick() {
|
||||||
|
return imagick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setImagick(String imagick) {
|
||||||
|
this.imagick = imagick;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSodiumMissing() {
|
||||||
|
return sodiumMissing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setSodiumMissing(boolean sodiumMissing) {
|
||||||
|
this.sodiumMissing = sodiumMissing;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxExecutionTime() {
|
||||||
|
return maxExecutionTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setMaxExecutionTime(int maxExecutionTime) {
|
||||||
|
this.maxExecutionTime = maxExecutionTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMagicQuotesGpc() {
|
||||||
|
return magicQuotesGpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setMagicQuotesGpc(boolean magicQuotesGpc) {
|
||||||
|
this.magicQuotesGpc = magicQuotesGpc;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultCharset() {
|
||||||
|
return defaultCharset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setDefaultCharset(String defaultCharset) {
|
||||||
|
this.defaultCharset = defaultCharset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMemoryLimit() {
|
||||||
|
return memoryLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setMemoryLimit(String memoryLimit) {
|
||||||
|
this.memoryLimit = memoryLimit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPostMaxSize() {
|
||||||
|
return postMaxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setPostMaxSize(String postMaxSize) {
|
||||||
|
this.postMaxSize = postMaxSize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUploadMaxSize() {
|
||||||
|
return uploadMaxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setUploadMaxSize(String uploadMaxSize) {
|
||||||
|
this.uploadMaxSize = uploadMaxSize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxInputVars() {
|
||||||
|
return maxInputVars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PvmInfoDTO setMaxInputVars(int maxInputVars) {
|
||||||
|
this.maxInputVars = maxInputVars;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package it.integry.ems.dynamic_cache;
|
|||||||
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
import it.integry.ems.expansion.RunnableArgsWithReturn;
|
||||||
import it.integry.ems.expansion.RunnableWithReturn;
|
import it.integry.ems.expansion.RunnableWithReturn;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -37,8 +37,7 @@ public class DynamicCacheService {
|
|||||||
DATI_AZIENDA_KEY,
|
DATI_AZIENDA_KEY,
|
||||||
ENTITY_LOGGER_SETUP,
|
ENTITY_LOGGER_SETUP,
|
||||||
GRIGLIA_ACQUISTO_KEY,
|
GRIGLIA_ACQUISTO_KEY,
|
||||||
ENTITY_SYNC_KEY,
|
ENTITY_SYNC_KEY
|
||||||
STB_GEST_SETUP_KEY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||||
@@ -51,11 +50,11 @@ public class DynamicCacheService {
|
|||||||
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||||
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
RunnableWithReturn<Object> internalRefreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
final HashMap<String, T> cachedDataByDB = new HashMap<>();
|
||||||
|
|
||||||
@@ -83,11 +82,11 @@ public class DynamicCacheService {
|
|||||||
|
|
||||||
RunnableWithReturn<Object> refreshAction = () -> {
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
||||||
|
|
||||||
@@ -138,11 +137,11 @@ public class DynamicCacheService {
|
|||||||
|
|
||||||
RunnableWithReturn<Object> refreshAction = () -> {
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
Map<String, List<AvailableConnectionModel>> databases = settingsModel.getAvailableConnections()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AvailableConnectionsModel::getInternalDb)
|
.filter(AvailableConnectionModel::getInternalDb)
|
||||||
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
.collect(Collectors.groupingBy(AvailableConnectionModel::getDbName));
|
||||||
|
|
||||||
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,322 @@
|
|||||||
|
package it.integry.ems.dynamic_cache;
|
||||||
|
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.dbms_change_tracker.component.DbmsChangeTrackerComponent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordDeletedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordInsertedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableRecordUpdatedEvent;
|
||||||
|
import it.integry.ems.dbms_change_tracker.model.events.TableTrackingResettedEvent;
|
||||||
|
import it.integry.ems.dto.EntityHierarchy;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
|
import it.integry.ems_model.entity.*;
|
||||||
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EntityCacheComponent implements ApplicationListener {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
private final DbmsChangeTrackerComponent dbmsChangeTrackerComponent;
|
||||||
|
private final EntityPropertyHolder entityPropertyHolder;
|
||||||
|
|
||||||
|
private final HashMap<IntegryCustomerDB, ConcurrentHashMap<String, ConcurrentHashMap<HashMap<String, Object>, EntityBase>>> entityCache = new HashMap<>();
|
||||||
|
|
||||||
|
// Lock per IntegryCustomerDB per garantire accessi sincronizzati alla cache di quel customer
|
||||||
|
private final ConcurrentHashMap<IntegryCustomerDB, Object> cacheLocks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private Object getCacheLock(IntegryCustomerDB customerDB) {
|
||||||
|
cacheLocks.putIfAbsent(customerDB, new Object());
|
||||||
|
return cacheLocks.get(customerDB);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final HashMap<String, Class<? extends EntityBase>> enabledEntities = new HashMap<String, Class<? extends EntityBase>>() {{
|
||||||
|
put(MtbDepo.ENTITY, MtbDepo.class);
|
||||||
|
put(MtbDepoPosizioni.ENTITY, MtbDepoPosizioni.class);
|
||||||
|
put(StbEditLimit.ENTITY, StbEditLimit.class);
|
||||||
|
put(StbGestSetup.ENTITY, StbGestSetup.class);
|
||||||
|
put(StbGestSetupDepo.ENTITY, StbGestSetupDepo.class);
|
||||||
|
put(StbUser.ENTITY, StbUser.class);
|
||||||
|
put(WtbDepo.ENTITY, WtbDepo.class);
|
||||||
|
put(WtbGestSetupUser.ENTITY, WtbGestSetupUser.class);
|
||||||
|
put(WtbClie.ENTITY, WtbClie.class);
|
||||||
|
}};
|
||||||
|
|
||||||
|
public EntityCacheComponent(DbmsChangeTrackerComponent dbmsChangeTrackerComponent, EntityPropertyHolder entityPropertyHolder) {
|
||||||
|
this.dbmsChangeTrackerComponent = dbmsChangeTrackerComponent;
|
||||||
|
this.entityPropertyHolder = entityPropertyHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@PostContextConstruct
|
||||||
|
private void init() throws Exception {
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Connection conn : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
IntegryCustomerDB customerDB = IntegryCustomerDB.parse(conn.getDbName());
|
||||||
|
|
||||||
|
if (customerDB == null)
|
||||||
|
throw new RuntimeException("Impossibile inizializzare IntegryCustomerDB per il database: " + conn.getDbName());
|
||||||
|
|
||||||
|
|
||||||
|
for (Map.Entry<String, Class<? extends EntityBase>> enabledEntity : enabledEntities.entrySet()) {
|
||||||
|
String tableName = enabledEntity.getKey();
|
||||||
|
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheGlobal(IntegryCustomerDB customerDB) throws Exception {
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(customerDB)) {
|
||||||
|
Connection conn = mdb.getPrimaryConnection();
|
||||||
|
for (Map.Entry<String, Class<? extends EntityBase>> enabledEntity : enabledEntities.entrySet()) {
|
||||||
|
String tableName = enabledEntity.getKey();
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheForEntity(IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(customerDB)) {
|
||||||
|
Connection conn = mdb.getPrimaryConnection();
|
||||||
|
refreshCacheForEntity(conn, customerDB, tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshCacheForEntity(Connection connection, IntegryCustomerDB customerDB, String tableName) throws Exception {
|
||||||
|
// Sincronizziamo l'intera operazione di refresh per il customerDB per evitare accessi concorrenti
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
Class<? extends EntityBase> clazz = enabledEntities.get(tableName);
|
||||||
|
// if (clazz == null)
|
||||||
|
// throw new RuntimeException("Entity cache is not enabled for table " + tableName);
|
||||||
|
|
||||||
|
entityCache.putIfAbsent(customerDB, new ConcurrentHashMap<>());
|
||||||
|
entityCache.get(customerDB).remove(tableName);
|
||||||
|
|
||||||
|
ConcurrentHashMap<HashMap<String, Object>, EntityBase> entities = retrieveEntityList(connection, tableName, clazz);
|
||||||
|
entityCache.get(customerDB).put(tableName, entities);
|
||||||
|
|
||||||
|
logger.trace(String.format("[%s] Cached %d records for entity %s",
|
||||||
|
customerDB.getValue(),
|
||||||
|
entities.size(),
|
||||||
|
clazz.getSimpleName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> List<T> getCachedEntitiesList(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||||
|
return getCachedEntitiesStream(customerDB, tableName, filterPredicate)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> Stream<T> getCachedEntitiesStream(IntegryCustomerDB customerDB, String tableName, Predicate<T> filterPredicate) {
|
||||||
|
// Per evitare accessi concorrenti leggiamo/snapshottiamo la cache sotto lock per quel customerDB
|
||||||
|
Stream<T> snapshot;
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
if (!isCacheEnabled(customerDB, tableName)) {
|
||||||
|
try {
|
||||||
|
refreshCacheForEntity(customerDB, tableName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// prendo un'istantanea degli oggetti clonati per poter lavorare fuori dal lock
|
||||||
|
snapshot = entityCache.get(customerDB)
|
||||||
|
.get(tableName)
|
||||||
|
.values()
|
||||||
|
.parallelStream()
|
||||||
|
.map(x -> (T) x.clone());
|
||||||
|
|
||||||
|
if (filterPredicate != null)
|
||||||
|
snapshot = snapshot.filter(filterPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ApplicationEvent event) {
|
||||||
|
if (event instanceof TableRecordInsertedEvent) {
|
||||||
|
handleRecordInserted((TableRecordInsertedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableRecordUpdatedEvent) {
|
||||||
|
handleRecordUpdated((TableRecordUpdatedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableRecordDeletedEvent) {
|
||||||
|
handleRecordDeleted((TableRecordDeletedEvent) event);
|
||||||
|
|
||||||
|
} else if (event instanceof TableTrackingResettedEvent) {
|
||||||
|
try {
|
||||||
|
handleTableTrackingResetted((TableTrackingResettedEvent) event);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handleRecordInserted(TableRecordInsertedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||||
|
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||||
|
enabledEntities.get(event.getTableName()),
|
||||||
|
event.getPrimaryKey());
|
||||||
|
|
||||||
|
|
||||||
|
// sincronizziamo la modifica per il customerDB
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.put(entityPrimaryKey, newItem);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRecordUpdated(TableRecordUpdatedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(event.getCustomerDB())) {
|
||||||
|
EntityBase newItem = retrieveEntityItem(mdb.getPrimaryConnection(), event.getTableName(),
|
||||||
|
enabledEntities.get(event.getTableName()),
|
||||||
|
event.getPrimaryKey());
|
||||||
|
|
||||||
|
|
||||||
|
// sincronizziamo la modifica per il customerDB
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.put(entityPrimaryKey, newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRecordDeleted(TableRecordDeletedEvent event) {
|
||||||
|
if (!isCacheEnabled(event.getCustomerDB(), event.getTableName()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap<String, Object> entityPrimaryKey = convertSqlMapToEntityMap(event.getPrimaryKey(), enabledEntities.get(event.getTableName()));
|
||||||
|
|
||||||
|
// sincronizziamo la rimozione per il customerDB
|
||||||
|
final EntityBase removedItem;
|
||||||
|
synchronized (getCacheLock(event.getCustomerDB())) {
|
||||||
|
removedItem = entityCache.get(event.getCustomerDB())
|
||||||
|
.get(event.getTableName())
|
||||||
|
.remove(entityPrimaryKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleTableTrackingResetted(TableTrackingResettedEvent event) throws Exception {
|
||||||
|
// reset e refresh sono eseguiti in modo sincronizzato per quel customer
|
||||||
|
resetTablesCache(event.getCustomerDB());
|
||||||
|
refreshCacheGlobal(event.getCustomerDB());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ConcurrentHashMap<HashMap<String, Object>, EntityBase> retrieveEntityList(Connection connection, String tableName, Class<? extends EntityBase> clazz) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = "SELECT * FROM " + tableName;
|
||||||
|
|
||||||
|
List<? extends EntityBase> objects = UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||||
|
if (objects == null)
|
||||||
|
objects = new ArrayList<>();
|
||||||
|
final List<EntityHierarchy.Field> pkFields = entityPropertyHolder.getEntityFields(clazz, EntityHierarchy.Field::isPrimaryKey);
|
||||||
|
|
||||||
|
|
||||||
|
ConcurrentHashMap<HashMap<String, Object>, EntityBase> objectsMap = new ConcurrentHashMap<>();
|
||||||
|
for (EntityBase object : objects) {
|
||||||
|
HashMap<String, Object> pkMap = new HashMap<>();
|
||||||
|
for (EntityHierarchy.Field pkField : pkFields) {
|
||||||
|
Object pkValue = pkField.getField().get(object);
|
||||||
|
pkMap.put(pkField.getFieldName(), pkValue);
|
||||||
|
}
|
||||||
|
objectsMap.put(pkMap, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objectsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityBase retrieveEntityItem(Connection connection, String tableName, Class<?> clazz, HashMap<String, Object> primaryKey) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = "SELECT * FROM " + tableName + "\n" +
|
||||||
|
" WHERE " + UtilityQuery.concatFieldsInWhereCond(primaryKey);
|
||||||
|
|
||||||
|
final EntityBase object = (EntityBase) UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, clazz);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private HashMap<String, Object> convertSqlMapToEntityMap(HashMap<String, Object> sqlMap, Class<? extends EntityBase> clazz) {
|
||||||
|
HashMap<String, Object> entityMap = new HashMap<>();
|
||||||
|
for (Map.Entry<String, Object> entry : sqlMap.entrySet()) {
|
||||||
|
String fieldName = entityPropertyHolder.getEntityFields(clazz, f -> f.isSqlField() && f.getSqlField().value().equals(entry.getKey()))
|
||||||
|
.stream()
|
||||||
|
.findFirst()
|
||||||
|
.map(EntityHierarchy.Field::getFieldName)
|
||||||
|
.orElse(entry.getKey());
|
||||||
|
entityMap.put(fieldName, entry.getValue());
|
||||||
|
}
|
||||||
|
return entityMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void resetTableCache(IntegryCustomerDB customerDB, String tableName) {
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
if (entityCache.containsKey(customerDB) && entityCache.get(customerDB).containsKey(tableName)) {
|
||||||
|
entityCache.get(customerDB).remove(tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void resetTablesCache(IntegryCustomerDB customerDB) {
|
||||||
|
// sincronizziamo la rimozione dell'intera cache per il customer
|
||||||
|
synchronized (getCacheLock(customerDB)) {
|
||||||
|
entityCache.remove(customerDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isCacheEnabled(IntegryCustomerDB customerDB, String tableName) {
|
||||||
|
return (entityCache.containsKey(customerDB) && entityCache.get(customerDB).containsKey(tableName)) ||
|
||||||
|
!(UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ import it.integry.annotations.PostContextConstruct;
|
|||||||
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
import it.integry.ems.entity_logger.db_schema_manager.component.SQLServerDBSchemaManager;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.*;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.*;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -57,7 +57,7 @@ public class EntityLoggerComponent {
|
|||||||
|
|
||||||
private void syncDBScheme() throws Exception {
|
private void syncDBScheme() throws Exception {
|
||||||
|
|
||||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
AvailableConnectionModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||||
|
|
||||||
if (connectionsModel == null) {
|
if (connectionsModel == null) {
|
||||||
throw new Exception("Impossibile ricavare la default connection");
|
throw new Exception("Impossibile ricavare la default connection");
|
||||||
@@ -107,7 +107,7 @@ public class EntityLoggerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||||
settingsModel.addAvailableConnection(new AvailableConnectionsModel()
|
settingsModel.addAvailableConnection(new AvailableConnectionModel()
|
||||||
.setInternalDb(false)
|
.setInternalDb(false)
|
||||||
.setHost(dbHost)
|
.setHost(dbHost)
|
||||||
.setUsername(dbUsername)
|
.setUsername(dbUsername)
|
||||||
@@ -210,12 +210,12 @@ public class EntityLoggerComponent {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<AvailableConnectionsModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
List<AvailableConnectionModel> connectionsModels = settingsModel.getAvailableConnectionsWithoutDuplicatedProfiles(true);
|
||||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
|
|
||||||
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
try (MultiDBTransactionManager historyMultiDB = new MultiDBTransactionManager(historyProfileDB)) {
|
||||||
|
|
||||||
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
for (AvailableConnectionModel sourceConnectionModel : connectionsModels) {
|
||||||
String sql = "SELECT * FROM stb_log_entity_setup" +
|
String sql = "SELECT * FROM stb_log_entity_setup" +
|
||||||
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class DistributoreDatabaseNotPresentException extends Exception {
|
||||||
|
|
||||||
|
public DistributoreDatabaseNotPresentException() {
|
||||||
|
super("Distributore database not present yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidCustomerDbException extends RuntimeException {
|
||||||
|
public InvalidCustomerDbException(String dbName) {
|
||||||
|
super("Invalid customer database name: " + dbName + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidDbNameException extends RuntimeException {
|
||||||
|
public InvalidDbNameException(String dbName) {
|
||||||
|
super("Invalid database name: " + dbName + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class InvalidProfileDbException extends RuntimeException {
|
||||||
|
public InvalidProfileDbException(String profileDb) {
|
||||||
|
super("Invalid profile db: " + profileDb + ". Please check your ems_settings.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package it.integry.ems.expansion;
|
package it.integry.ems.expansion;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Observable;
|
|
||||||
import java.util.Observer;
|
|
||||||
|
|
||||||
public class ObservableArrayList<T> extends Observable {
|
public class ObservableArrayList<T> extends Observable {
|
||||||
|
|
||||||
@@ -122,4 +119,16 @@ public class ObservableArrayList<T> extends Observable {
|
|||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof ObservableArrayList)) return false;
|
||||||
|
ObservableArrayList<?> that = (ObservableArrayList<?>) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.expansion;
|
package it.integry.ems.expansion;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
|
|
||||||
public class ObservableField<T> extends Observable {
|
public class ObservableField<T> extends Observable {
|
||||||
@@ -34,4 +35,16 @@ public class ObservableField<T> extends Observable {
|
|||||||
|
|
||||||
super.addObserver((o, arg) -> observerCallback.run());
|
super.addObserver((o, arg) -> observerCallback.run());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof ObservableField)) return false;
|
||||||
|
ObservableField<?> that = (ObservableField<?>) o;
|
||||||
|
return Objects.equals(value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
|||||||
.map(x -> (FileItem) x)
|
.map(x -> (FileItem) x)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
String pathFile = UtilityDirs.getDirectoryExport(multiDBTransactionManager.getPrimaryDatasource().getDbName(), type, format).getAbsolutePath();
|
String pathFile = UtilityDirs.getDirectoryExport(multiDBTransactionManager.getPrimaryConnection().getDbName(), type, format).getAbsolutePath();
|
||||||
|
|
||||||
for (FileItem file : files) {
|
for (FileItem file : files) {
|
||||||
File tempFile = new File(pathFile + File.separator + file.getFileName());
|
File tempFile = new File(pathFile + File.separator + file.getFileName());
|
||||||
@@ -369,7 +369,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
|||||||
entityExportResponse.setMessageContent("Messaggio creato automaticamente: " + "INVIO " + type + " formato " + format);
|
entityExportResponse.setMessageContent("Messaggio creato automaticamente: " + "INVIO " + type + " formato " + format);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSharerSettings = MailService.readParameter(multiDBTransactionManager, null);
|
fileSharerSettings = MailService.readParameter(multiDBTransactionManager.getPrimaryConnection(), null);
|
||||||
((EmailFileSharerSettings) fileSharerSettings)
|
((EmailFileSharerSettings) fileSharerSettings)
|
||||||
.withSubject(entityExportResponse.getMessageSubject())
|
.withSubject(entityExportResponse.getMessageSubject())
|
||||||
.withTextMessage(entityExportResponse.getMessageContent())
|
.withTextMessage(entityExportResponse.getMessageContent())
|
||||||
@@ -426,7 +426,7 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
MailService mailService = ContextLoader.getCurrentWebApplicationContext().getBean(MailService.class);
|
MailService mailService = ContextLoader.getCurrentWebApplicationContext().getBean(MailService.class);
|
||||||
mailService.sendInfoMail(multiDBTransactionManager, notificationEmail,
|
mailService.sendInfoMail(multiDBTransactionManager.getPrimaryConnection(), notificationEmail,
|
||||||
String.format("Esportazione di %s - %s", getType(), getFormat()),
|
String.format("Esportazione di %s - %s", getType(), getFormat()),
|
||||||
String.format("come da accordi, l'esportazione %s - %s è stata completata.", getType(), getFormat()));
|
String.format("come da accordi, l'esportazione %s - %s è stata completata.", getType(), getFormat()));
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import it.integry.ems.response.FileItem;
|
|||||||
import it.integry.ems.service.EntityProcessor;
|
import it.integry.ems.service.EntityProcessor;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems_model.entity.WtbUsersInfo;
|
import it.integry.ems_model.entity.WtbUsersInfo;
|
||||||
|
import it.integry.ems_model.service.SetupGest;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityResultSet;
|
import it.integry.ems_model.utility.UtilityResultSet;
|
||||||
@@ -27,8 +28,13 @@ public class ExportFromQuery {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EntityProcessor entityProcessor;
|
private EntityProcessor entityProcessor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SetupGest setupGest;
|
||||||
|
|
||||||
public EntityExportResponse export (String userName, String type, String format, String whereCond) throws Exception {
|
public EntityExportResponse export (String userName, String type, String format, String whereCond) throws Exception {
|
||||||
|
|
||||||
|
String query = setupGest.getExportSetup(multiDBTransactionManager.getPrimaryConnection(), type, format, "QUERY");
|
||||||
|
|
||||||
WtbUsersInfo wtbUsersInfo =
|
WtbUsersInfo wtbUsersInfo =
|
||||||
new WtbUsersInfo()
|
new WtbUsersInfo()
|
||||||
.setUserName(userName)
|
.setUserName(userName)
|
||||||
@@ -38,18 +44,20 @@ public class ExportFromQuery {
|
|||||||
|
|
||||||
entityProcessor.processEntity(wtbUsersInfo, multiDBTransactionManager);
|
entityProcessor.processEntity(wtbUsersInfo, multiDBTransactionManager);
|
||||||
|
|
||||||
String queryCustom = wtbUsersInfo.getQueryCustom();
|
if (UtilityString.isNullOrEmpty(wtbUsersInfo.getQueryCustom()) && UtilityString.isNullOrEmpty(query))
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(queryCustom))
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
String.format(
|
String.format(
|
||||||
"Query non configurata per l'utente %s tipo %s formato %s",
|
"Query non configurata per l'utente %s tipo %s formato %s o per il formato.",
|
||||||
userName, type, format));
|
userName, type, format));
|
||||||
|
|
||||||
queryCustom = UtilityDB.addwhereCond(queryCustom, whereCond, true);
|
|
||||||
|
if (!UtilityString.isNullOrEmpty(wtbUsersInfo.getQueryCustom())) {
|
||||||
|
query = wtbUsersInfo.getQueryCustom();
|
||||||
|
}
|
||||||
|
query = UtilityDB.addwhereCond(query, whereCond, true);
|
||||||
PreparedStatement stm = multiDBTransactionManager
|
PreparedStatement stm = multiDBTransactionManager
|
||||||
.getPrimaryConnection()
|
.getPrimaryConnection()
|
||||||
.prepareStatement(queryCustom,
|
.prepareStatement(query,
|
||||||
ResultSet.TYPE_SCROLL_INSENSITIVE,
|
ResultSet.TYPE_SCROLL_INSENSITIVE,
|
||||||
ResultSet.CONCUR_READ_ONLY);
|
ResultSet.CONCUR_READ_ONLY);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
|
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
|
||||||
import com.fasterxml.jackson.dataformat.csv.CsvSchema.Column;
|
import com.fasterxml.jackson.dataformat.csv.CsvSchema.Column;
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems_model.ImportExport.Interfaces.IExportFormat;
|
import it.integry.ems_model.ImportExport.Interfaces.IExportFormat;
|
||||||
import it.integry.ems_model.ImportExport.Interfaces.IImportFormat;
|
import it.integry.ems_model.ImportExport.Interfaces.IImportFormat;
|
||||||
import it.integry.ems_model.annotation.DtoField;
|
import it.integry.ems_model.annotation.DtoField;
|
||||||
@@ -64,7 +63,7 @@ public class CsvMapper<T> {
|
|||||||
builder.addColumn(new Column(i, columns[i]));
|
builder.addColumn(new Column(i, columns[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setLineSeparator(System.getProperty("line.separator"));
|
builder.setLineSeparator(System.lineSeparator());
|
||||||
CsvSchema schema = builder.build().withoutQuoteChar();
|
CsvSchema schema = builder.build().withoutQuoteChar();
|
||||||
|
|
||||||
mapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
|
mapper.configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package it.integry.ems.file_formatter.txt;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.ems_model.annotation.DtoField;
|
import it.integry.ems_model.annotation.DtoField;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -10,6 +11,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -76,8 +78,16 @@ public class TxtMapper<T> {
|
|||||||
|
|
||||||
if (ignorePosition)
|
if (ignorePosition)
|
||||||
stringBuilder.append(value).append(fieldsSplitChar);
|
stringBuilder.append(value).append(fieldsSplitChar);
|
||||||
else
|
else {
|
||||||
|
if ( stringBuilder.length() > 0 && stringBuilder.length() < dtoField.startPosition() ) {
|
||||||
|
int numChar = dtoField.startPosition() - stringBuilder.length();
|
||||||
|
for (int i = 0; i < numChar; i++) {
|
||||||
|
stringBuilder.append(fieldsSplitChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
stringBuilder.insert(dtoField.startPosition(), value).append(fieldsSplitChar);
|
stringBuilder.insert(dtoField.startPosition(), value).append(fieldsSplitChar);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
@@ -208,6 +218,8 @@ public class TxtMapper<T> {
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof Date) {
|
||||||
value = new SimpleDateFormat(dtoField.format()).format(value);
|
value = new SimpleDateFormat(dtoField.format()).format(value);
|
||||||
|
} else if (!UtilityString.isNullOrEmpty(dtoField.format()) && value instanceof LocalDate) {
|
||||||
|
value = UtilityLocalDate.formatDate((LocalDate) value, dtoField.format() );
|
||||||
} else if (!UtilityString.isNullOrEmpty(dtoField.formula()) && value instanceof BigDecimal) {
|
} else if (!UtilityString.isNullOrEmpty(dtoField.formula()) && value instanceof BigDecimal) {
|
||||||
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
value = ((BigDecimal) value).setScale(dtoField.scale(), RoundingMode.HALF_DOWN);
|
||||||
String formula = dtoField.formula().replaceAll("this", value.toString());
|
String formula = dtoField.formula().replaceAll("this", value.toString());
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package it.integry.ems.javabeans;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems._context.ApplicationContextProvider;
|
||||||
|
import it.integry.ems.jpa.TenantContext;
|
||||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import it.integry.ems.model.IntegryApplicationEnum;
|
import it.integry.ems.model.IntegryApplicationEnum;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.user.dto.UserDTO;
|
import it.integry.ems.user.dto.UserDTO;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
@@ -16,13 +20,15 @@ import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.PreDestroy;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope("request")
|
@Scope(WebApplicationContext.SCOPE_REQUEST)
|
||||||
public class RequestDataDTO {
|
public class RequestDataDTO {
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
private final Logger logger = LogManager.getLogger();
|
||||||
@@ -37,24 +43,32 @@ public class RequestDataDTO {
|
|||||||
private String requestClientIP;
|
private String requestClientIP;
|
||||||
|
|
||||||
private String profileDB;
|
private String profileDB;
|
||||||
|
|
||||||
|
//Indica il codice deposito reale dell'utente che effettua la richiesta, ovvero la posizione fisica dell'utente
|
||||||
|
private String codMdep;
|
||||||
|
|
||||||
private Long deviceId;
|
private Long deviceId;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
private boolean includeNulls = false;
|
private boolean includeNulls = false;
|
||||||
|
|
||||||
private IntegryApplicationEnum integryApplication = IntegryApplicationEnum.PVM;
|
private IntegryApplicationEnum integryApplication;
|
||||||
|
|
||||||
private UserDTO userDTO;
|
private UserDTO userDTO;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() throws IOException, InterruptedException {
|
public void init() throws IOException, InterruptedException {
|
||||||
|
|
||||||
if (request != null && request.getQueryString() != null && request.getQueryString().contains(CommonConstants.PROFILE_DB)) {
|
if (request != null && request.getParameter(CommonConstants.PROFILE_DB) != null) {
|
||||||
profileDB = request.getParameter(CommonConstants.PROFILE_DB);
|
profileDB = request.getParameter(CommonConstants.PROFILE_DB);
|
||||||
} else if (request != null && request.getHeader(CommonConstants.PROFILE_DB) != null) {
|
} else if (request != null && request.getHeader(CommonConstants.PROFILE_DB) != null) {
|
||||||
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request != null && request.getHeader(CommonConstants.COD_MDEP) != null) {
|
||||||
|
codMdep = request.getHeader(CommonConstants.COD_MDEP);
|
||||||
|
}
|
||||||
|
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
if (authentication != null && !(authentication instanceof AnonymousAuthenticationToken)) {
|
||||||
readAuthenticationClaims(authentication);
|
readAuthenticationClaims(authentication);
|
||||||
@@ -89,6 +103,24 @@ public class RequestDataDTO {
|
|||||||
} else {
|
} else {
|
||||||
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
jsonObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Logica di fallback o recupero tenant da sessione/utente
|
||||||
|
if (profileDB == null || profileDB.isEmpty()) {
|
||||||
|
// Esempio: recupero da sessione se presente
|
||||||
|
// tenantId = (String) request.getSession().getAttribute("TENANT_ID");
|
||||||
|
|
||||||
|
// Fallback temporaneo per test
|
||||||
|
// tenantId = DEFAULT_TENANT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profileDB != null) {
|
||||||
|
TenantContext.setCurrentTenant(profileDB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
public void destroy() throws Exception {
|
||||||
|
TenantContext.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,10 +130,20 @@ public class RequestDataDTO {
|
|||||||
.setPassword("sql");
|
.setPassword("sql");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RequestDataDTO scheduledOperationsMockupData() {
|
||||||
|
return new RequestDataDTO()
|
||||||
|
.setUsername("INTEGRY")
|
||||||
|
.setPassword("INTEGRY");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValidProfileDB() {
|
public boolean isValidProfileDB() {
|
||||||
return !UtilityString.isNullOrEmpty(profileDB);
|
return !UtilityString.isNullOrEmpty(profileDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidCodMdep() {
|
||||||
|
return !UtilityString.isNullOrEmpty(codMdep);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValidDeviceId() {
|
public boolean isValidDeviceId() {
|
||||||
return deviceId != null;
|
return deviceId != null;
|
||||||
}
|
}
|
||||||
@@ -132,6 +174,20 @@ public class RequestDataDTO {
|
|||||||
return profileDB;
|
return profileDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCodMdep() {
|
||||||
|
return codMdep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegryCustomerDB getCustomerDB() {
|
||||||
|
if (UtilityString.isNullOrEmpty(profileDB))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
final SettingsModel settingsModel = ApplicationContextProvider.getApplicationContext().getBean(SettingsModel.class);
|
||||||
|
final String dbName = settingsModel.getDbNameFromProfileDb(profileDB);
|
||||||
|
|
||||||
|
return IntegryCustomerDB.parse(dbName);
|
||||||
|
}
|
||||||
|
|
||||||
public Long getDeviceId() {
|
public Long getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package it.integry.ems.jpa;
|
||||||
|
|
||||||
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.BasicConnectionPool;
|
||||||
|
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MultiTenantDataSource extends AbstractRoutingDataSource {
|
||||||
|
|
||||||
|
private final BasicConnectionPool basicConnectionPool;
|
||||||
|
private final SettingsModel settingsModel;
|
||||||
|
|
||||||
|
public MultiTenantDataSource(BasicConnectionPool basicConnectionPool, SettingsModel settingsModel) {
|
||||||
|
this.basicConnectionPool = basicConnectionPool;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object determineCurrentLookupKey() {
|
||||||
|
return TenantContext.getCurrentTenant();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() {
|
||||||
|
Map<Object, Object> targetDataSources = new HashMap<>();
|
||||||
|
List<AvailableConnectionModel> connections = settingsModel.getAvailableConnections(false);
|
||||||
|
|
||||||
|
// Imposta il primo come default se necessario, o gestisci il caso null
|
||||||
|
DataSource defaultDataSource = null;
|
||||||
|
|
||||||
|
for (AvailableConnectionModel model : connections) {
|
||||||
|
DataSource ds = basicConnectionPool.getDataSource(model.getProfileName());
|
||||||
|
if (ds != null) {
|
||||||
|
targetDataSources.put(model.getProfileName(), ds);
|
||||||
|
if (defaultDataSource == null) {
|
||||||
|
defaultDataSource = ds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setTargetDataSources(targetDataSources);
|
||||||
|
this.setDefaultTargetDataSource(defaultDataSource);
|
||||||
|
super.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metodo per ricaricare i datasource se vengono aggiunti nuovi tenant a runtime
|
||||||
|
public void refreshDataSources() {
|
||||||
|
this.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
18
ems-core/src/main/java/it/integry/ems/jpa/TenantContext.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package it.integry.ems.jpa;
|
||||||
|
|
||||||
|
public class TenantContext {
|
||||||
|
private static final ThreadLocal<String> currentTenant = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void setCurrentTenant(String tenant) {
|
||||||
|
currentTenant.set(tenant);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCurrentTenant() {
|
||||||
|
return currentTenant.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
currentTenant.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package it.integry.ems.jpa.entity;
|
||||||
|
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class BaseEntity implements Serializable {
|
||||||
|
// Classe base per le entity JPA
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.repository.NoRepositoryBean;
|
||||||
|
|
||||||
|
@NoRepositoryBean
|
||||||
|
public interface BaseRepository<T, ID> extends JpaRepository<T, ID> {
|
||||||
|
// Interfaccia base per i repository
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.MtbAart;
|
||||||
|
import org.springframework.data.jpa.repository.EntityGraph;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MtbAartRepository extends BaseRepository<MtbAart, String> {
|
||||||
|
|
||||||
|
Optional<MtbAart> findByCodMart(String codMart);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis"})
|
||||||
|
Optional<MtbAart> findWithUntMisByCodMart(String codMart);
|
||||||
|
|
||||||
|
List<MtbAart> findByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis"})
|
||||||
|
List<MtbAart> findWithUntMisByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbUntMis", "mtbAartBarCode"})
|
||||||
|
List<MtbAart> findWithBarcodeWithUntMisByCodMartIn(List<String> codMarts);
|
||||||
|
|
||||||
|
@EntityGraph(attributePaths = {"mtbAartBarCode"})
|
||||||
|
Optional<MtbAart> findWithBarcodeByCodMart(String codMart);
|
||||||
|
|
||||||
|
@Query("SELECT m FROM MtbAart m WHERE m.untMis = 'KG'")
|
||||||
|
List<MtbAart> findByUntMisKG();
|
||||||
|
|
||||||
|
@Query("SELECT m.flagQtaCnfFissa FROM MtbAart m WHERE m.codMart = :codMart")
|
||||||
|
Optional<String> findFlagQtaCnfFissaByCodMart(@Param("codMart") String codMart);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.jpa.repository;
|
||||||
|
|
||||||
|
import it.integry.ems_model.entity.MtbUntMis;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface MtbUntMisRepository extends BaseRepository<MtbUntMis, String> {
|
||||||
|
|
||||||
|
Optional<MtbUntMis> findByUntMis(String untMis);
|
||||||
|
|
||||||
|
List<MtbUntMis> findByUntMisIn(List<String> untMis);
|
||||||
|
|
||||||
|
@Query("SELECT a.mtbUntMis FROM MtbAart a WHERE a.codMart = :codMart")
|
||||||
|
Optional<MtbUntMis> findByCodMart(@Param("codMart") String codMart);
|
||||||
|
|
||||||
|
int countByUntMis(String untMis);
|
||||||
|
|
||||||
|
@Query("SELECT u.cifreDec FROM MtbUntMis u WHERE u.flagUnitaKg = :flagUnitaKg")
|
||||||
|
List<BigDecimal> findCifreDecByFlagUnitaKg(@Param("flagUnitaKg") String flagUnitaKg);
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ public class JsonObjectMapperConfig {
|
|||||||
|
|
||||||
module.addDeserializer(BigDecimal.class, new BigDecimalDeserialize());
|
module.addDeserializer(BigDecimal.class, new BigDecimalDeserialize());
|
||||||
module.addDeserializer(Integer.class, new IntegerDeserializer());
|
module.addDeserializer(Integer.class, new IntegerDeserializer());
|
||||||
|
module.addDeserializer(Long.class, new LongDeserializer());
|
||||||
|
|
||||||
module.addDeserializer(String.class, new StringUnicodeDeserialize());
|
module.addDeserializer(String.class, new StringUnicodeDeserialize());
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package it.integry.ems.license;
|
package it.integry.ems.license;
|
||||||
|
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.context.ContextLoader;
|
||||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -11,7 +12,6 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
|
public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LicenseComponent licenseComponent;
|
private LicenseComponent licenseComponent;
|
||||||
|
|
||||||
@@ -19,13 +19,9 @@ public class LicenseCheckInterceptor extends HandlerInterceptorAdapter {
|
|||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response, Object handler) {
|
HttpServletResponse response, Object handler) {
|
||||||
|
|
||||||
|
RequestDataDTO requestData = ContextLoader.getCurrentWebApplicationContext().getBean(RequestDataDTO.class);
|
||||||
|
|
||||||
String profileDB = null;
|
String profileDB = requestData.getProfileDB();
|
||||||
if (request != null && request.getQueryString() != null && request.getQueryString().contains(CommonConstants.PROFILE_DB)) {
|
|
||||||
profileDB = request.getParameter(CommonConstants.PROFILE_DB);
|
|
||||||
} else if (request != null && request.getHeader(CommonConstants.PROFILE_DB) != null) {
|
|
||||||
profileDB = request.getHeader(CommonConstants.PROFILE_DB);
|
|
||||||
}
|
|
||||||
|
|
||||||
LicenseStatusDTO licenseStatusDTO = null;
|
LicenseStatusDTO licenseStatusDTO = null;
|
||||||
if (profileDB != null) licenseStatusDTO = licenseComponent.getLicenseStatus(profileDB);
|
if (profileDB != null) licenseStatusDTO = licenseComponent.getLicenseStatus(profileDB);
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
|
|||||||
import it.integry.ems.response.EsitoType;
|
import it.integry.ems.response.EsitoType;
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
import it.integry.ems.service.HttpRestWrapper;
|
import it.integry.ems.service.HttpRestWrapper;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -59,11 +60,11 @@ public class LicenseComponent {
|
|||||||
if (!canStart)
|
if (!canStart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<AvailableConnectionsModel> availableConnectionsModels = settingsModel.getAvailableConnections(true);
|
List<AvailableConnectionModel> availableConnectionModels = settingsModel.getAvailableConnections(true);
|
||||||
|
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager()) {
|
||||||
|
|
||||||
for (AvailableConnectionsModel model : availableConnectionsModels) {
|
for (AvailableConnectionModel model : availableConnectionModels) {
|
||||||
multiDBTransactionManager.addConnection(model);
|
multiDBTransactionManager.addConnection(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,12 +83,12 @@ public class LicenseComponent {
|
|||||||
|
|
||||||
final HashMap<String, String> listAziende = new HashMap<>();
|
final HashMap<String, String> listAziende = new HashMap<>();
|
||||||
|
|
||||||
for (AdvancedDataSource model : multiDBTransactionManager.getActiveConnections()) {
|
for (Connection connection : multiDBTransactionManager.getActiveConnections()) {
|
||||||
String sql = "SELECT part_iva FROM azienda WHERE part_iva is not null";
|
String sql = "SELECT part_iva FROM azienda WHERE part_iva is not null";
|
||||||
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(model.getConnection(), sql);
|
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(partIva))
|
if (!UtilityString.isNullOrEmpty(partIva))
|
||||||
listAziende.put(model.getProfileName(), partIva);
|
listAziende.put(connection.getProfileName(), partIva);
|
||||||
}
|
}
|
||||||
|
|
||||||
String jsonBody = jsonObjectMapper.writeValueAsString(listAziende.values());
|
String jsonBody = jsonObjectMapper.writeValueAsString(listAziende.values());
|
||||||
@@ -105,14 +106,19 @@ public class LicenseComponent {
|
|||||||
} else {
|
} else {
|
||||||
List<LicenseStatusDTO> licenses = response.getDTO(new TypeReference<List<LicenseStatusDTO>>() {
|
List<LicenseStatusDTO> licenses = response.getDTO(new TypeReference<List<LicenseStatusDTO>>() {
|
||||||
});
|
});
|
||||||
if (licenses == null) return;
|
if (licenses == null || licenses.isEmpty()) return;
|
||||||
|
|
||||||
listAziende.forEach((key, value) -> {
|
listAziende.forEach((key, value) -> {
|
||||||
cachedLicenseStatus.remove(key);
|
cachedLicenseStatus.remove(key);
|
||||||
|
|
||||||
licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
|
final Optional<LicenseStatusDTO> licenseSearch = licenses.stream().filter(x -> x.getPartIva().equalsIgnoreCase(value))
|
||||||
.findFirst()
|
.findFirst();
|
||||||
.ifPresent(license -> cachedLicenseStatus.put(key, license));
|
|
||||||
|
if (licenseSearch.isPresent()) {
|
||||||
|
cachedLicenseStatus.put(key, licenseSearch.get());
|
||||||
|
} else {
|
||||||
|
cachedLicenseStatus.put(key, licenses.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,13 @@ import java.util.Date;
|
|||||||
public class LicenseStatusDTO {
|
public class LicenseStatusDTO {
|
||||||
@SqlField("part_iva")
|
@SqlField("part_iva")
|
||||||
private String partIva;
|
private String partIva;
|
||||||
|
|
||||||
@SqlField("classe_merito")
|
@SqlField("classe_merito")
|
||||||
private Quality quality;
|
private Quality quality;
|
||||||
|
|
||||||
@SqlField
|
@SqlField
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
@SqlField("data_scad_license")
|
@SqlField("data_scad_license")
|
||||||
private Date expiringDate;
|
private Date expiringDate;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package it.integry.ems.menu.service;
|
package it.integry.ems.menu.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
|
||||||
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||||
import it.integry.annotations.PostContextAutowired;
|
import it.integry.annotations.PostContextAutowired;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
@@ -11,7 +12,6 @@ import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
|||||||
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||||
import it.integry.ems.service.MailService;
|
import it.integry.ems.service.MailService;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDirs;
|
import it.integry.ems.utility.UtilityDirs;
|
||||||
@@ -57,17 +57,17 @@ public class MenuConfigurationService {
|
|||||||
|
|
||||||
final MenuConfigDTO menuConfig = loadMenuData();
|
final MenuConfigDTO menuConfig = loadMenuData();
|
||||||
|
|
||||||
for (AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
|
for (Connection connection : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
|
||||||
if (advancedDataSource.getDataSource().getDbName().equalsIgnoreCase("menu") || isHistoryDB(advancedDataSource))
|
if (connection.getDbName().equalsIgnoreCase("menu") || isHistoryDB(connection))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||||
internalRefresh(advancedDataSource.getConnection(), menuConfig);
|
internalRefresh(connection, menuConfig);
|
||||||
//logger.debug("Menu refresh time: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
//logger.debug("Menu refresh time: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("Errore durante l'aggiornamento del menu di " + advancedDataSource.getProfileName(), ex);
|
logger.error("Errore durante l'aggiornamento del menu di " + connection.getProfileName(), ex);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,9 +75,9 @@ public class MenuConfigurationService {
|
|||||||
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Fine refresh menu");
|
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Fine refresh menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHistoryDB(AdvancedDataSource advancedDataSource) throws Exception {
|
private boolean isHistoryDB(Connection connection) throws Exception {
|
||||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
return historyProfileDB.equalsIgnoreCase(connection.getProfileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh(Connection connection, boolean forceRefresh) throws Exception {
|
public void refresh(Connection connection, boolean forceRefresh) throws Exception {
|
||||||
@@ -101,6 +101,7 @@ public class MenuConfigurationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig, boolean forceRefresh) throws Exception {
|
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig, boolean forceRefresh) throws Exception {
|
||||||
|
SQLServerConnection sqlServerConnection = connection.unwrap(SQLServerConnection.class);
|
||||||
final Azienda azienda = Azienda.getDefaultAzienda(connection);
|
final Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||||
|
|
||||||
if (azienda.getTipoAzienda() == null)
|
if (azienda.getTipoAzienda() == null)
|
||||||
@@ -121,7 +122,7 @@ public class MenuConfigurationService {
|
|||||||
"descrizione, gest_name, entity_name, picture_menu, picture_select, object_type, flag_printer_setup, parameter, note, open_type, is_deprecated)" +
|
"descrizione, gest_name, entity_name, picture_menu, picture_select, object_type, flag_printer_setup, parameter, note, open_type, is_deprecated)" +
|
||||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuOpzSQL)) {
|
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuOpzSQL)) {
|
||||||
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
|
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
|
||||||
|
|
||||||
insertBulkPs.setString(1, stbMenuOpzDto.getCodOpz());
|
insertBulkPs.setString(1, stbMenuOpzDto.getCodOpz());
|
||||||
@@ -169,7 +170,7 @@ public class MenuConfigurationService {
|
|||||||
"pos_tipo_azienda, pos_cliente, descrizione_estesa) " +
|
"pos_tipo_azienda, pos_cliente, descrizione_estesa) " +
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) connection.prepareStatement(insertStbMenuSql)) {
|
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(insertStbMenuSql)) {
|
||||||
for (StbMenuDTO stbMenuDto : stbMenus) {
|
for (StbMenuDTO stbMenuDto : stbMenus) {
|
||||||
|
|
||||||
insertBulkPs.setString(1, stbMenuDto.getCodOpz());
|
insertBulkPs.setString(1, stbMenuDto.getCodOpz());
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import it.integry.ems.migration._base.MigrationModelInterface;
|
|||||||
import it.integry.ems.service.MailService;
|
import it.integry.ems.service.MailService;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
@@ -25,7 +25,6 @@ import org.reflections.Reflections;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -75,12 +74,12 @@ public class MigrationComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
List<AdvancedDataSource> advancedDataSources;
|
List<Connection> advancedDataSources;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
advancedDataSources = multiDBTransactionManager.getActiveConnections();
|
advancedDataSources = multiDBTransactionManager.getActiveConnections();
|
||||||
advancedDataSources = advancedDataSources.stream()
|
advancedDataSources = advancedDataSources.stream()
|
||||||
.filter(AdvancedDataSource::isInternalDb)
|
.filter(Connection::isInternalDb)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
advancedDataSources = new ArrayList<>();
|
advancedDataSources = new ArrayList<>();
|
||||||
@@ -89,7 +88,7 @@ public class MigrationComponent {
|
|||||||
|
|
||||||
Exception firstException = null;
|
Exception firstException = null;
|
||||||
|
|
||||||
for (final AdvancedDataSource advancedDataSource : advancedDataSources) {
|
for (final Connection advancedDataSource : advancedDataSources) {
|
||||||
try {
|
try {
|
||||||
executeMigrationGroup(advancedDataSource);
|
executeMigrationGroup(advancedDataSource);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -102,9 +101,9 @@ public class MigrationComponent {
|
|||||||
// throw firstException;
|
// throw firstException;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executeMigrationGroup(AdvancedDataSource advancedDataSource) throws Exception {
|
public void executeMigrationGroup(Connection connection) throws Exception {
|
||||||
migrateStatus(advancedDataSource);
|
migrateStatus(connection);
|
||||||
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(advancedDataSource);
|
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(connection);
|
||||||
|
|
||||||
for (Class<? extends MigrationModelInterface> migrationClass : allMigrationsList) {
|
for (Class<? extends MigrationModelInterface> migrationClass : allMigrationsList) {
|
||||||
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
||||||
@@ -113,47 +112,47 @@ public class MigrationComponent {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
executeMigration(migrationClass, connection, settingsController, settingsModel, droolsDataCompleting);
|
||||||
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
updateLastMigrationIntoDB(connection, migrationNumber);
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
advancedDataSource.getConnection().rollback();
|
connection.rollback();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
logger.error("MigrationService - Rollback", ex);
|
logger.error("MigrationService - Rollback", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
trackMigrationError(advancedDataSource, migrationNumber, e);
|
trackMigrationError(connection, migrationNumber, e);
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), false);
|
migrationsErrorMapByProfiles.putIfAbsent(connection.getProfileName(), false);
|
||||||
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), false);
|
migrationsErrorMapByProfiles.replace(connection.getProfileName(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
||||||
AdvancedDataSource advancedDataSource,
|
Connection connection,
|
||||||
SettingsController settingsController,
|
SettingsController settingsController,
|
||||||
SettingsModel settingsModel,
|
SettingsModel settingsModel,
|
||||||
DroolsDataCompleting droolsDataCompleting) throws Exception {
|
DroolsDataCompleting droolsDataCompleting) throws Exception {
|
||||||
|
|
||||||
logger.info("Applico " + migrationClass.getSimpleName() + " " + advancedDataSource.getProfileName());
|
logger.info("Applico " + migrationClass.getSimpleName() + " " + connection.getProfileName());
|
||||||
|
|
||||||
MigrationModelInterface migrationInstance = migrationClass.newInstance();
|
MigrationModelInterface migrationInstance = migrationClass.newInstance();
|
||||||
migrationInstance.init(advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
migrationInstance.init(connection, settingsController, settingsModel, droolsDataCompleting);
|
||||||
migrationInstance.up();
|
migrationInstance.up();
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLastMigrationIntoDB(AdvancedDataSource advancedDataSource, long lastMigraton) throws Exception {
|
public void updateLastMigrationIntoDB(Connection connection, long lastMigraton) throws Exception {
|
||||||
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + lastMigraton;
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + lastMigraton;
|
||||||
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
|
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
if (stbMigrationStatus == null) {
|
if (stbMigrationStatus == null) {
|
||||||
stbMigrationStatus = new StbMigrationStatus()
|
stbMigrationStatus = new StbMigrationStatus()
|
||||||
@@ -171,9 +170,9 @@ public class MigrationComponent {
|
|||||||
stbMigrationStatus.setOperation(OperationType.UPDATE);
|
stbMigrationStatus.setOperation(OperationType.UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
stbMigrationStatus.manageWithParentConnection(connection);
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,9 +184,9 @@ public class MigrationComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void migrateStatus(AdvancedDataSource advancedDataSource) throws Exception {
|
private void migrateStatus(Connection connection) throws Exception {
|
||||||
final long lastMigrationNumber = getLastMigrationFromDB(advancedDataSource);
|
final long lastMigrationNumber = getLastMigrationFromDB(connection);
|
||||||
final List<Long> alreadyExecutedMigrations = retrieveAllMigrationsStatus(advancedDataSource)
|
final List<Long> alreadyExecutedMigrations = retrieveAllMigrationsStatus(connection)
|
||||||
.stream()
|
.stream()
|
||||||
.map(StbMigrationStatus::getMigrationCode)
|
.map(StbMigrationStatus::getMigrationCode)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -205,25 +204,25 @@ public class MigrationComponent {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (StbMigrationStatus stbMigrationStatus : migrationStatusesToMigrate)
|
for (StbMigrationStatus stbMigrationStatus : migrationStatusesToMigrate)
|
||||||
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
stbMigrationStatus.manageWithParentConnection(connection);
|
||||||
|
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getLastMigrationFromDB(AdvancedDataSource advancedDataSource) throws Exception {
|
private Long getLastMigrationFromDB(Connection connection) throws Exception {
|
||||||
String sql = "SELECT last_migration FROM azienda";
|
String sql = "SELECT last_migration FROM azienda";
|
||||||
String lastMigration = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
String lastMigration = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
lastMigration = UtilityString.isNullOrEmpty(lastMigration) ? "-1" : lastMigration;
|
lastMigration = UtilityString.isNullOrEmpty(lastMigration) ? "-1" : lastMigration;
|
||||||
|
|
||||||
return Long.parseLong(lastMigration);
|
return Long.parseLong(lastMigration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<StbMigrationStatus> retrieveAllMigrationsStatus(AdvancedDataSource advancedDataSource) throws
|
private List<StbMigrationStatus> retrieveAllMigrationsStatus(Connection connection) throws
|
||||||
SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY;
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY;
|
||||||
List<StbMigrationStatus> stbMigrationStatuses = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
|
List<StbMigrationStatus> stbMigrationStatuses = UtilityDB.executeSimpleQueryDTO(connection, sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
if (stbMigrationStatuses == null) return new ArrayList<>();
|
if (stbMigrationStatuses == null) return new ArrayList<>();
|
||||||
|
|
||||||
@@ -234,14 +233,14 @@ public class MigrationComponent {
|
|||||||
return stbMigrationStatuses;
|
return stbMigrationStatuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trackMigrationError(AdvancedDataSource advancedDataSource, long migrationCode, Exception e) {
|
private void trackMigrationError(Connection connection, long migrationCode, Exception e) {
|
||||||
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), true);
|
migrationsErrorMapByProfiles.putIfAbsent(connection.getProfileName(), true);
|
||||||
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), true);
|
migrationsErrorMapByProfiles.replace(connection.getProfileName(), true);
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
logger.error("MigrationService (" + connection.getProfileName() + ")", e);
|
||||||
|
|
||||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(advancedDataSource.getProfileName())) {
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connection.getProfileName())) {
|
||||||
final String exceptionTraceAsString = GeneralUtils.getExceptionTraceAsString(e);
|
final String exceptionTraceAsString = GeneralUtils.getExceptionTraceAsString(e);
|
||||||
|
|
||||||
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
|
||||||
@@ -259,8 +258,8 @@ public class MigrationComponent {
|
|||||||
.setCompleted(false)
|
.setCompleted(false)
|
||||||
.setSkipped(false)
|
.setSkipped(false)
|
||||||
.setErrorMessage(e.getMessage() + "\n" + exceptionTraceAsString);
|
.setErrorMessage(e.getMessage() + "\n" + exceptionTraceAsString);
|
||||||
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
stbMigrationStatus.manageWithParentConnection(connection);
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
|
|
||||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) return;
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) return;
|
||||||
|
|
||||||
@@ -268,7 +267,7 @@ public class MigrationComponent {
|
|||||||
|
|
||||||
mailService.sendSystemWarningLog("[" + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Aggiornamento sistema",
|
mailService.sendSystemWarningLog("[" + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Aggiornamento sistema",
|
||||||
"anomalia durante l'aggiornamento",
|
"anomalia durante l'aggiornamento",
|
||||||
"La migrazione " + migrationCode + " non è andata a buon fine sul DB " + advancedDataSource.getProfileName() + ". Controllare il log per ulteriori dettagli.",
|
"La migrazione " + migrationCode + " non è andata a buon fine sul DB " + connection.getProfileName() + ". Controllare il log per ulteriori dettagli.",
|
||||||
e, new Date());
|
e, new Date());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("MigrationService - Mail", ex);
|
logger.error("MigrationService - Mail", ex);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseSche
|
|||||||
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
import it.integry.ems_model.entity.Azienda;
|
import it.integry.ems_model.entity.Azienda;
|
||||||
@@ -18,10 +17,12 @@ import it.integry.ems_model.exception.DataConverterNotFoundException;
|
|||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
import it.integry.ems_model.types.ApplicationName;
|
import it.integry.ems_model.types.ApplicationName;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.types.TypeDbObject;
|
||||||
import it.integry.ems_model.utility.Query;
|
import it.integry.ems_model.utility.Query;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
import it.integry.ems_model.utility.dto.PkTableDTO;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
@@ -38,7 +39,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class BaseMigration implements MigrationModelInterface {
|
public abstract class BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
protected AdvancedDataSource advancedDataSource;
|
protected Connection connection;
|
||||||
protected SettingsController settingsController;
|
protected SettingsController settingsController;
|
||||||
protected SettingsModel settingsModel;
|
protected SettingsModel settingsModel;
|
||||||
protected DroolsDataCompleting droolsDataCompleting;
|
protected DroolsDataCompleting droolsDataCompleting;
|
||||||
@@ -46,8 +47,8 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
protected final Logger logger = LogManager.getLogger();
|
protected final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AdvancedDataSource advancedDataSource, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
|
public void init(Connection connection, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
|
||||||
this.advancedDataSource = advancedDataSource;
|
this.connection = connection;
|
||||||
this.settingsController = settingsController;
|
this.settingsController = settingsController;
|
||||||
this.settingsModel = settingsModel;
|
this.settingsModel = settingsModel;
|
||||||
this.droolsDataCompleting = droolsDataCompleting;
|
this.droolsDataCompleting = droolsDataCompleting;
|
||||||
@@ -59,7 +60,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
|
|
||||||
protected boolean isHistoryDB() throws Exception {
|
protected boolean isHistoryDB() throws Exception {
|
||||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
return historyProfileDB.equalsIgnoreCase(connection.getProfileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isDebug() {
|
protected boolean isDebug() {
|
||||||
@@ -67,16 +68,28 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected @NotNull List<HashMap<String, Object>> executeQuery(String sql) throws SQLException, IOException {
|
protected @NotNull List<HashMap<String, Object>> executeQuery(String sql) throws SQLException {
|
||||||
return UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
return UtilityDB.executeSimpleQuery(connection, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected @NotNull <T> List<T> executeQueryDTO(String sql, Class<T> clazz) throws Exception {
|
protected @NotNull <T> List<T> executeQueryDTO(String sql, Class<T> clazz) throws Exception {
|
||||||
return UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, clazz);
|
return UtilityDB.executeSimpleQueryDTO(connection, sql, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeStatement(String... sqls) throws SQLException, IOException {
|
protected @NotNull <T> List<T> executeQueryOnlyFirstColumn(String sql) throws SQLException {
|
||||||
executeStatement(advancedDataSource.getConnection(), sqls);
|
return UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull HashMap<String, Object> executeQueryOnlyFirstRow(String sql) throws SQLException {
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull <T> T executeQueryOnlyFirstRowFirstColumn(String sql) throws SQLException {
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void executeStatement(String... sqls) throws SQLException {
|
||||||
|
executeStatement(connection, sqls);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void executeStatement(Connection connection, String... sqls) throws SQLException {
|
protected void executeStatement(Connection connection, String... sqls) throws SQLException {
|
||||||
@@ -90,7 +103,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
protected long executeInsertStatement(String sql) throws SQLException {
|
protected long executeInsertStatement(String sql) throws SQLException {
|
||||||
long generatedId = -1;
|
long generatedId = -1;
|
||||||
|
|
||||||
try (PreparedStatement pstmt = advancedDataSource.getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
|
try (PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
|
||||||
|
|
||||||
int affectedRows = pstmt.executeUpdate();
|
int affectedRows = pstmt.executeUpdate();
|
||||||
|
|
||||||
@@ -102,8 +115,6 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return generatedId;
|
return generatedId;
|
||||||
@@ -130,8 +141,8 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
alterObject(SqlObjectTypeEnum.VIEW, objectName, createViewSql);
|
alterObject(SqlObjectTypeEnum.VIEW, objectName, createViewSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean existsView(String objectName) throws SQLException, IOException {
|
protected boolean existsView(String objectName) throws SQLException {
|
||||||
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
|
return UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, "SELECT COUNT(*) FROM SYSOBJECTS WHERE id = object_id('" + objectName + "')") > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createOrUpdateProcedure(String objectName, String createProcedureSql) throws SQLException, IOException {
|
protected void createOrUpdateProcedure(String objectName, String createProcedureSql) throws SQLException, IOException {
|
||||||
@@ -143,6 +154,10 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
private void alterObject(SqlObjectTypeEnum sqlObject, String objectName, String sql) throws SQLException, IOException {
|
||||||
|
if (UtilityString.isNullOrEmpty(objectName)) {
|
||||||
|
throw new IllegalArgumentException("ObjectName in createOrUpdateFunction(), createOrUpdateView(), createOrUpdateTrigger(), createOrUpdateProcedure() cannot be null or empty");
|
||||||
|
}
|
||||||
|
|
||||||
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
executeStatement("IF EXISTS (SELECT * FROM SYSOBJECTS WHERE id = object_id('" + objectName + "'))\r\n" +
|
||||||
"\tDROP " + sqlObject.toString() + " " + objectName,
|
"\tDROP " + sqlObject.toString() + " " + objectName,
|
||||||
sql);
|
sql);
|
||||||
@@ -154,15 +169,28 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void createIndex(IndexTableDTO indexTableDTO) throws Exception {
|
protected void createIndex(IndexTableDTO indexTableDTO) throws Exception {
|
||||||
UtilityDB.createIndex(advancedDataSource.getConnection(), indexTableDTO);
|
UtilityDB.createIndex(connection, indexTableDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dropIndex(String tableName, String indexName) throws Exception {
|
protected void createPrimaryKey(PkTableDTO pkTableDTO) throws Exception {
|
||||||
UtilityDB.dropIndex(advancedDataSource.getConnection(), tableName, indexName);
|
UtilityDB.createPK(connection, pkTableDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean existsColumn(String tableName, String columnName) throws SQLException, IOException {
|
protected void cloneTable(String sourceTable, String newTable, boolean fillNewTable, boolean dropOldTable, boolean renameNewTable) throws Exception {
|
||||||
|
UtilityDB.cloneTable(connection, sourceTable, newTable, fillNewTable, dropOldTable, renameNewTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean existIndex(String tableName, String indexName) throws SQLException {
|
||||||
|
return UtilityDB.existIndex(connection, tableName, indexName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropIndex(String tableName, String indexName) throws SQLException {
|
||||||
|
UtilityDB.dropIndex(connection, tableName, indexName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean existsColumn(String tableName, String columnName) throws SQLException {
|
||||||
String schema = null;
|
String schema = null;
|
||||||
if (tableName.contains(".")) {
|
if (tableName.contains(".")) {
|
||||||
schema = tableName.substring(0, tableName.indexOf("."));
|
schema = tableName.substring(0, tableName.indexOf("."));
|
||||||
@@ -173,7 +201,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
" WHERE Name = N{}\n" +
|
" WHERE Name = N{}\n" +
|
||||||
" AND Object_ID = Object_ID(N{})", columnName, (schema != null ? schema : "dbo") + "." + tableName);
|
" AND Object_ID = Object_ID(N{})", columnName, (schema != null ? schema : "dbo") + "." + tableName);
|
||||||
|
|
||||||
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
return val != null && val == 1;
|
return val != null && val == 1;
|
||||||
}
|
}
|
||||||
@@ -192,7 +220,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <T> void addDefault(String tableName, String columnName, T defaultValue) throws SQLException, IOException {
|
protected <T> void addDefault(String tableName, String columnName, T defaultValue) throws SQLException, IOException {
|
||||||
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||||
"FROM sys.syscolumns\n" +
|
"FROM sys.syscolumns\n" +
|
||||||
"WHERE name = %s\n" +
|
"WHERE name = %s\n" +
|
||||||
@@ -203,7 +231,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void dropDefault(String tableName, String columnName) throws SQLException, IOException {
|
protected void dropDefault(String tableName, String columnName) throws SQLException, IOException {
|
||||||
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
boolean existDefault = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||||
"FROM sys.syscolumns\n" +
|
"FROM sys.syscolumns\n" +
|
||||||
"WHERE name = %s\n" +
|
"WHERE name = %s\n" +
|
||||||
@@ -216,7 +244,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void dropChecks(String tableName, String columnName) throws SQLException, IOException {
|
protected void dropChecks(String tableName, String columnName) throws SQLException, IOException {
|
||||||
boolean checkExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
boolean checkExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
Query.format("SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||||
"FROM sys.objects obj_table\n" +
|
"FROM sys.objects obj_table\n" +
|
||||||
" JOIN sys.objects obj_Constraint\n" +
|
" JOIN sys.objects obj_Constraint\n" +
|
||||||
@@ -235,7 +263,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean existsTable(String tableName) throws SQLException, IOException {
|
protected boolean existsTable(String tableName) throws SQLException {
|
||||||
String schema = null;
|
String schema = null;
|
||||||
if (tableName.contains(".")) {
|
if (tableName.contains(".")) {
|
||||||
schema = tableName.substring(0, tableName.indexOf("."));
|
schema = tableName.substring(0, tableName.indexOf("."));
|
||||||
@@ -248,7 +276,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
if (schema != null)
|
if (schema != null)
|
||||||
sql += Query.format("AND TABLE_SCHEMA = N%s", schema);
|
sql += Query.format("AND TABLE_SCHEMA = N%s", schema);
|
||||||
|
|
||||||
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dropTable(String tableName) throws SQLException, IOException {
|
protected void dropTable(String tableName) throws SQLException, IOException {
|
||||||
@@ -264,7 +292,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
|
String sql = Query.format("SELECT cast(count(*) as bit) FROM stb_gest_setup_query WHERE cod_query = %s", codQuery);
|
||||||
boolean existQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
boolean existQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
if (existQuery)
|
if (existQuery)
|
||||||
executeStatement(Query.format("UPDATE stb_gest_setup_query SET query_default = %S, description = %S WHERE cod_query = %s ",
|
executeStatement(Query.format("UPDATE stb_gest_setup_query SET query_default = %S, description = %S WHERE cod_query = %s ",
|
||||||
@@ -274,20 +302,20 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
" VALUES (%s, %s, %s);", codQuery, query, name));
|
" VALUES (%s, %s, %s);", codQuery, query, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean existsSetup(String gestName, String section, String keySection) throws SQLException, IOException {
|
protected boolean existsSetup(String gestName, String section, String keySection) throws SQLException {
|
||||||
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetup.ENTITY +
|
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetup.ENTITY +
|
||||||
" WHERE gest_name = %s AND" +
|
" WHERE gest_name = %s AND" +
|
||||||
" section = %s AND" +
|
" section = %s AND" +
|
||||||
" key_section = %s", gestName, section, keySection);
|
" key_section = %s", gestName, section, keySection);
|
||||||
|
|
||||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean existsSetupQuery(String codQuery) throws SQLException, IOException {
|
protected boolean existsSetupQuery(String codQuery) throws SQLException {
|
||||||
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetupQuery.ENTITY +
|
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM " + StbGestSetupQuery.ENTITY +
|
||||||
" WHERE cod_query = %s", codQuery);
|
" WHERE cod_query = %s", codQuery);
|
||||||
|
|
||||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createSetup(String gestName, String section, String keySection, String value, String description, String codQuery) throws Exception {
|
protected void createSetup(String gestName, String section, String keySection, String value, String description, String codQuery) throws Exception {
|
||||||
@@ -297,7 +325,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
||||||
"(gest_name, section, key_section, value, description, query_default) VALUES (?, ?, ?, ?, ?, ?)";
|
"(gest_name, section, key_section, value, description, query_default) VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
|
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
|
||||||
ps.setString(1, gestName);
|
ps.setString(1, gestName);
|
||||||
ps.setString(2, section);
|
ps.setString(2, section);
|
||||||
ps.setString(3, keySection);
|
ps.setString(3, keySection);
|
||||||
@@ -316,7 +344,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
||||||
"(gest_name, section, key_section, value, description, query_default, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
"(gest_name, section, key_section, value, description, query_default, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
|
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
|
||||||
ps.setString(1, gestName);
|
ps.setString(1, gestName);
|
||||||
ps.setString(2, section);
|
ps.setString(2, section);
|
||||||
ps.setString(3, keySection);
|
ps.setString(3, keySection);
|
||||||
@@ -336,7 +364,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
String insertSql = "INSERT INTO " + StbGestSetup.ENTITY +
|
||||||
"(gest_name, section, key_section, value, description, query_default, flag_multi_value, flag_setup_user_web) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
"(gest_name, section, key_section, value, description, query_default, flag_multi_value, flag_setup_user_web) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
|
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
|
||||||
ps.setString(1, gestName);
|
ps.setString(1, gestName);
|
||||||
ps.setString(2, section);
|
ps.setString(2, section);
|
||||||
ps.setString(3, keySection);
|
ps.setString(3, keySection);
|
||||||
@@ -366,7 +394,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
||||||
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +403,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
|
"flag_user_view, flag_setup_depo, flag_setup_user_web,\n" +
|
||||||
"flag_tipo_json, flag_tipo_colore, tipo_setup, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
"flag_tipo_json, flag_tipo_colore, tipo_setup, flag_multi_value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try (PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(insertSql)) {
|
try (PreparedStatement ps = connection.prepareStatement(insertSql)) {
|
||||||
ps.setString(1, gestName);
|
ps.setString(1, gestName);
|
||||||
ps.setString(2, section);
|
ps.setString(2, section);
|
||||||
ps.setString(3, keySection);
|
ps.setString(3, keySection);
|
||||||
@@ -395,6 +423,25 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getSetupValue(String gestName, String section, String keySection) throws SQLException {
|
||||||
|
String sql = Query.format("SELECT value FROM " + StbGestSetup.ENTITY +
|
||||||
|
" WHERE gest_name = %s AND" +
|
||||||
|
" section = %s AND" +
|
||||||
|
" key_section = %s", gestName, section, keySection);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create a getStbGestSetup method to return the entire StbGestSetup object
|
||||||
|
protected StbGestSetup getStbGestSetup(String gestName, String section, String keySection) throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = Query.format("SELECT * FROM stb_gest_setup " +
|
||||||
|
" WHERE gest_name = %s AND" +
|
||||||
|
" section = %s AND" +
|
||||||
|
" key_section = %s", gestName, section, keySection);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowDTO(connection, sql, StbGestSetup.class);
|
||||||
|
}
|
||||||
|
|
||||||
protected void deleteSetup(String gestName, String section, String keySection) throws Exception {
|
protected void deleteSetup(String gestName, String section, String keySection) throws Exception {
|
||||||
StbGestSetup stbGestSetup = new StbGestSetup()
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
.setGestName(gestName)
|
.setGestName(gestName)
|
||||||
@@ -402,7 +449,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
.setKeySection(keySection);
|
.setKeySection(keySection);
|
||||||
|
|
||||||
stbGestSetup.setOperation(OperationType.DELETE);
|
stbGestSetup.setOperation(OperationType.DELETE);
|
||||||
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSetupValue(String gestName, String section, String keySection, String newValue) throws Exception {
|
protected void updateSetupValue(String gestName, String section, String keySection, String newValue) throws Exception {
|
||||||
@@ -422,7 +469,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
Boolean flagTipoJson, Boolean flagTipoColore, String tipoSetup, Boolean flagMultiValue,
|
Boolean flagTipoJson, Boolean flagTipoColore, String tipoSetup, Boolean flagMultiValue,
|
||||||
String query) throws Exception {
|
String query) throws Exception {
|
||||||
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
||||||
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,13 +504,13 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
stbGestSetup.setFlagMultiValue(flagMultiValue);
|
stbGestSetup.setFlagMultiValue(flagMultiValue);
|
||||||
|
|
||||||
stbGestSetup.setOperation(OperationType.UPDATE);
|
stbGestSetup.setOperation(OperationType.UPDATE);
|
||||||
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSetupQuery(String gestName, String section, String keySection,
|
protected void updateSetupQuery(String gestName, String section, String keySection,
|
||||||
String codQuery, String query) throws Exception {
|
String codQuery, String query) throws Exception {
|
||||||
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
if (!UtilityString.isNullOrEmpty(query) && UtilityString.isNullOrEmpty(codQuery)) {
|
||||||
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
codQuery = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
Query.format("SELECT cod_query FROM stb_gest_setup_query WHERE query_default = %s", query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +521,17 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
.setQueryDefault(codQuery);
|
.setQueryDefault(codQuery);
|
||||||
|
|
||||||
stbGestSetup.setOperation(OperationType.UPDATE);
|
stbGestSetup.setOperation(OperationType.UPDATE);
|
||||||
stbGestSetup.manageWithParentConnection(advancedDataSource.getConnection());
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropSetup(String gestName, String section, String keySection) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.DELETE);
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
||||||
@@ -508,7 +565,7 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
|
|
||||||
|
|
||||||
protected boolean isCustomer(IntegryCustomer... customers) {
|
protected boolean isCustomer(IntegryCustomer... customers) {
|
||||||
String currentDbName = advancedDataSource.getDataSource().getDbName();
|
String currentDbName = connection.getDbName();
|
||||||
|
|
||||||
return Arrays.stream(customers)
|
return Arrays.stream(customers)
|
||||||
.anyMatch(x ->
|
.anyMatch(x ->
|
||||||
@@ -517,31 +574,31 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isCustomerDb(IntegryCustomerDB... customersDbs) {
|
protected boolean isCustomerDb(IntegryCustomerDB... customersDbs) {
|
||||||
String currentDbName = advancedDataSource.getDataSource().getDbName();
|
String currentDbName = connection.getDbName();
|
||||||
|
|
||||||
return Arrays.stream(customersDbs)
|
return Arrays.stream(customersDbs)
|
||||||
.anyMatch(y -> y.getValue().equalsIgnoreCase(currentDbName));
|
.anyMatch(y -> y.getValue().equalsIgnoreCase(currentDbName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean isWingest() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
protected boolean isWingest() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
|
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
|
||||||
return currentAzienda.getApplicationNameEnum() == ApplicationName.WINGEST;
|
return currentAzienda.getApplicationNameEnum() == ApplicationName.WINGEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isTextiles() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
protected boolean isTextiles() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
|
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
|
||||||
return currentAzienda.getApplicationNameEnum() == ApplicationName.TEXTILES;
|
return currentAzienda.getApplicationNameEnum() == ApplicationName.TEXTILES;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isDMS() throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
protected boolean isDMS() throws SQLException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
Azienda currentAzienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
|
Azienda currentAzienda = Azienda.getDefaultAzienda(connection);
|
||||||
return currentAzienda.getApplicationNameEnum() == ApplicationName.DMS;
|
return currentAzienda.getApplicationNameEnum() == ApplicationName.DMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enableSaveToRest(String gestName) throws Exception {
|
protected void enableSaveToRest(String gestName) throws Exception {
|
||||||
boolean existRow =
|
boolean existRow =
|
||||||
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT cast(count(*) as bit) FROM stb_gest_sync WHERE gest_name = %s", gestName));
|
Query.format("SELECT cast(count(*) as bit) FROM stb_gest_sync WHERE gest_name = %s", gestName));
|
||||||
|
|
||||||
StbGestSync gestSync =
|
StbGestSync gestSync =
|
||||||
@@ -552,21 +609,21 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
gestSync.setOperation(OperationType.UPDATE);
|
gestSync.setOperation(OperationType.UPDATE);
|
||||||
} else {
|
} else {
|
||||||
String entityName =
|
String entityName =
|
||||||
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT entity_name FROM stb_menu_opz WHERE gest_name = %s", gestName));
|
Query.format("SELECT entity_name FROM stb_menu_opz WHERE gest_name = %s", gestName));
|
||||||
gestSync.setEntityName(entityName);
|
gestSync.setEntityName(entityName);
|
||||||
gestSync.setOperation(OperationType.INSERT);
|
gestSync.setOperation(OperationType.INSERT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gestSync.manageWithParentConnection(advancedDataSource.getConnection());
|
gestSync.manageWithParentConnection(connection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseVersionEnum getSqlCompatibilityLevel() throws Exception {
|
private DatabaseVersionEnum getSqlCompatibilityLevel() throws Exception {
|
||||||
short compatibilityLevel =
|
short compatibilityLevel =
|
||||||
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
Query.format("SELECT compatibility_level FROM sys.databases WHERE name = %s", advancedDataSource.getDataSource().getDbName()));
|
Query.format("SELECT compatibility_level FROM sys.databases WHERE name = %s", connection.getDbName()));
|
||||||
|
|
||||||
|
|
||||||
return DatabaseVersionEnum.fromCode(compatibilityLevel);
|
return DatabaseVersionEnum.fromCode(compatibilityLevel);
|
||||||
@@ -597,4 +654,38 @@ public abstract class BaseMigration implements MigrationModelInterface {
|
|||||||
protected boolean isSqlServer2022() throws Exception {
|
protected boolean isSqlServer2022() throws Exception {
|
||||||
return getSqlCompatibilityLevel() == DatabaseVersionEnum.SQLServer2022;
|
return getSqlCompatibilityLevel() == DatabaseVersionEnum.SQLServer2022;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addDescriptionTable(String tableName, String description) throws SQLException {
|
||||||
|
if (existsTable(tableName)) {
|
||||||
|
addDescriptionObject(tableName, TypeDbObject.TABLE, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addDescriptionView(String viewName, String description) throws SQLException {
|
||||||
|
if (existsView(viewName)) {
|
||||||
|
addDescriptionObject(viewName, TypeDbObject.VIEW, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDescriptionObject(String objectName, TypeDbObject type, String description) throws SQLException {
|
||||||
|
String typeString = "TABLE";
|
||||||
|
|
||||||
|
if (type == TypeDbObject.VIEW) {
|
||||||
|
typeString = "VIEW";
|
||||||
|
}
|
||||||
|
executeStatement(
|
||||||
|
Query.format("EXEC sp_addextendedproperty " +
|
||||||
|
"@name = N'MS_Description', " +
|
||||||
|
"@value = %s, " +
|
||||||
|
"@level0type = N'SCHEMA', @level0name = 'dbo', " +
|
||||||
|
"@level1type = %s, @level1name = %s;", description, typeString, objectName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDescriptionColumn(String tableName, String columnName, String description) throws SQLException {
|
||||||
|
executeStatement(Query.format("EXEC sp_addextendedproperty 'MS_Description', %s, 'SCHEMA', 'dbo', 'TABLE',%s, 'COLUMN', %s)",
|
||||||
|
description, tableName, columnName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public enum IntegryCustomer {
|
|||||||
IntegryCustomerDB.Agricoper_IlVisone,
|
IntegryCustomerDB.Agricoper_IlVisone,
|
||||||
IntegryCustomerDB.Agricoper_Luva),
|
IntegryCustomerDB.Agricoper_Luva),
|
||||||
|
|
||||||
ATI(IntegryCustomerDB.ATI_Finpart),
|
ATI(IntegryCustomerDB.ATI, IntegryCustomerDB.ATI_Finpart),
|
||||||
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
Auricchio(IntegryCustomerDB.Auricchio_Auricchio,
|
||||||
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
IntegryCustomerDB.Auricchio_AuricchioMiki,
|
||||||
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
IntegryCustomerDB.Auricchio_AuricchioSrl,
|
||||||
@@ -20,6 +20,7 @@ public enum IntegryCustomer {
|
|||||||
Biolevante(IntegryCustomerDB.Biolevante_Biolevante,
|
Biolevante(IntegryCustomerDB.Biolevante_Biolevante,
|
||||||
IntegryCustomerDB.Biolevante_BiolevanteStorico,
|
IntegryCustomerDB.Biolevante_BiolevanteStorico,
|
||||||
IntegryCustomerDB.Biolevante_TenutaSanMartino),
|
IntegryCustomerDB.Biolevante_TenutaSanMartino),
|
||||||
|
CapelliMonelli(IntegryCustomerDB.CapelliMonelli_CapelliMonelli),
|
||||||
Carelli(IntegryCustomerDB.Carelli_Carelli,
|
Carelli(IntegryCustomerDB.Carelli_Carelli,
|
||||||
IntegryCustomerDB.Carelli_GestFood,
|
IntegryCustomerDB.Carelli_GestFood,
|
||||||
IntegryCustomerDB.Carelli_Chiuso,
|
IntegryCustomerDB.Carelli_Chiuso,
|
||||||
@@ -70,7 +71,8 @@ public enum IntegryCustomer {
|
|||||||
Gramm(IntegryCustomerDB.Gramm_Gramm,
|
Gramm(IntegryCustomerDB.Gramm_Gramm,
|
||||||
IntegryCustomerDB.Gramm_PrimeOlive,
|
IntegryCustomerDB.Gramm_PrimeOlive,
|
||||||
IntegryCustomerDB.Gramm_ProveStage,
|
IntegryCustomerDB.Gramm_ProveStage,
|
||||||
IntegryCustomerDB.Gramm_2MHolding),
|
IntegryCustomerDB.Gramm_2MHolding,
|
||||||
|
IntegryCustomerDB.Gramm_GrammUsa),
|
||||||
Idrotecnica(IntegryCustomerDB.Idrotecnica_Idrotecnica),
|
Idrotecnica(IntegryCustomerDB.Idrotecnica_Idrotecnica),
|
||||||
Igood(IntegryCustomerDB.Igood_Aida,
|
Igood(IntegryCustomerDB.Igood_Aida,
|
||||||
IntegryCustomerDB.Igood_Igood,
|
IntegryCustomerDB.Igood_Igood,
|
||||||
@@ -117,7 +119,10 @@ public enum IntegryCustomer {
|
|||||||
IntegryCustomerDB.Suit_TenutaArianna,
|
IntegryCustomerDB.Suit_TenutaArianna,
|
||||||
IntegryCustomerDB.Suit_Valpietro),
|
IntegryCustomerDB.Suit_Valpietro),
|
||||||
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
Tempesta(IntegryCustomerDB.Tempesta_Tempesta,
|
||||||
IntegryCustomerDB.Tempesta_VivaiTempesta),
|
IntegryCustomerDB.Tempesta_DI,
|
||||||
|
IntegryCustomerDB.Tempesta_VivaiTempesta,
|
||||||
|
IntegryCustomerDB.Tempesta_VivaiTempesta_DI
|
||||||
|
),
|
||||||
Tosca(IntegryCustomerDB.Tosca_Ba,
|
Tosca(IntegryCustomerDB.Tosca_Ba,
|
||||||
IntegryCustomerDB.Tosca_Ce,
|
IntegryCustomerDB.Tosca_Ce,
|
||||||
IntegryCustomerDB.Tosca_Cz,
|
IntegryCustomerDB.Tosca_Cz,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package it.integry.ems.migration._base;
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
|
import it.integry.ems.exception.InvalidCustomerDbException;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -9,7 +10,9 @@ public enum IntegryCustomerDB {
|
|||||||
Agricoper_IlVisone("ilvisone"),
|
Agricoper_IlVisone("ilvisone"),
|
||||||
Agricoper_Luva("luva"),
|
Agricoper_Luva("luva"),
|
||||||
|
|
||||||
|
ATI("atisrl"),
|
||||||
ATI_Finpart("Finpart"),
|
ATI_Finpart("Finpart"),
|
||||||
|
|
||||||
Auricchio_Auricchio("auricchio"),
|
Auricchio_Auricchio("auricchio"),
|
||||||
Auricchio_AuricchioMiki("auricchio_miki"),
|
Auricchio_AuricchioMiki("auricchio_miki"),
|
||||||
Auricchio_AuricchioSrl("auricchiosrl"),
|
Auricchio_AuricchioSrl("auricchiosrl"),
|
||||||
@@ -24,12 +27,14 @@ public enum IntegryCustomerDB {
|
|||||||
Biolevante_BiolevanteStorico("biolevante_storico"),
|
Biolevante_BiolevanteStorico("biolevante_storico"),
|
||||||
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
Biolevante_TenutaSanMartino("tenutasanmartino"),
|
||||||
|
|
||||||
|
CapelliMonelli_CapelliMonelli("capelli_monelli"),
|
||||||
|
|
||||||
Carelli_Carelli("carelli"),
|
Carelli_Carelli("carelli"),
|
||||||
Carelli_GestFood("gestfood"),
|
Carelli_GestFood("gestfood"),
|
||||||
Carelli_Chiuso("chiuso"),
|
Carelli_Chiuso("chiuso"),
|
||||||
Carelli_Format("format"),
|
Carelli_Format("format"),
|
||||||
Carelli_Murgia("murgia"),
|
Carelli_Murgia("murgia"),
|
||||||
|
Carelli_MurgiaTest("murgia_test"),
|
||||||
Carelli_Panimal("panimal"),
|
Carelli_Panimal("panimal"),
|
||||||
Carelli_Winact("winact"),
|
Carelli_Winact("winact"),
|
||||||
Carelli_Csgr("csgr"),
|
Carelli_Csgr("csgr"),
|
||||||
@@ -91,7 +96,8 @@ public enum IntegryCustomerDB {
|
|||||||
Gramm_Gramm("gramm"),
|
Gramm_Gramm("gramm"),
|
||||||
Gramm_PrimeOlive("primeolive"),
|
Gramm_PrimeOlive("primeolive"),
|
||||||
Gramm_ProveStage("grammprovestage"),
|
Gramm_ProveStage("grammprovestage"),
|
||||||
Gramm_2MHolding("2M_HOLDING"),
|
Gramm_2MHolding("dueemme"),
|
||||||
|
Gramm_GrammUsa("gramm_usa"),
|
||||||
|
|
||||||
|
|
||||||
Idrotecnica_Idrotecnica("idrotecnica"),
|
Idrotecnica_Idrotecnica("idrotecnica"),
|
||||||
@@ -122,6 +128,7 @@ public enum IntegryCustomerDB {
|
|||||||
Levanplast_Perilflor("perilflor"),
|
Levanplast_Perilflor("perilflor"),
|
||||||
Levanplast_PerilflorSrl("perilflorsrl"),
|
Levanplast_PerilflorSrl("perilflorsrl"),
|
||||||
Levanplast_Levanplast("levanplast"),
|
Levanplast_Levanplast("levanplast"),
|
||||||
|
Levanplast_Levanplastsrl("levanplastsrl"),
|
||||||
|
|
||||||
Maggio_MaggioSrl("maggiosrl"),
|
Maggio_MaggioSrl("maggiosrl"),
|
||||||
Maggio_GiovMaggio("giovmaggio"),
|
Maggio_GiovMaggio("giovmaggio"),
|
||||||
@@ -191,7 +198,9 @@ public enum IntegryCustomerDB {
|
|||||||
|
|
||||||
|
|
||||||
Tempesta_Tempesta("tempesta"),
|
Tempesta_Tempesta("tempesta"),
|
||||||
|
Tempesta_DI("tempestadi"),
|
||||||
Tempesta_VivaiTempesta("vivaitempesta"),
|
Tempesta_VivaiTempesta("vivaitempesta"),
|
||||||
|
Tempesta_VivaiTempesta_DI("vivaitempestadi"),
|
||||||
|
|
||||||
|
|
||||||
Tosca_Ba("tosca_ba"),
|
Tosca_Ba("tosca_ba"),
|
||||||
@@ -229,6 +238,6 @@ public enum IntegryCustomerDB {
|
|||||||
|
|
||||||
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
return Arrays.stream(values()).filter(x -> x.getValue().equalsIgnoreCase(value))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElseThrow(() -> new InvalidCustomerDbException(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package it.integry.ems.migration._base;
|
|||||||
|
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
import it.integry.ems.settings.SettingsController;
|
import it.integry.ems.settings.SettingsController;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
|
|
||||||
public interface MigrationModelInterface {
|
public interface MigrationModelInterface {
|
||||||
|
|
||||||
void init(AdvancedDataSource advancedDataSource,
|
void init(Connection connection,
|
||||||
SettingsController settingsController,
|
SettingsController settingsController,
|
||||||
SettingsModel settingsModel,
|
SettingsModel settingsModel,
|
||||||
DroolsDataCompleting droolsDataCompleting);
|
DroolsDataCompleting droolsDataCompleting);
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
@@ -15,9 +14,9 @@ public class Migration_20210721093948 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void up() throws Exception {
|
public void up() throws Exception {
|
||||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||||
|
|
||||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getProfileName()))
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (historyDBModel == null)
|
if (historyDBModel == null)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Migration_20210721125744 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void up() throws Exception {
|
public void up() throws Exception {
|
||||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getDataSource().getDbName()))
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getDbName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String tomcatPath = System.getProperty("catalina.home");
|
String tomcatPath = System.getProperty("catalina.home");
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionModel;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
@@ -15,9 +14,9 @@ public class Migration_20210924152555 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void up() throws Exception {
|
public void up() throws Exception {
|
||||||
AvailableConnectionsModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
AvailableConnectionModel historyDBModel = settingsController.getHistoryDbConnectionModel();
|
||||||
|
|
||||||
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(advancedDataSource.getProfileName()))
|
if (!settingsModel.getDefaultProfile().equalsIgnoreCase(connection.getProfileName()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (historyDBModel == null)
|
if (historyDBModel == null)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Migration_20211022131206 extends BaseMigration implements Migration
|
|||||||
" WHERE stb_user.user_name IS NULL ";
|
" WHERE stb_user.user_name IS NULL ";
|
||||||
|
|
||||||
|
|
||||||
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, WtbUsers.class);
|
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(connection, sql, WtbUsers.class);
|
||||||
|
|
||||||
if (wtbUsersList == null) return;
|
if (wtbUsersList == null) return;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class Migration_20211022131206 extends BaseMigration implements Migration
|
|||||||
.setFlagAttivo(wtbUser.getCtrlState());
|
.setFlagAttivo(wtbUser.getCtrlState());
|
||||||
|
|
||||||
stbUser.setOperation(OperationType.INSERT);
|
stbUser.setOperation(OperationType.INSERT);
|
||||||
stbUser.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
|
stbUser.manageWithParentConnection(connection, droolsDataCompleting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ public class Migration_20211027170945 extends BaseMigration implements Migration
|
|||||||
"WHERE Name = N'orientation' " +
|
"WHERE Name = N'orientation' " +
|
||||||
" AND Object_ID = Object_ID(N'dbo.wtb_jrept')";
|
" AND Object_ID = Object_ID(N'dbo.wtb_jrept')";
|
||||||
|
|
||||||
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
if (!fieldExists) {
|
if (!fieldExists) {
|
||||||
sql = "ALTER TABLE wtb_jrept ADD orientation INT DEFAULT 0 NOT NULL CHECK (orientation IN (0, 1))";
|
sql = "ALTER TABLE wtb_jrept ADD orientation INT DEFAULT 0 NOT NULL CHECK (orientation IN (0, 1))";
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute(sql);
|
statement.execute(sql);
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ public class Migration_20211108185224 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
||||||
|
|
||||||
final String migrateFileOperationName = "Migrate files grlAnagNote " + advancedDataSource.getProfileName().toUpperCase();
|
final String migrateFileOperationName = "Migrate files grlAnagNote " + connection.getProfileName().toUpperCase();
|
||||||
|
|
||||||
ServiceCallAutomatedOperationDTO serviceCallAutomatedOperationDTO = new ServiceCallAutomatedOperationDTO()
|
ServiceCallAutomatedOperationDTO serviceCallAutomatedOperationDTO = new ServiceCallAutomatedOperationDTO()
|
||||||
.setMethodName("migrateGtbAnagNoteFiles")
|
.setMethodName("migrateGtbAnagNoteFiles")
|
||||||
.setProfileDb(advancedDataSource.getProfileName())
|
.setProfileDb(connection.getProfileName())
|
||||||
.setUsername(advancedDataSource.getProfileName());
|
.setUsername(connection.getProfileName());
|
||||||
|
|
||||||
serviceCallAutomatedOperationDTO
|
serviceCallAutomatedOperationDTO
|
||||||
.setCronTrigger("0 0 0 1/1 * ?")
|
.setCronTrigger("0 0 0 1/1 * ?")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package it.integry.ems.migration.model;
|
|||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.service.PrinterService;
|
import it.integry.ems.service.PrinterService;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||||
import it.integry.ems_model.entity.MtbDepo;
|
import it.integry.ems_model.entity.MtbDepo;
|
||||||
import it.integry.ems_model.entity.WtbJreptSetup;
|
import it.integry.ems_model.entity.WtbJreptSetup;
|
||||||
@@ -13,8 +14,6 @@ import it.integry.ems_model.utility.UtilityString;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
|
||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -29,11 +28,11 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
|
|||||||
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
|
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
|
||||||
"FROM INFORMATION_SCHEMA.TABLES " +
|
"FROM INFORMATION_SCHEMA.TABLES " +
|
||||||
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
|
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
|
||||||
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
|
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
|
||||||
|
|
||||||
if (!existTable) {
|
if (!existTable) {
|
||||||
|
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute("CREATE TABLE wtb_jrept_setup\n" +
|
statement.execute("CREATE TABLE wtb_jrept_setup\n" +
|
||||||
"(\n" +
|
"(\n" +
|
||||||
" id BIGINT IDENTITY\n" +
|
" id BIGINT IDENTITY\n" +
|
||||||
@@ -51,26 +50,26 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
|
|||||||
")");
|
")");
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
statement = advancedDataSource.getConnection().createStatement();
|
statement = connection.createStatement();
|
||||||
statement.execute("CREATE UNIQUE INDEX wtb_jrept_setup_report_id_cod_mdep_tipo_uindex " +
|
statement.execute("CREATE UNIQUE INDEX wtb_jrept_setup_report_id_cod_mdep_tipo_uindex " +
|
||||||
"ON wtb_jrept_setup (report_id, cod_mdep, tipo)");
|
"ON wtb_jrept_setup (report_id, cod_mdep, tipo)");
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
connection.commit();
|
||||||
|
|
||||||
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
|
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
|
||||||
|
|
||||||
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
|
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
|
||||||
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sqlDepo);
|
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sqlDepo);
|
||||||
|
|
||||||
if (codMdeps != null && !codMdeps.isEmpty()) {
|
if (codMdeps != null && !codMdeps.isEmpty()) {
|
||||||
|
|
||||||
for (String codMdep : codMdeps) {
|
for (String codMdep : codMdeps) {
|
||||||
String stampantePrimaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.PRIMARIA);
|
String stampantePrimaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.PRIMARIA);
|
||||||
String stampanteSecondaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.SECONDARIA);
|
String stampanteSecondaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.SECONDARIA);
|
||||||
|
|
||||||
String grlAnagJreptSql = "SELECT DISTINCT report_id, tipo FROM " + GrlAnagJrept.ENTITY;
|
String grlAnagJreptSql = "SELECT DISTINCT report_id, tipo FROM " + GrlAnagJrept.ENTITY;
|
||||||
List<GrlAnagJrept> grlAnagJrepts = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), grlAnagJreptSql, GrlAnagJrept.class);
|
List<GrlAnagJrept> grlAnagJrepts = UtilityDB.executeSimpleQueryDTO(connection, grlAnagJreptSql, GrlAnagJrept.class);
|
||||||
|
|
||||||
if (grlAnagJrepts != null && !UtilityString.isNullOrEmpty(stampantePrimaria)) {
|
if (grlAnagJrepts != null && !UtilityString.isNullOrEmpty(stampantePrimaria)) {
|
||||||
for (GrlAnagJrept grlAnagJrept : grlAnagJrepts) {
|
for (GrlAnagJrept grlAnagJrept : grlAnagJrepts) {
|
||||||
@@ -90,7 +89,7 @@ public class Migration_20220405180136 extends BaseMigration implements Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
|
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
|
||||||
wtbJreptSetup.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
|
wtbJreptSetup.manageWithParentConnection(connection, droolsDataCompleting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import it.integry.ems_model.entity.StbUser;
|
|||||||
import it.integry.ems_model.entity.WtbUsers;
|
import it.integry.ems_model.entity.WtbUsers;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import it.integry.security.utility.CryptoUtils;
|
import it.integry.security.utility.CryptoUtils;
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
|
|||||||
" WHERE stb_user.user_name IS NULL ";
|
" WHERE stb_user.user_name IS NULL ";
|
||||||
|
|
||||||
|
|
||||||
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, WtbUsers.class);
|
List<WtbUsers> wtbUsersList = UtilityDB.executeSimpleQueryDTO(connection, sql, WtbUsers.class);
|
||||||
|
|
||||||
if (wtbUsersList == null) return;
|
if (wtbUsersList == null) return;
|
||||||
|
|
||||||
@@ -57,17 +58,16 @@ public class Migration_20220413102657 extends BaseMigration implements Migration
|
|||||||
.setUserCode(wtbUser.getUserCode())
|
.setUserCode(wtbUser.getUserCode())
|
||||||
.setDetails(wtbUser.getDetails())
|
.setDetails(wtbUser.getDetails())
|
||||||
.setLastAccessDatetime(wtbUser.getLastAccessDatetime())
|
.setLastAccessDatetime(wtbUser.getLastAccessDatetime())
|
||||||
.setPasswordEndtime(wtbUser.getPasswordEndtime())
|
.setPasswordEndtime(UtilityLocalDate.localDateTimeFromDate(wtbUser.getPasswordEndtime()))
|
||||||
.setUrlCss(wtbUser.getUrlCss())
|
.setUrlCss(wtbUser.getUrlCss())
|
||||||
.setCodLang(wtbUser.getCodLang())
|
.setCodLang(wtbUser.getCodLang())
|
||||||
.setCreationDatetime(wtbUser.getCreationDatetime())
|
.setCreationDatetime(wtbUser.getCreationDatetime())
|
||||||
.setPasswordExpiresDays(wtbUser.getPasswordExpiresDays())
|
.setPasswordExpiresDays(wtbUser.getPasswordExpiresDays())
|
||||||
.setLastPasswords(wtbUser.getLastPasswords())
|
.setLastPasswords(wtbUser.getLastPasswords())
|
||||||
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring())
|
.setFlagPasswordExpiring(wtbUser.getFlagPasswordExpiring());
|
||||||
.setDestructionDatetime(wtbUser.getDestructionDatetime());;
|
|
||||||
|
|
||||||
stbUser.setOperation(OperationType.INSERT);
|
stbUser.setOperation(OperationType.INSERT);
|
||||||
stbUser.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
|
stbUser.manageWithParentConnection(connection, droolsDataCompleting);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
|
|||||||
"SET flag_default_contabilita = 'S', flag_default = 'N' " +
|
"SET flag_default_contabilita = 'S', flag_default = 'N' " +
|
||||||
"WHERE flag_default = 'S'";
|
"WHERE flag_default = 'S'";
|
||||||
|
|
||||||
PreparedStatement updateDefaultFlagPS = advancedDataSource.getConnection().prepareStatement(updateDefaultFlagSql);
|
PreparedStatement updateDefaultFlagPS = connection.prepareStatement(updateDefaultFlagSql);
|
||||||
updateDefaultFlagPS.setQueryTimeout(30);
|
updateDefaultFlagPS.setQueryTimeout(30);
|
||||||
updateDefaultFlagPS.executeUpdate();
|
updateDefaultFlagPS.executeUpdate();
|
||||||
updateDefaultFlagPS.close();
|
updateDefaultFlagPS.close();
|
||||||
@@ -38,13 +38,13 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
|
|||||||
" FROM " + StbEmail.ENTITY +
|
" FROM " + StbEmail.ENTITY +
|
||||||
" WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
|
" WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
|
||||||
|
|
||||||
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
boolean isOffice365 = mailConfiguration.getSmtp().contains("office365");
|
boolean isOffice365 = mailConfiguration.getSmtp().contains("office365");
|
||||||
|
|
||||||
int newId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(),
|
int newId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection,
|
||||||
"SELECT ISNULL(MAX(id_riga), 0) + 1 as new_id " +
|
"SELECT ISNULL(MAX(id_riga), 0) + 1 as new_id " +
|
||||||
"FROM stb_email");
|
"FROM stb_email");
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
|
|||||||
.setFlagDefault(isOffice365 ? "S" : "N");
|
.setFlagDefault(isOffice365 ? "S" : "N");
|
||||||
|
|
||||||
stbEmail.setOperation(OperationType.INSERT);
|
stbEmail.setOperation(OperationType.INSERT);
|
||||||
stbEmail.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
|
stbEmail.manageWithParentConnection(connection, droolsDataCompleting);
|
||||||
|
|
||||||
if (!isOffice365) {
|
if (!isOffice365) {
|
||||||
String noReplyFrom = "noreply@" + mailConfiguration.getFrom().split("@")[1];
|
String noReplyFrom = "noreply@" + mailConfiguration.getFrom().split("@")[1];
|
||||||
@@ -79,14 +79,14 @@ public class Migration_20220415094936 extends BaseMigration implements Migration
|
|||||||
.setFlagDefault("S");
|
.setFlagDefault("S");
|
||||||
|
|
||||||
stbEmailNoReply.setOperation(OperationType.INSERT);
|
stbEmailNoReply.setOperation(OperationType.INSERT);
|
||||||
stbEmailNoReply.manageWithParentConnection(advancedDataSource.getConnection(), droolsDataCompleting);
|
stbEmailNoReply.manageWithParentConnection(connection, droolsDataCompleting);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateDefaultFlagSql = "UPDATE stb_email " +
|
updateDefaultFlagSql = "UPDATE stb_email " +
|
||||||
"SET flag_default = 'S' " +
|
"SET flag_default = 'S' " +
|
||||||
"WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
|
"WHERE e_mail = " + UtilityDB.valueToString(mailConfiguration.getFrom());
|
||||||
|
|
||||||
updateDefaultFlagPS = advancedDataSource.getConnection().prepareStatement(updateDefaultFlagSql);
|
updateDefaultFlagPS = connection.prepareStatement(updateDefaultFlagSql);
|
||||||
updateDefaultFlagPS.setQueryTimeout(30);
|
updateDefaultFlagPS.setQueryTimeout(30);
|
||||||
updateDefaultFlagPS.executeUpdate();
|
updateDefaultFlagPS.executeUpdate();
|
||||||
updateDefaultFlagPS.close();
|
updateDefaultFlagPS.close();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package it.integry.ems.migration.model;
|
|||||||
import it.integry.ems.migration._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.service.PrinterService;
|
import it.integry.ems.service.PrinterService;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||||
import it.integry.ems_model.entity.MtbDepo;
|
import it.integry.ems_model.entity.MtbDepo;
|
||||||
import it.integry.ems_model.entity.WtbJrept;
|
import it.integry.ems_model.entity.WtbJrept;
|
||||||
@@ -14,8 +15,6 @@ import it.integry.ems_model.utility.UtilityString;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
|
||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,15 +29,15 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
|
|||||||
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
|
String checkTableSpesExistsSql = "SELECT CAST(COUNT(*) AS BIT) AS exist_table " +
|
||||||
"FROM INFORMATION_SCHEMA.TABLES " +
|
"FROM INFORMATION_SCHEMA.TABLES " +
|
||||||
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
|
"WHERE TABLE_NAME = 'wtb_jrept_setup'";
|
||||||
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
|
boolean existTable = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
|
||||||
|
|
||||||
if (existTable) {
|
if (existTable) {
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute("drop table wtb_jrept_setup");
|
statement.execute("drop table wtb_jrept_setup");
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute("create table wtb_jrept_setup\n" +
|
statement.execute("create table wtb_jrept_setup\n" +
|
||||||
"(\n" +
|
"(\n" +
|
||||||
" id bigint identity\n" +
|
" id bigint identity\n" +
|
||||||
@@ -60,7 +59,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
|
|||||||
")");
|
")");
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|
||||||
statement = advancedDataSource.getConnection().createStatement();
|
statement = connection.createStatement();
|
||||||
statement.execute("create unique index wtb_jrept_setup_cod_mdep_tipo_cod_anag_uindex" +
|
statement.execute("create unique index wtb_jrept_setup_cod_mdep_tipo_cod_anag_uindex" +
|
||||||
" on wtb_jrept_setup (cod_mdep, tipo, cod_anag)");
|
" on wtb_jrept_setup (cod_mdep, tipo, cod_anag)");
|
||||||
statement.close();
|
statement.close();
|
||||||
@@ -68,17 +67,17 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
|
|||||||
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
|
ArrayList<WtbJreptSetup> jreptSetupsToInsert = new ArrayList<>();
|
||||||
|
|
||||||
String sqlAnagJrept = "SELECT * FROM " + GrlAnagJrept.ENTITY + " ";
|
String sqlAnagJrept = "SELECT * FROM " + GrlAnagJrept.ENTITY + " ";
|
||||||
List<GrlAnagJrept> anagJrepts = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sqlAnagJrept, GrlAnagJrept.class);
|
List<GrlAnagJrept> anagJrepts = UtilityDB.executeSimpleQueryDTO(connection, sqlAnagJrept, GrlAnagJrept.class);
|
||||||
|
|
||||||
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
|
String sqlDepo = "SELECT cod_mdep FROM " + MtbDepo.ENTITY;
|
||||||
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(advancedDataSource.getConnection(), sqlDepo);
|
List<String> codMdeps = UtilityDB.executeSimpleQueryOnlyFirstColumn(connection, sqlDepo);
|
||||||
|
|
||||||
if (anagJrepts != null && !anagJrepts.isEmpty()) {
|
if (anagJrepts != null && !anagJrepts.isEmpty()) {
|
||||||
|
|
||||||
for (GrlAnagJrept anagReport : anagJrepts) {
|
for (GrlAnagJrept anagReport : anagJrepts) {
|
||||||
|
|
||||||
String sqlOrientationReport = "SELECT orientation FROM " + WtbJrept.ENTITY + " where id = " + UtilityDB.valueToString(anagReport.getReportId());
|
String sqlOrientationReport = "SELECT orientation FROM " + WtbJrept.ENTITY + " where id = " + UtilityDB.valueToString(anagReport.getReportId());
|
||||||
int orientation = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sqlOrientationReport);
|
int orientation = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sqlOrientationReport);
|
||||||
|
|
||||||
WtbJreptSetup wtbJreptSetup = new WtbJreptSetup()
|
WtbJreptSetup wtbJreptSetup = new WtbJreptSetup()
|
||||||
.setCodMdep(null)
|
.setCodMdep(null)
|
||||||
@@ -92,7 +91,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
if (codMdeps != null && !codMdeps.isEmpty()) {
|
if (codMdeps != null && !codMdeps.isEmpty()) {
|
||||||
for (String codMdep : codMdeps) {
|
for (String codMdep : codMdeps) {
|
||||||
String stampantePrimaria = getPrinterNameByDepo(advancedDataSource.getConnection(), codMdep, null, PrinterService.Type.PRIMARIA);
|
String stampantePrimaria = getPrinterNameByDepo(connection, codMdep, null, PrinterService.Type.PRIMARIA);
|
||||||
if (!UtilityString.isNullOrEmpty(stampantePrimaria)) {
|
if (!UtilityString.isNullOrEmpty(stampantePrimaria)) {
|
||||||
|
|
||||||
WtbJreptSetup wtbJreptSetupDepo = new WtbJreptSetup()
|
WtbJreptSetup wtbJreptSetupDepo = new WtbJreptSetup()
|
||||||
@@ -116,7 +115,7 @@ public class Migration_20220421125860 extends BaseMigration implements Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
|
for (WtbJreptSetup wtbJreptSetup : jreptSetupsToInsert) {
|
||||||
wtbJreptSetup.manageWithParentConnection(advancedDataSource.getConnection());
|
wtbJreptSetup.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ public class Migration_20220510103554 extends BaseMigration implements Migration
|
|||||||
"FROM sys.columns " +
|
"FROM sys.columns " +
|
||||||
"WHERE Name = N'ref_uuid' " +
|
"WHERE Name = N'ref_uuid' " +
|
||||||
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
|
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
|
||||||
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
|
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
|
||||||
|
|
||||||
if (existColumn) {
|
if (existColumn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute("ALTER TABLE stb_activity_file " +
|
statement.execute("ALTER TABLE stb_activity_file " +
|
||||||
"ADD ref_uuid VARCHAR(36) NULL");
|
"ADD ref_uuid VARCHAR(36) NULL");
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ public class Migration_20220510123355 extends BaseMigration implements Migration
|
|||||||
"FROM sys.columns " +
|
"FROM sys.columns " +
|
||||||
"WHERE Name = N'ref_uuid1' " +
|
"WHERE Name = N'ref_uuid1' " +
|
||||||
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
|
"AND Object_ID = Object_ID(N'dbo.stb_activity_file')";
|
||||||
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), checkTableSpesExistsSql);
|
boolean existColumn = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, checkTableSpesExistsSql);
|
||||||
|
|
||||||
if (existColumn) {
|
if (existColumn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.execute("ALTER TABLE stb_activity_file " +
|
statement.execute("ALTER TABLE stb_activity_file " +
|
||||||
"ADD ref_uuid1 VARCHAR(36) NULL");
|
"ADD ref_uuid1 VARCHAR(36) NULL");
|
||||||
statement.close();
|
statement.close();
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ public class Migration_20221128123233 extends BaseMigration implements Migration
|
|||||||
"ALTER TABLE azienda\n" +
|
"ALTER TABLE azienda\n" +
|
||||||
" ADD jwt_secret_key VARCHAR(MAX)");
|
" ADD jwt_secret_key VARCHAR(MAX)");
|
||||||
|
|
||||||
Azienda azienda = Azienda.getDefaultAzienda(advancedDataSource.getConnection());
|
Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||||
azienda.setJwtSecretKey(secretKeyToUse)
|
azienda.setJwtSecretKey(secretKeyToUse)
|
||||||
.setOperation(OperationType.UPDATE);
|
.setOperation(OperationType.UPDATE);
|
||||||
|
|
||||||
azienda.manageWithParentConnection(advancedDataSource.getConnection());
|
azienda.manageWithParentConnection(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ public class Migration_20230411163906 extends BaseMigration implements Migration
|
|||||||
"ALTER TABLE stb_files_attached\n" +
|
"ALTER TABLE stb_files_attached\n" +
|
||||||
" ADD mime_type VARCHAR(MAX)");
|
" ADD mime_type VARCHAR(MAX)");
|
||||||
|
|
||||||
final List<HashMap<String, Object>> stbFilesAttached = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(),
|
final List<HashMap<String, Object>> stbFilesAttached = UtilityDB.executeSimpleQuery(connection,
|
||||||
"SELECT id_attach, file_name FROM stb_files_attached\n" +
|
"SELECT id_attach, file_name FROM stb_files_attached\n" +
|
||||||
"WHERE mime_type IS NULL");
|
"WHERE mime_type IS NULL");
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
String profileDb = advancedDataSource.getProfileName();
|
String profileDb = connection.getProfileName();
|
||||||
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDb, false)) {
|
try (MultiDBTransactionManager mdb = new MultiDBTransactionManager(profileDb, false)) {
|
||||||
for (HashMap<String, Object> stbFileAttached : stbFilesAttached) {
|
for (HashMap<String, Object> stbFileAttached : stbFilesAttached) {
|
||||||
final MediaType mimeType = mimeTypesHandler.getContentType((String) stbFileAttached.get("file_name"));
|
final MediaType mimeType = mimeTypesHandler.getContentType((String) stbFileAttached.get("file_name"));
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Migration_20230523130047 extends BaseMigration implements Migration
|
|||||||
.setIndexName("ix_dtb_ordr_id_contratto")
|
.setIndexName("ix_dtb_ordr_id_contratto")
|
||||||
.setColumnsIndex(columnsIndex)/*
|
.setColumnsIndex(columnsIndex)/*
|
||||||
.setColumnsInclude("ciao", "prova", "sole") */;
|
.setColumnsInclude("ciao", "prova", "sole") */;
|
||||||
UtilityDB.createIndex(advancedDataSource.getConnection(),indexTableDTO );
|
UtilityDB.createIndex(connection,indexTableDTO );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user