Compare commits
456 Commits
20240110_1
...
feature/SD
| Author | SHA1 | Date | |
|---|---|---|---|
| 21347036cc | |||
| 67170a87ca | |||
| cd042fc248 | |||
| 31f2195acb | |||
| 1b8b6f6304 | |||
| 7ab4f8a55f | |||
| 879fcb9d56 | |||
| ab761d0ac9 | |||
| b35d51f0ad | |||
| eb0b047994 | |||
| ac71a4a92a | |||
| 29677501e8 | |||
| 3821c88000 | |||
| fc52433878 | |||
| efdd30a8dd | |||
| a5ef9aebee | |||
| 900c00e6c2 | |||
| 0f3261185a | |||
| ed5817d6e2 | |||
| 2578efc638 | |||
| 0428bb9680 | |||
| 3aeb112f10 | |||
| 1f3caadc14 | |||
| 388ff5c36e | |||
| 7d7d0b508a | |||
| b0b4cc6298 | |||
| 30ddd694d1 | |||
| 7eecf7591f | |||
| ad035e63ad | |||
| 9e1e670faf | |||
| 5a0a5491cf | |||
| f85fce7127 | |||
| ec1f3939d6 | |||
| d086a88214 | |||
| 50ba382f6d | |||
| 36074a3765 | |||
| 4c490e21af | |||
| 2963c7b592 | |||
| e320f90a1a | |||
| f61df8763c | |||
| a275167a4b | |||
| 09cd7ba414 | |||
| 3ffa635387 | |||
| db8395fdd5 | |||
| 15041e3b44 | |||
| 5104bdb53f | |||
| 42858e0c30 | |||
| 10f6702573 | |||
| 3243008219 | |||
| 6b7d2057d7 | |||
| 60e43da598 | |||
| dae5d4cf21 | |||
| b7083541e8 | |||
| a26a2ee44f | |||
| a4b297dc9d | |||
| a2f169101b | |||
| eb1043eb3b | |||
| a62f804c25 | |||
| 60f9578a14 | |||
| 11bc54df6e | |||
| 831434267d | |||
| a554141182 | |||
| d5a9070a7f | |||
| 90e5874ba4 | |||
| 9e47404c91 | |||
| d4a1c85390 | |||
| 696d4a2f4b | |||
| cf3235b176 | |||
| ba198c9d2f | |||
| 574f747618 | |||
| 09ffd4090f | |||
| 50b1f43818 | |||
| aab7560ecb | |||
| 29c28367d1 | |||
| 8035b2c5c1 | |||
| bfbc459393 | |||
| a2d536d6d5 | |||
| 507aa7cd0d | |||
| 4af91e8c8d | |||
| 8f7215a57c | |||
| a71cf5517b | |||
| 5292edfd78 | |||
| f3e0ad8f60 | |||
| 26b17202df | |||
| 17b975a4fe | |||
| a94bb34c54 | |||
| 66dd299d09 | |||
| 8d2dfbf178 | |||
| bc6cd67e81 | |||
| 7ba6771112 | |||
| 4cac7be4cc | |||
| 14ce9cefc8 | |||
| 6fab1e8db5 | |||
| 7e2c4256f2 | |||
| 8c33b02dae | |||
| bc2f063ed8 | |||
| 1dc94e60a2 | |||
| f4eb510770 | |||
| c34b15aeae | |||
| 19ac975f14 | |||
| 074f939559 | |||
| d702d208ab | |||
| bbf199f6c7 | |||
| 4182ef790e | |||
| f01887dd50 | |||
| 0ca1bb46d3 | |||
| d2cfd915a4 | |||
| 64bfafbcf1 | |||
| 8e615a3ee9 | |||
| de6d9a82b7 | |||
| 9b5abfcdd4 | |||
| 857b6a150a | |||
| ffa4ded1fe | |||
| 7709c11636 | |||
| 06f8d99688 | |||
| 863d808914 | |||
| 11307be692 | |||
| 0ad90cf961 | |||
| d5c285fa45 | |||
| 8c5eba3031 | |||
| 0efbc8ba16 | |||
| 063ab02a28 | |||
| 80a65dbcb3 | |||
| cdaa89749b | |||
| edda17080d | |||
| 0871c50ceb | |||
| 3771891886 | |||
| 3aae8b5d24 | |||
| 4b17566d15 | |||
| 6128d3756c | |||
| 91bb735fb1 | |||
| 9f1489a9c8 | |||
| 02ac9d1559 | |||
| 2d6f27d8a6 | |||
| 8d143fa2ab | |||
| cc6f8dfa52 | |||
| 80333cc27e | |||
| d4883a25e7 | |||
| 504d5c8171 | |||
| ac3c048e7a | |||
| 8c2e407c10 | |||
| bb159584f0 | |||
| 3b269da398 | |||
| 94b44a723e | |||
| 7acd898115 | |||
| c751d70663 | |||
| 167feef6be | |||
| 7c7be3a89c | |||
| 1bf6f776e9 | |||
| 83acc13fe9 | |||
| 7b727538e7 | |||
| 5252a0d522 | |||
| 27cdb94dff | |||
| bd64c14e7c | |||
| d095e2c1b1 | |||
| 330a977e77 | |||
| e8df520abd | |||
| cdc9b35ccd | |||
| 0cb3aee12e | |||
| 75446207a5 | |||
| 75d1671e7b | |||
| 9a390dd6f1 | |||
| f225211ffd | |||
| d07f6ceeb2 | |||
| 65d1221fb6 | |||
| 56721f4730 | |||
| 42f5b96acb | |||
| 30374c6e98 | |||
| 0a13ab43d0 | |||
| 8b8486b3f2 | |||
| 9062f0b4f6 | |||
| a7c87523c9 | |||
| c609fd74eb | |||
| 8cfe60ae30 | |||
| 6a225715cb | |||
| f136e6b6bd | |||
| 0910a8ab50 | |||
| 407d9231e3 | |||
| 6e55d3f4af | |||
| dbb0f7c4a8 | |||
| be8dc47a94 | |||
| 71d4011d09 | |||
| 56e880e3c6 | |||
| c09af099da | |||
| 49ad5aed67 | |||
| 31d5b67ddf | |||
| baa0ddffd0 | |||
| 5d23629723 | |||
| e5a9e50742 | |||
| 77531c46e0 | |||
| ab2a1c07e1 | |||
| 9866736f04 | |||
| 7f1d091a6c | |||
| 27ef594142 | |||
| b8612733d5 | |||
| 3b0103c0f4 | |||
| 26a2646523 | |||
| 2966234133 | |||
| 5932496c97 | |||
| 501f270c86 | |||
| 21f34fd7ee | |||
| d1c131dc55 | |||
| 0b3fba112b | |||
| b36a2cff5b | |||
| dc5abf30a0 | |||
| b14b9be0aa | |||
| 2c41e6cbe7 | |||
| 3283f856ec | |||
| f1da0aeccd | |||
| 9dbfc8579b | |||
| d6aca23687 | |||
| 507498e6a7 | |||
| f1f7e8c276 | |||
| 7308e1e3e3 | |||
| 8d52017e07 | |||
| dea7babe92 | |||
| 97a6acb826 | |||
| ae03d4f5f4 | |||
| 686fea9daf | |||
| 962d3d6682 | |||
| 88287d95cb | |||
| 3406bd91b3 | |||
| c6d9ee4432 | |||
| e94198c242 | |||
| 3644be526d | |||
| 9a9142ad92 | |||
| 4e648347a5 | |||
| b84c488de0 | |||
| 3a2a8f3d4b | |||
| cf91030464 | |||
| 8d2186bfe9 | |||
| 78ed2a8da9 | |||
| 86bc5905d6 | |||
| b74d7baf84 | |||
| f0fb79b5e0 | |||
| 4b34d8a512 | |||
| 252faa7221 | |||
| 0534ddeb3e | |||
| 977c2bc050 | |||
| df46ac1e93 | |||
| eea5f9cb8b | |||
| 053641ee1d | |||
| dbf8a970f3 | |||
| 3c10bb06d5 | |||
| b698487227 | |||
| 138ee04105 | |||
| bddd9f6e4b | |||
| c608946385 | |||
| d7d862f5c4 | |||
| a01b40ee07 | |||
| 4bc56f30dc | |||
| 23e256481b | |||
| a131410b91 | |||
| 934c15fa24 | |||
| 651f263b12 | |||
| 1b31a31f50 | |||
| d39c64e680 | |||
| c554738b14 | |||
| 2cad617ea9 | |||
| aad34b04e3 | |||
| 781e884ef4 | |||
| 6006d52f51 | |||
| 26c694dc97 | |||
| b29ed540fd | |||
| c4f60a495e | |||
| 228f69062b | |||
| 39a97a0e0c | |||
| 83318b3b52 | |||
| b18e445da1 | |||
| 74fbed2a02 | |||
| 023466d7c5 | |||
| 0f4410c931 | |||
| 585e5dcc44 | |||
| 15f8a6c254 | |||
| 9f9165c780 | |||
| 11d24fe5c9 | |||
| fe2609948b | |||
| a71ab685dd | |||
| 39c00651f8 | |||
| 41916d467b | |||
| a87811e3ef | |||
| f996b8c5bf | |||
| f322436c10 | |||
| 10a6b85861 | |||
| 0d490fd292 | |||
| a6e33cc38d | |||
| fe517df4ac | |||
| a444b113cb | |||
| 8e4b3a629e | |||
| 17b62a0623 | |||
| 2c09bb9267 | |||
| b4f9984511 | |||
| c73717e484 | |||
| 6ed20a30bc | |||
| c41c7bad02 | |||
| 7e27c8a705 | |||
| 4e2ce393d9 | |||
| ea3ffb2d89 | |||
| c04ddaaf3f | |||
| 40c1127538 | |||
| 7d357f9c12 | |||
| 10fff183b9 | |||
| 6f19ca07e3 | |||
| 0d0ae9ae96 | |||
| 5fad721677 | |||
| 87ea42be73 | |||
| a1c993bbe9 | |||
| 0f5bed2fef | |||
| 1c142f1731 | |||
| 06e2b4b96e | |||
| 6c062cb81c | |||
| 30337ae0fb | |||
| cc02400682 | |||
| 5a7cf6688c | |||
| bbb1720f48 | |||
| 52351ed12b | |||
| 824d846f46 | |||
| 308841b0af | |||
| 1b857636ba | |||
| 02afe2d3bf | |||
| 92e7329b57 | |||
| 764ce217cf | |||
| 56ea796597 | |||
| 47f8592e49 | |||
| 775be4ecb7 | |||
| 38b4f4d77a | |||
| aa7839bd6a | |||
| 18eba28492 | |||
| 2383dcd243 | |||
| 02b912b25d | |||
| b2d713d18b | |||
| e75d9d61e3 | |||
| 9f2b70f03c | |||
| 1278a72523 | |||
| 394567b5ba | |||
| ee1a22fcce | |||
| 265de6ffd2 | |||
| f363269313 | |||
| 4cc3732e30 | |||
| 42237f463f | |||
| 531fc74fe5 | |||
| 3e46a37d80 | |||
| 81b312e14b | |||
| 06f3249125 | |||
| cc8f17cad5 | |||
| 5ce51e6689 | |||
| 3a6556cce2 | |||
| 48b7621291 | |||
| fa7c172fe5 | |||
| 45cd5bd53b | |||
| 60df9f8a7d | |||
| ffee3197e2 | |||
| 1242f95270 | |||
| b1bd3ac5ad | |||
| c0dc4afd3b | |||
| 01ad4b1d12 | |||
| 2553b1bd85 | |||
| f12428ae62 | |||
| c14f99fc3a | |||
| e1b4c2be78 | |||
| 20822a5755 | |||
| 46e38b8847 | |||
| 0d923a10d1 | |||
| c967a9f7d3 | |||
| 3e966fd10f | |||
| 0a5733fc4d | |||
| bcd2253cd4 | |||
| 3e65f2f08b | |||
| cb943e9cb1 | |||
| 96a1e3ce54 | |||
| d71d3d7283 | |||
| ca35777f31 | |||
| 724c69c6c5 | |||
| 838482171f | |||
| cd21ef103d | |||
| 176bfe8c50 | |||
| 16e0216aa1 | |||
| 9569bdcf34 | |||
| 940665018a | |||
| cb0aa3f1c1 | |||
| 092eb14b02 | |||
| cc61eead9b | |||
| 652503ea51 | |||
| bb44596809 | |||
| a7e0b0c9f9 | |||
| df78b0022d | |||
| 145f37f420 | |||
| 3426b04241 | |||
| 36b01e40d3 | |||
| f39736eb00 | |||
| 698ac9dfa5 | |||
| 50e45b233f | |||
| c8d99b4f38 | |||
| da3be37041 | |||
| f0e5beac2e | |||
| 7c6a187505 | |||
| 5b95feba1b | |||
| 8f799ae10e | |||
| 3a5a1d1aad | |||
| 1fe5fa5b1a | |||
| 04be79d70a | |||
| 955765bffa | |||
| 98c54be2da | |||
| db279a1da4 | |||
| 17415db1bc | |||
| 5b65a2b204 | |||
| f1f1a2ebe2 | |||
| 0beaa44958 | |||
| 4f0f181b47 | |||
| 456e3f1bbb | |||
| 5f1826ec4b | |||
| bdd6df144f | |||
| e7e2289b23 | |||
| 9f93be2804 | |||
| b658426912 | |||
| 263dafd635 | |||
| d6666dff10 | |||
| b7c214fee2 | |||
| 29ebded325 | |||
| 91a61f336a | |||
| a6ec10d35b | |||
| 59a06e67cd | |||
| 245d55322a | |||
| 3d423f3f27 | |||
| c59782c463 | |||
| 883368d3d6 | |||
| 467a763502 | |||
| 3b8fbd02dd | |||
| acbf5b7221 | |||
| 00ad753956 | |||
| 30afb1fdf1 | |||
| 33f70b3ad2 | |||
| 21a95b258a | |||
| 67f36bbab1 | |||
| bba44b68e6 | |||
| 224cf2a2b6 | |||
| 7c0e79175a | |||
| d0b3c9f968 | |||
| 1601ce19b3 | |||
| 8c6ae1c266 | |||
| 48c3c4a903 | |||
| f8dde6c77c | |||
| 5df3775791 | |||
| d7d98b7bba | |||
| bb72cc493a | |||
| 3914314291 | |||
| e9f7755d97 | |||
| 317240bb9c | |||
| 0cdcb37d0a | |||
| 307d01daca | |||
| 1f6d125bb2 | |||
| 2bfa582a82 | |||
| 31cbcd2c44 | |||
| 5a5ce4df96 | |||
| df9df5a21f | |||
| 0625723dfc |
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -135,10 +135,13 @@ ems-contabil/src/main/java/it/integry/ems/contabil/service/ContabilService.java
|
|||||||
ems-contabil/src/main/java/it/integry/ems/contabil/service/DistinteIncassiDTO.java -text
|
ems-contabil/src/main/java/it/integry/ems/contabil/service/DistinteIncassiDTO.java -text
|
||||||
ems-contabil/src/main/java/it/integry/ems/contabil/type/ContabilImportFormat.java -text
|
ems-contabil/src/main/java/it/integry/ems/contabil/type/ContabilImportFormat.java -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.00.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIBdyPaymentRequest.00.04.01.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIHdrSrv.001.07.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIHdrSrv.001.07.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIHdrTrt.001.07.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIHdrTrt.001.07.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.00.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.00.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.00.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequest.00.04.01.xsd -text
|
||||||
|
ems-contabil/src/main/resources/sepa/xsd/CBIPaymentRequestMsg.00.04.01.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/CBISgnInf.001.04.xsd -text
|
ems-contabil/src/main/resources/sepa/xsd/CBISgnInf.001.04.xsd -text
|
||||||
ems-contabil/src/main/resources/sepa/xsd/binding.jxb -text
|
ems-contabil/src/main/resources/sepa/xsd/binding.jxb -text
|
||||||
ems-contabil/target/classes/it/integry/ems/contabil/it.integry.core.controller/ContabilController.class -text
|
ems-contabil/target/classes/it/integry/ems/contabil/it.integry.core.controller/ContabilController.class -text
|
||||||
|
|||||||
@@ -108,6 +108,9 @@
|
|||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.4" />
|
||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.4" />
|
||||||
<element id="library" level="project" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.9.4" />
|
<element id="library" level="project" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.9.4" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba:fastjson:2.0.47" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.47" />
|
||||||
|
<element id="library" level="project" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.47" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-aop:4.2.5.RELEASE" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-core:4.2.5.RELEASE" />
|
||||||
<element id="library" level="project" name="Maven: org.springframework:spring-instrument-tomcat:4.2.5.RELEASE" />
|
<element id="library" level="project" name="Maven: org.springframework:spring-instrument-tomcat:4.2.5.RELEASE" />
|
||||||
@@ -254,7 +257,7 @@
|
|||||||
<element id="library" level="project" name="Maven: org.reflections:reflections:0.9.10" />
|
<element id="library" level="project" name="Maven: org.reflections:reflections:0.9.10" />
|
||||||
<element id="library" level="project" name="Maven: org.javassist:javassist:3.19.0-GA" />
|
<element id="library" level="project" name="Maven: org.javassist:javassist:3.19.0-GA" />
|
||||||
<element id="library" level="project" name="Maven: com.google.code.findbugs:annotations:2.0.1" />
|
<element id="library" level="project" name="Maven: com.google.code.findbugs:annotations:2.0.1" />
|
||||||
<element id="library" level="project" name="Maven: com.google.code.gson:gson:2.5" />
|
<element id="library" level="project" name="Maven: com.google.code.gson:gson:2.9.1" />
|
||||||
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" />
|
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" />
|
||||||
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" />
|
<element id="library" level="project" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" />
|
||||||
<element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.3" />
|
<element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.3" />
|
||||||
@@ -549,7 +552,6 @@
|
|||||||
<option value="$PROJECT_DIR$/ems-retail/pom.xml" />
|
<option value="$PROJECT_DIR$/ems-retail/pom.xml" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="PWA">
|
<component name="PWA">
|
||||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||||
@@ -829,6 +831,44 @@
|
|||||||
</option>
|
</option>
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration default="false" name="Tomcat 7 #1 (ServerDev)" 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="serverdev" />
|
||||||
|
<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>
|
||||||
|
<configuration default="false" name="Tomcat 9 #2 (ServerDev)" 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="serverdev" />
|
||||||
|
<option name="PORT" value="8002" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration default="false" name="Tomcat #1 (ServerTomcat)" 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="8000" />
|
||||||
|
<option name="AUTO_RESTART" value="false" />
|
||||||
|
<RunnerSettings RunnerId="Debug">
|
||||||
|
<option name="DEBUG_PORT" value="8000" />
|
||||||
|
<option name="LOCAL" value="false" />
|
||||||
|
</RunnerSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
<configuration default="false" name="Tomcat (FAST)" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat" ALTERNATIVE_JRE_ENABLED="false" ALTERNATIVE_JRE_PATH="1.8" show_console_on_std_err="true" show_console_on_std_out="true">
|
<configuration default="false" name="Tomcat (FAST)" type="#com.intellij.j2ee.web.tomcat.TomcatRunConfigurationFactory" factoryName="Local" APPLICATION_SERVER_NAME="Tomcat" ALTERNATIVE_JRE_ENABLED="false" ALTERNATIVE_JRE_PATH="1.8" show_console_on_std_err="true" show_console_on_std_out="true">
|
||||||
<option name="COMMON_VM_ARGUMENTS" value="-DDISABLE_DROOLS_COMPILE=TRUE -Xms256m -Xmx1024m -XX:PermSize=1024m" />
|
<option name="COMMON_VM_ARGUMENTS" value="-DDISABLE_DROOLS_COMPILE=TRUE -Xms256m -Xmx1024m -XX:PermSize=1024m" />
|
||||||
<deployment>
|
<deployment>
|
||||||
@@ -900,6 +940,21 @@
|
|||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
</SHUTDOWN>
|
</SHUTDOWN>
|
||||||
</ConfigurationWrapper>
|
</ConfigurationWrapper>
|
||||||
|
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="JProfiler">
|
||||||
|
<option name="USE_ENV_VARIABLES" value="true" />
|
||||||
|
<STARTUP>
|
||||||
|
<option name="USE_DEFAULT" value="true" />
|
||||||
|
<option name="SCRIPT" value="" />
|
||||||
|
<option name="VM_PARAMETERS" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
</STARTUP>
|
||||||
|
<SHUTDOWN>
|
||||||
|
<option name="USE_DEFAULT" value="true" />
|
||||||
|
<option name="SCRIPT" value="" />
|
||||||
|
<option name="VM_PARAMETERS" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
</SHUTDOWN>
|
||||||
|
</ConfigurationWrapper>
|
||||||
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Profile">
|
<ConfigurationWrapper VM_VAR="JAVA_OPTS" RunnerId="Profile">
|
||||||
<option name="USE_ENV_VARIABLES" value="true" />
|
<option name="USE_ENV_VARIABLES" value="true" />
|
||||||
<STARTUP>
|
<STARTUP>
|
||||||
@@ -1065,6 +1120,42 @@
|
|||||||
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
|
<library name="Maven: com.alibaba.fastjson2:fastjson2-extension:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba.fastjson2" artifactId="fastjson2-extension" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2-extension/2.0.47/fastjson2-extension-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
<library name="Maven: com.alibaba.fastjson2:fastjson2:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba.fastjson2" artifactId="fastjson2" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson2/fastjson2/2.0.47/fastjson2-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
<library name="Maven: com.alibaba:fastjson:2.0.47" type="java-imported" external-system-id="Maven">
|
||||||
|
<properties groupId="com.alibaba" artifactId="fastjson" version="2.0.47" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/2.0.47/fastjson-2.0.47-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
<library name="Maven: com.amazonservices.mws:MWSClientJavaRuntime:1.1" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.amazonservices.mws:MWSClientJavaRuntime:1.1" type="java-imported" external-system-id="Maven">
|
||||||
<properties groupId="com.amazonservices.mws" artifactId="MWSClientJavaRuntime" version="1.1" />
|
<properties groupId="com.amazonservices.mws" artifactId="MWSClientJavaRuntime" version="1.1" />
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
@@ -1449,16 +1540,16 @@
|
|||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
<library name="Maven: com.google.code.gson:gson:2.5" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.google.code.gson:gson:2.9.1" type="java-imported" external-system-id="Maven">
|
||||||
<properties groupId="com.google.code.gson" artifactId="gson" version="2.5" />
|
<properties groupId="com.google.code.gson" artifactId="gson" version="2.9.1" />
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC>
|
<JAVADOC>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1-javadoc.jar!/" />
|
||||||
</JAVADOC>
|
</JAVADOC>
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.5/gson-2.5-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.9.1/gson-2.9.1-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
<library name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" type="java-imported" external-system-id="Maven">
|
<library name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" type="java-imported" external-system-id="Maven">
|
||||||
|
|||||||
@@ -83,6 +83,9 @@
|
|||||||
<classes>
|
<classes>
|
||||||
<class>it.integry.ems.response.ServiceRestResponse</class>
|
<class>it.integry.ems.response.ServiceRestResponse</class>
|
||||||
</classes>
|
</classes>
|
||||||
|
<excludeClasses>
|
||||||
|
<excludeClass>it.integry.ems_model.base.EntityInterface</excludeClass>
|
||||||
|
</excludeClasses>
|
||||||
<outputFile>../ts/ems-core.module.ts</outputFile>
|
<outputFile>../ts/ems-core.module.ts</outputFile>
|
||||||
<outputKind>module</outputKind>
|
<outputKind>module</outputKind>
|
||||||
<outputFileType>implementationFile</outputFileType>
|
<outputFileType>implementationFile</outputFileType>
|
||||||
@@ -434,6 +437,12 @@
|
|||||||
<version>${jackson.version}</version>
|
<version>${jackson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>2.0.47</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public class WooCommerceArticoliDataManager {
|
|||||||
" where cod_mdep = dbo.getGestSetup('WOOCOMMERCE','SETUP','COD_MDEP')";
|
" where cod_mdep = dbo.getGestSetup('WOOCOMMERCE','SETUP','COD_MDEP')";
|
||||||
|
|
||||||
if (codMarts != null && codMarts.size() > 0) {
|
if (codMarts != null && codMarts.size() > 0) {
|
||||||
sql += " AND lisv.cod_mart IN (" + UtilityQuery.concatFieldsWithSeparator(codMarts, ",") + ")";
|
sql += " AND lisv.cod_mart IN (" + UtilityQuery.concatStringFieldsWithSeparator(codMarts, ",") + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement info = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
PreparedStatement info = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public class CommonConstants {
|
|||||||
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.TIME_FORMAT)
|
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.TIME_FORMAT)
|
||||||
.withZone(ZoneId.systemDefault());
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
public static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
|
||||||
|
.withZone(ZoneId.systemDefault());
|
||||||
|
|
||||||
|
public static final DateTimeFormatter DATESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd")
|
||||||
|
.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());
|
||||||
|
|||||||
@@ -37,17 +37,10 @@ public class BooleanDeserializer extends JsonDeserializer<Boolean> {
|
|||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ("N".equalsIgnoreCase(text) || text.length() == 0) {
|
|
||||||
// return Boolean.FALSE;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if ("Y".equalsIgnoreCase(text)) {
|
|
||||||
// return Boolean.TRUE;
|
|
||||||
// }
|
|
||||||
throw ctxt.weirdStringException("", _valueClass, "only \"true\" or \"false\" recognized");
|
throw ctxt.weirdStringException("", _valueClass, "only \"true\" or \"false\" recognized");
|
||||||
}
|
}
|
||||||
// Otherwise, no can do:
|
// Otherwise, no can do:
|
||||||
throw ctxt.mappingException(_valueClass);
|
throw ctxt.instantiationException(_valueClass, "error");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
package it.integry.ems.async.controller;
|
|
||||||
|
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems.async.service.AsyncServiceNew;
|
|
||||||
import it.integry.ems.controller.EmsController;
|
|
||||||
import it.integry.ems.response.EsitoType;
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.response.StatusResponse;
|
|
||||||
import it.integry.ems.status.ServiceChecker;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
|
||||||
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;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@Scope("request")
|
|
||||||
@RequestMapping(EmsRestConstants.PATH_ASYNC_BASE_ROUTE)
|
|
||||||
public class AsyncControllerNew {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ServiceChecker serviceChecker;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AsyncServiceNew asyncServiceNew;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/status", method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
List<StatusResponse> status(HttpServletRequest request) {
|
|
||||||
Method[] methods = EmsController.class.getDeclaredMethods();
|
|
||||||
return serviceChecker.getServiceStatus(methods, EmsController.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_START, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse start(
|
|
||||||
HttpServletRequest request,
|
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
|
||||||
@RequestParam String subscriptionName
|
|
||||||
) {
|
|
||||||
ServiceRestResponse response;
|
|
||||||
|
|
||||||
try {
|
|
||||||
asyncServiceNew.startSync(subscriptionName);
|
|
||||||
response = ServiceRestResponse.createPositiveResponse();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error(ex);
|
|
||||||
response = new ServiceRestResponse(EsitoType.KO, configuration, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_RETRIEVE_TRANSACTIONS, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse retrieveTransactions(
|
|
||||||
HttpServletRequest request,
|
|
||||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
|
||||||
@RequestParam(value = "limit", required = false, defaultValue = "1") Integer limit
|
|
||||||
) {
|
|
||||||
|
|
||||||
ServiceRestResponse response;
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = ServiceRestResponse.createPositiveResponse(asyncServiceNew.retrieveTransactions(limit));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error(ex);
|
|
||||||
response = new ServiceRestResponse(EsitoType.KO, configuration, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = EmsRestConstants.PATH_ASYNC_UPDATE_TRANSACTION_IMPORT_ID, method = RequestMethod.GET)
|
|
||||||
public @ResponseBody
|
|
||||||
ServiceRestResponse updateTransactionImportID(HttpServletRequest request,
|
|
||||||
@RequestParam Integer transactionImportID,
|
|
||||||
@RequestParam String sender,
|
|
||||||
@RequestParam String publicationID) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
asyncServiceNew.updateTransactionImportCounterInDB(transactionImportID, publicationID, sender);
|
|
||||||
return ServiceRestResponse.createPositiveResponse();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error(ex);
|
|
||||||
return new ServiceRestResponse(EsitoType.KO, ex.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package it.integry.ems.async.dto;
|
|
||||||
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
|
|
||||||
public class SubscriptionDTO {
|
|
||||||
|
|
||||||
private String publicationId;
|
|
||||||
private int lastTransactionIDImport = 0;
|
|
||||||
private String entityName = null;
|
|
||||||
private String whereCond = null;
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
|
|
||||||
public String getPublicationId() {
|
|
||||||
return publicationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setPublicationId(String publicationId) {
|
|
||||||
this.publicationId = publicationId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastTransactionIDImport() {
|
|
||||||
return lastTransactionIDImport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setLastTransactionIDImport(int lastTransactionIDImport) {
|
|
||||||
this.lastTransactionIDImport = lastTransactionIDImport;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEntityName() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setEntityName(String entityName) {
|
|
||||||
this.entityName = entityName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWhereCond() {
|
|
||||||
return whereCond;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setWhereCond(String whereCond) {
|
|
||||||
this.whereCond = whereCond;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MultiDBTransactionManager getMultiDBTransactionManager() {
|
|
||||||
return multiDBTransactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionDTO setMultiDBTransactionManager(MultiDBTransactionManager multiDBTransactionManager) {
|
|
||||||
this.multiDBTransactionManager = multiDBTransactionManager;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package it.integry.ems.async.dto;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class TransactionDTO {
|
|
||||||
|
|
||||||
public String publicationId;
|
|
||||||
public int transactionId;
|
|
||||||
public Date transactionDate;
|
|
||||||
public String username;
|
|
||||||
public String entityName;
|
|
||||||
public String errorMsg;
|
|
||||||
public String esito;
|
|
||||||
public Date execDate;
|
|
||||||
public String transactionJson;
|
|
||||||
public int transactionGroupId;
|
|
||||||
|
|
||||||
public String getPublicationId() {
|
|
||||||
return publicationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setPublicationId(String publicationId) {
|
|
||||||
this.publicationId = publicationId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTransactionId() {
|
|
||||||
return transactionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setTransactionId(int transactionId) {
|
|
||||||
this.transactionId = transactionId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getTransactionDate() {
|
|
||||||
return transactionDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setTransactionDate(Date transactionDate) {
|
|
||||||
this.transactionDate = transactionDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEntityName() {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setEntityName(String entityName) {
|
|
||||||
this.entityName = entityName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getErrorMsg() {
|
|
||||||
return errorMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setErrorMsg(String errorMsg) {
|
|
||||||
this.errorMsg = errorMsg;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEsito() {
|
|
||||||
return esito;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setEsito(String esito) {
|
|
||||||
this.esito = esito;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getExecDate() {
|
|
||||||
return execDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setExecDate(Date execDate) {
|
|
||||||
this.execDate = execDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTransactionJson() {
|
|
||||||
return transactionJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setTransactionJson(String transactionJson) {
|
|
||||||
this.transactionJson = transactionJson;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTransactionGroupId() {
|
|
||||||
return transactionGroupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionDTO setTransactionGroupId(int transactionGroupId) {
|
|
||||||
this.transactionGroupId = transactionGroupId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,339 +0,0 @@
|
|||||||
package it.integry.ems.async.service;
|
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import it.integry.common.var.CommonConstants;
|
|
||||||
import it.integry.ems.async.dto.SubscriptionDTO;
|
|
||||||
import it.integry.ems.async.dto.TransactionDTO;
|
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
|
||||||
import it.integry.ems.response.EsitoType;
|
|
||||||
import it.integry.ems.response.ServiceRestResponse;
|
|
||||||
import it.integry.ems.service.EntityProcessor;
|
|
||||||
import it.integry.ems.service.HttpRestWrapper;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
import it.integry.ems_model.base.EntityBase;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
|
||||||
import it.integry.ems_model.resolver.EntitySubTypeHolder;
|
|
||||||
import it.integry.ems_model.service.SetupGest;
|
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
import it.integry.ems_model.utility.UtilityHashMap;
|
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.josql.Query;
|
|
||||||
import org.josql.QueryResults;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Scope;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Scope("request")
|
|
||||||
public class AsyncServiceNew {
|
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private JSONObjectMapper jsonObjectMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityProcessor entityProcessor;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RequestDataDTO requestData;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SetupGest setupGest;
|
|
||||||
|
|
||||||
|
|
||||||
public void startSync(String subscriptionName) throws Exception {
|
|
||||||
|
|
||||||
String jsonConfigurationString = setupGest.getSetup(multiDBTransactionManager.getPrimaryConnection(), "SINCRONIZZAZIONI_OFFLINE", "SETUP", subscriptionName);
|
|
||||||
JsonNode jsonConfigurationList = jsonObjectMapper.readTree(jsonConfigurationString);
|
|
||||||
|
|
||||||
for (JsonNode jsonConfig : jsonConfigurationList) {
|
|
||||||
String endpoint = jsonConfig.get("endpoint").asText();
|
|
||||||
String username = jsonConfig.get("username").asText();
|
|
||||||
String profileDb = jsonConfig.get("profileDb").asText();
|
|
||||||
|
|
||||||
|
|
||||||
String wsUrlEndpoint = endpoint + EmsRestConstants.PATH_ASYNC_BASE_ROUTE + EmsRestConstants.PATH_ASYNC_RETRIEVE_TRANSACTIONS;
|
|
||||||
|
|
||||||
HashMap<String, String> queryParams = new HashMap<>();
|
|
||||||
queryParams.put("profileDb", profileDb);
|
|
||||||
|
|
||||||
boolean shouldStop = false;
|
|
||||||
|
|
||||||
int importedTransactionsCounter = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
|
|
||||||
StringBuilder responseBody = new StringBuilder();
|
|
||||||
int status = HttpRestWrapper.callGenericGet(wsUrlEndpoint, username, username, responseBody, queryParams);
|
|
||||||
|
|
||||||
if (status != 200)
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato status code: " + status + "<br />Body: " + responseBody);
|
|
||||||
|
|
||||||
ServiceRestResponse response = jsonObjectMapper.readValue(responseBody.toString(), ServiceRestResponse.class);
|
|
||||||
|
|
||||||
if (response.getEsito() == EsitoType.OK) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
jsonObjectMapper.writeValue(writer, response.getJsonObject());
|
|
||||||
String dtoJson = writer.toString();
|
|
||||||
|
|
||||||
List<List<TransactionDTO>> transactions = jsonObjectMapper.readValue(dtoJson, new TypeReference<List<List<TransactionDTO>>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
if (transactions.size() == 0 || transactions.get(0).size() == 0) {
|
|
||||||
if (importedTransactionsCounter == 0) logger.debug("Nessuna entity da sincronizzare");
|
|
||||||
else logger.debug("Sincronizzazione OFFLINE terminata");
|
|
||||||
shouldStop = true;
|
|
||||||
} else {
|
|
||||||
importedTransactionsCounter += importTransactions(endpoint, profileDb, username, transactions);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato un ESITO KO<br />Body: " + responseBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} while (!shouldStop);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private int importTransactions(@NotNull String hostEndpoint, @NotNull String profileDb, @NotNull String username, @NotNull List<List<TransactionDTO>> transactionList) throws Exception {
|
|
||||||
|
|
||||||
int importedEntityCounter = 0;
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < transactionList.size(); i++) {
|
|
||||||
final List<Integer> transactionsIDGroups = new ArrayList<Integer>();
|
|
||||||
for (int j = 0; j < transactionList.get(i).size(); j++) {
|
|
||||||
if (!transactionsIDGroups.contains(transactionList.get(i).get(j).transactionGroupId))
|
|
||||||
transactionsIDGroups.add(transactionList.get(i).get(j).transactionGroupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Per ogni transaction group trovato mi prendo tutte le transactions
|
|
||||||
for (int j = 0; j < transactionsIDGroups.size(); j++) {
|
|
||||||
final int finalJ = j;
|
|
||||||
List<TransactionDTO> transactionsToImport = Stream.of(transactionList.get(i))
|
|
||||||
.filter(transactionDTO -> transactionDTO.getTransactionGroupId() == transactionsIDGroups.get(finalJ))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
List<EntityBase> entitiesToImport = new ArrayList<EntityBase>();
|
|
||||||
|
|
||||||
for (TransactionDTO transaction : transactionsToImport) {
|
|
||||||
EntityBase entity = jsonObjectMapper.readValue(transaction.transactionJson, EntityBase.class);
|
|
||||||
entitiesToImport.add(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
entityProcessor.processEntityList(null, false, true, false, entitiesToImport);
|
|
||||||
|
|
||||||
for (EntityBase importedEntity : entitiesToImport) {
|
|
||||||
if (importedEntity.getException() != null) {
|
|
||||||
throw importedEntity.getException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
importedEntityCounter += entitiesToImport.size();
|
|
||||||
|
|
||||||
updateTransactionImportCounterInRemote(hostEndpoint, profileDb, username, transactionsToImport);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return importedEntityCounter;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<List<TransactionDTO>> retrieveTransactions(int limit) throws Exception {
|
|
||||||
String username = requestData.getUsername();
|
|
||||||
|
|
||||||
String sqlCheckActiveSubscriptions = "SELECT * " +
|
|
||||||
" FROM stb_subscriptions_user " +
|
|
||||||
" LEFT OUTER JOIN stb_subscriptions_user_detail ssud" +
|
|
||||||
" on stb_subscriptions_user.publication_id = ssud.publication_id and" +
|
|
||||||
" stb_subscriptions_user.user_name = ssud.user_name" +
|
|
||||||
" WHERE stb_subscriptions_user.user_name = " + UtilityDB.valueToString(username) +
|
|
||||||
" AND flag_attivo = 'S'";
|
|
||||||
|
|
||||||
|
|
||||||
List<SubscriptionDTO> activeSubscriptions = new ArrayList<>();
|
|
||||||
|
|
||||||
//Lettura di tutte le sottoscrizioni attive (di tutte le entity)
|
|
||||||
List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sqlCheckActiveSubscriptions);
|
|
||||||
|
|
||||||
if (result.size() > 0) {
|
|
||||||
for (HashMap<String, Object> stringObjectHashMap : result) {
|
|
||||||
activeSubscriptions.add(new SubscriptionDTO()
|
|
||||||
.setPublicationId(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "publication_id"))
|
|
||||||
.setLastTransactionIDImport(UtilityHashMap.<Integer>getValueIfExists(stringObjectHashMap, "last_transaction_id_import"))
|
|
||||||
.setEntityName(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "entity_name"))
|
|
||||||
.setWhereCond(UtilityHashMap.<String>getValueIfExists(stringObjectHashMap, "where_cond_sql")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Estraggo le transazione in base alle sottoscrizioni attive
|
|
||||||
return getTransactionsFromSubscriptions(activeSubscriptions, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<List<TransactionDTO>> getTransactionsFromSubscriptions(List<SubscriptionDTO> subscriptionList, int limit) throws Exception {
|
|
||||||
List<List<TransactionDTO>> groupOfTransactionsToBeExecuted = new ArrayList<>();
|
|
||||||
|
|
||||||
int totalTransactionsCounter = 0;
|
|
||||||
|
|
||||||
for (SubscriptionDTO subscriptionDTO : subscriptionList) {
|
|
||||||
if (totalTransactionsCounter >= limit) break;
|
|
||||||
|
|
||||||
String sqlToRetrieveMaxGroupTransactionId = "SELECT min(transaction_group_id) as min_group, max(transaction_group_id) as max_group " +
|
|
||||||
"FROM stb_transaction_log_db " +
|
|
||||||
"WHERE transaction_id > " + UtilityDB.valueToString(subscriptionDTO.getLastTransactionIDImport()) + " AND " +
|
|
||||||
"entity_name_list = " + UtilityDB.valueToString(subscriptionDTO.getEntityName());
|
|
||||||
|
|
||||||
HashMap<String, Object> transactionGroupsResult = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sqlToRetrieveMaxGroupTransactionId);
|
|
||||||
|
|
||||||
if (transactionGroupsResult == null) continue;
|
|
||||||
|
|
||||||
Integer minTransactionGroupId = UtilityHashMap.getValueIfExists(transactionGroupsResult, "min_group");
|
|
||||||
Integer maxTransactionGroupId = UtilityHashMap.getValueIfExists(transactionGroupsResult, "max_group");
|
|
||||||
|
|
||||||
if (minTransactionGroupId == null || maxTransactionGroupId == null) continue;
|
|
||||||
|
|
||||||
List<TransactionDTO> transactionsToBeProcessed = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = minTransactionGroupId; i <= maxTransactionGroupId; i++) {
|
|
||||||
if (totalTransactionsCounter >= limit) break;
|
|
||||||
|
|
||||||
String sqlToRetrieveTransactions = "SELECT * " +
|
|
||||||
"FROM stb_transaction_log_db " +
|
|
||||||
"WHERE transaction_group_id = " + UtilityDB.valueToString(i) + " AND " +
|
|
||||||
"entity_name_list = " + UtilityDB.valueToString(subscriptionDTO.getEntityName()) + " " +
|
|
||||||
"ORDER BY transaction_id";
|
|
||||||
|
|
||||||
List<HashMap<String, Object>> results = UtilityDB.executeSimpleQuery(multiDBTransactionManager.getPrimaryConnection(), sqlToRetrieveTransactions);
|
|
||||||
|
|
||||||
boolean shouldAdd = true;
|
|
||||||
|
|
||||||
for (HashMap<String, Object> result : results) {
|
|
||||||
TransactionDTO transaction = new TransactionDTO()
|
|
||||||
.setPublicationId(subscriptionDTO.getPublicationId())
|
|
||||||
.setEntityName(UtilityHashMap.<String>getValueIfExists(result, "entity_name_list"))
|
|
||||||
.setErrorMsg(UtilityHashMap.<String>getValueIfExists(result, "error_msg"))
|
|
||||||
.setEsito(UtilityHashMap.<String>getValueIfExists(result, "esito"))
|
|
||||||
.setExecDate(UtilityHashMap.<Date>getValueIfExists(result, "exec_date"))
|
|
||||||
.setTransactionDate(UtilityHashMap.<Date>getValueIfExists(result, "transaction_date"))
|
|
||||||
.setTransactionGroupId(UtilityHashMap.<Integer>getValueIfExists(result, "transaction_group_id"))
|
|
||||||
.setTransactionId(UtilityHashMap.<Integer>getValueIfExists(result, "transaction_id"))
|
|
||||||
.setTransactionJson(UtilityHashMap.<String>getValueIfExists(result, "transaction_json"))
|
|
||||||
.setUsername(UtilityHashMap.<String>getValueIfExists(result, "user_name"));
|
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(subscriptionDTO.getWhereCond())) {
|
|
||||||
Class entityClass = UtilityHashMap.getValueIfExists(EntitySubTypeHolder.getMapType(), subscriptionDTO.getEntityName().toLowerCase());
|
|
||||||
|
|
||||||
EntityBase entity = jsonObjectMapper.readValue(transaction.transactionJson, EntityBase.class);
|
|
||||||
|
|
||||||
List<EntityBase> tmpList = new ArrayList<>();
|
|
||||||
tmpList.add(entity);
|
|
||||||
|
|
||||||
String selectSql = "SELECT * FROM " + entityClass.getCanonicalName() + " WHERE " + subscriptionDTO.getWhereCond();
|
|
||||||
|
|
||||||
// Create a new Query.
|
|
||||||
Query q = new Query();
|
|
||||||
q.parse(selectSql);
|
|
||||||
|
|
||||||
QueryResults qr = q.execute(tmpList);
|
|
||||||
tmpList = qr.getResults();
|
|
||||||
|
|
||||||
if (tmpList.size() == 0) {
|
|
||||||
shouldAdd = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldAdd) {
|
|
||||||
transactionsToBeProcessed.add(transaction);
|
|
||||||
totalTransactionsCounter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transactionsToBeProcessed.size() > 0) groupOfTransactionsToBeExecuted.add(transactionsToBeProcessed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return groupOfTransactionsToBeExecuted;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void updateTransactionImportCounterInDB(int lastTransactionId, String publicationID, String username) throws Exception {
|
|
||||||
String sql = "UPDATE stb_subscriptions_user " +
|
|
||||||
"SET last_transaction_id_import = " + lastTransactionId + " " +
|
|
||||||
"WHERE publication_id = " + UtilityDB.valueToString(publicationID) + " " +
|
|
||||||
"AND user_name = " + UtilityDB.valueToString(username);
|
|
||||||
|
|
||||||
PreparedStatement psUpdate = multiDBTransactionManager.prepareStatement(sql);
|
|
||||||
psUpdate.executeUpdate();
|
|
||||||
multiDBTransactionManager.commitAll();
|
|
||||||
psUpdate.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTransactionImportCounterInRemote(String hostEndpoint, String profileDb, String username, List<TransactionDTO> importedTransactions) throws Exception {
|
|
||||||
StringBuilder responseBody;
|
|
||||||
String wsUrlEndpoint = hostEndpoint + EmsRestConstants.PATH_ASYNC_BASE_ROUTE + EmsRestConstants.PATH_ASYNC_UPDATE_TRANSACTION_IMPORT_ID;
|
|
||||||
|
|
||||||
List<String> publicationIDs = Stream.of(importedTransactions)
|
|
||||||
.map(transactionDTO -> transactionDTO.getPublicationId())
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
|
|
||||||
List<TransactionDTO> maxOfTransactionsIDList = new ArrayList<>();
|
|
||||||
for (final String publicationId : publicationIDs) {
|
|
||||||
maxOfTransactionsIDList.add(Stream.of(importedTransactions)
|
|
||||||
.filter(transactionDTO -> transactionDTO.getPublicationId().equalsIgnoreCase(publicationId))
|
|
||||||
.max((o1, o2) -> o1.getTransactionId() - o2.getTransactionId()).get());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TransactionDTO transactionDTO : maxOfTransactionsIDList) {
|
|
||||||
int status;
|
|
||||||
int retryCounter = 0;
|
|
||||||
do {
|
|
||||||
HashMap<String, String> queryParams = new HashMap<>();
|
|
||||||
queryParams.put(CommonConstants.PROFILE_DB, profileDb);
|
|
||||||
queryParams.put("publicationID", transactionDTO.getPublicationId());
|
|
||||||
queryParams.put("sender", username);
|
|
||||||
queryParams.put("transactionImportID", "" + transactionDTO.getTransactionId());
|
|
||||||
|
|
||||||
responseBody = new StringBuilder();
|
|
||||||
status = HttpRestWrapper.callGenericGet(wsUrlEndpoint, username, username, responseBody, queryParams);
|
|
||||||
|
|
||||||
retryCounter++;
|
|
||||||
} while (status != 200 && retryCounter < 4);
|
|
||||||
|
|
||||||
if (retryCounter == 4) {
|
|
||||||
throw new Exception("La richiesta \"" + wsUrlEndpoint + "\" ha generato un ESITO KO<br />Body: " + responseBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -334,8 +334,8 @@ public class EmsController {
|
|||||||
List<EntityBase> entityList = new ArrayList<>();
|
List<EntityBase> entityList = new ArrayList<>();
|
||||||
|
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (obj instanceof EntityBase[]) {
|
if (obj instanceof List) {
|
||||||
entityList = Arrays.asList((EntityBase[]) obj);
|
entityList = (List<EntityBase>) obj;
|
||||||
} else {
|
} else {
|
||||||
entityList.add((EntityBase) obj);
|
entityList.add((EntityBase) obj);
|
||||||
}
|
}
|
||||||
@@ -705,7 +705,7 @@ public class EmsController {
|
|||||||
if (ordinaSuPriorita)
|
if (ordinaSuPriorita)
|
||||||
entityList = entityPropertyHolder.getEntityChain(entityList, multiDBTransactionManager.getPrimaryConnection());
|
entityList = entityPropertyHolder.getEntityChain(entityList, multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
|
||||||
Integer prevTransactionGroupId = null;
|
Long prevTransactionGroupId = null;
|
||||||
|
|
||||||
for (EntityBase entity : entityList) {
|
for (EntityBase entity : entityList) {
|
||||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||||
@@ -726,6 +726,7 @@ public class EmsController {
|
|||||||
|
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
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.getPrimaryDatasource().getProfile(), entity);
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import javax.annotation.PreDestroy;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -61,6 +62,10 @@ public class DataSource {
|
|||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
if (connectionModel.getConnectionType() == EmsRestConstants.DB_TYPE.MSSQL) {
|
||||||
|
try (final PreparedStatement setNocountOn = connection.prepareStatement("SET NOCOUNT ON")) {
|
||||||
|
boolean resultNoCount = setNocountOn.execute();
|
||||||
|
}
|
||||||
|
|
||||||
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
|
HashMap<String, Object> resultSessionData = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, "select @@spid AS session_id," +
|
||||||
" user_name() AS [user_name]," +
|
" user_name() AS [user_name]," +
|
||||||
" suser_name() AS [suser_name]," +
|
" suser_name() AS [suser_name]," +
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
package it.integry.ems.dto;
|
package it.integry.ems.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EntityHierarchyDTO {
|
public class EntityHierarchyDTO {
|
||||||
|
|
||||||
|
private Class<? extends EntityBase> clazz;
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
private Field field;
|
||||||
|
private boolean master;
|
||||||
private List<EntityHierarchyDTO> children;
|
private List<EntityHierarchyDTO> children;
|
||||||
|
|
||||||
|
public Class<? extends EntityBase> getClazz() {
|
||||||
|
return clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityHierarchyDTO setClazz(Class<? extends EntityBase> clazz) {
|
||||||
|
this.clazz = clazz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getEntityName() {
|
public String getEntityName() {
|
||||||
return entityName;
|
return entityName;
|
||||||
}
|
}
|
||||||
@@ -24,6 +39,24 @@ public class EntityHierarchyDTO {
|
|||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Field getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityHierarchyDTO setField(Field field) {
|
||||||
|
this.field = field;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMaster() {
|
||||||
|
return master;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityHierarchyDTO setMaster(boolean master) {
|
||||||
|
this.master = master;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<EntityHierarchyDTO> getChildren() {
|
public List<EntityHierarchyDTO> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class ExtendedStbActivity {
|
|||||||
private String codJcom;
|
private String codJcom;
|
||||||
private String codAnag;
|
private String codAnag;
|
||||||
private String personaRif;
|
private String personaRif;
|
||||||
|
private String emailPersonaRif;
|
||||||
private String userName;
|
private String userName;
|
||||||
private String userCreator;
|
private String userCreator;
|
||||||
private String note;
|
private String note;
|
||||||
@@ -70,6 +71,15 @@ public class ExtendedStbActivity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEmailPersonaRif() {
|
||||||
|
return emailPersonaRif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedStbActivity setEmailPersonaRif(String emailPersonaRif) {
|
||||||
|
this.emailPersonaRif = emailPersonaRif;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class StbActivityEmailObject {
|
|||||||
private String subject;
|
private String subject;
|
||||||
private List<StbActivityEmailObjectAddress> to;
|
private List<StbActivityEmailObjectAddress> to;
|
||||||
private String body;
|
private String body;
|
||||||
|
private boolean bodyInBase64;
|
||||||
private List<StbActivityEmailObjectAttachment> attachments;
|
private List<StbActivityEmailObjectAttachment> attachments;
|
||||||
|
|
||||||
public StbActivityEmailObjectAddress getFrom() {
|
public StbActivityEmailObjectAddress getFrom() {
|
||||||
@@ -77,6 +78,15 @@ public class StbActivityEmailObject {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBodyInBase64() {
|
||||||
|
return bodyInBase64;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbActivityEmailObject setBodyInBase64(boolean bodyInBase64) {
|
||||||
|
this.bodyInBase64 = bodyInBase64;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<StbActivityEmailObjectAttachment> getAttachments() {
|
public List<StbActivityEmailObjectAttachment> getAttachments() {
|
||||||
return attachments;
|
return attachments;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,158 @@
|
|||||||
package it.integry.ems.dynamic_cache;
|
package it.integry.ems.dynamic_cache;
|
||||||
|
|
||||||
import it.integry.ems.expansion.RunnableArgs;
|
|
||||||
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.SettingsModel;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DynamicCacheService {
|
public class DynamicCacheService {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LooperService looperService;
|
private LooperService looperService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsModel settingsModel;
|
||||||
|
|
||||||
private final HashMap<Keys, Object> cacheData = new HashMap<>();
|
private final HashMap<Keys, Object> cacheData = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public enum Keys {
|
public enum Keys {
|
||||||
DATI_AZIENDA_KEY
|
DATI_AZIENDA_KEY,
|
||||||
|
ENTITY_LOGGER_SETUP,
|
||||||
|
GRIGLIA_ACQUISTO_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||||
cacheData.put(key, refreshAction.run());
|
//cacheData.put(key, refreshAction.run());
|
||||||
|
|
||||||
this.looperService.add(() -> {
|
this.looperService.add(() -> {
|
||||||
cacheData.put(key, refreshAction.run());
|
cacheData.put(key, refreshAction.run());
|
||||||
}, invalidateTimeInMins * 60 * 1000, "dynamic-cache-" + key);
|
}, invalidateTimeInMins * 60 * 1000, "dynamic-cache-" + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addEntity(Keys key, int invalidateTimeInMins, Class<? extends EntityBase> clazz, List<String> dbNames) {
|
||||||
|
|
||||||
|
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||||
|
|
||||||
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
|
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||||
|
.stream()
|
||||||
|
.filter(AvailableConnectionsModel::getInternalDb)
|
||||||
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
|
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||||
|
|
||||||
|
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = new HashMap<>();
|
||||||
|
|
||||||
|
for (String dbName : databases.keySet()) {
|
||||||
|
try {
|
||||||
|
String profileName = databases.get(dbName).get(0).getProfileName();
|
||||||
|
cacheEntityByDB(dbName, profileName, clazz, cachedEntitiesByDB);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error(ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cachedEntitiesByDB;
|
||||||
|
};
|
||||||
|
|
||||||
|
addItem(key, invalidateTimeInMins, refreshAction);
|
||||||
|
}
|
||||||
|
|
||||||
public void setManualValue(Keys key, Object value) {
|
public void setManualValue(Keys key, Object value) {
|
||||||
cacheData.put(key, value);
|
cacheData.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public <T extends EntityBase> List<T> getEntity(Keys key, String dbName) {
|
||||||
|
dbName = dbName.toLowerCase();
|
||||||
|
|
||||||
|
final HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB = (HashMap<String, List<? extends EntityBase>>) cacheData.getOrDefault(key, null);
|
||||||
|
if (cachedEntitiesByDB == null) return null;
|
||||||
|
|
||||||
|
final List<T> cachedEntityList = (List<T>) cachedEntitiesByDB.getOrDefault(dbName, null);
|
||||||
|
if (cachedEntityList == null) return null;
|
||||||
|
|
||||||
|
return cachedEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheEntityByDB(String dbName, String profileName, Class<? extends EntityBase> clazz, HashMap<String, List<? extends EntityBase>> cachedEntitiesByDB) throws Exception {
|
||||||
|
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String tableName = clazz.newInstance().getTableName();
|
||||||
|
String sql = "SELECT * FROM " + tableName;
|
||||||
|
List<? extends EntityBase> entities = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, clazz);
|
||||||
|
|
||||||
|
cachedEntitiesByDB.putIfAbsent(dbName.toLowerCase(), entities);
|
||||||
|
} finally {
|
||||||
|
multiDBTransactionManager.closeAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addQuery(Keys key, int invalidateTimeInMins, String query, Class<?> clazz, List<String> dbNames) {
|
||||||
|
List<String> finalDbNames = dbNames.stream().map(String::toLowerCase).collect(Collectors.toList());
|
||||||
|
|
||||||
|
RunnableWithReturn<Object> refreshAction = () -> {
|
||||||
|
|
||||||
|
Map<String, List<AvailableConnectionsModel>> databases = settingsModel.getAvailableConnections()
|
||||||
|
.stream()
|
||||||
|
.filter(AvailableConnectionsModel::getInternalDb)
|
||||||
|
.filter(x -> finalDbNames.contains(x.getDbName().toLowerCase()))
|
||||||
|
.collect(Collectors.groupingBy(AvailableConnectionsModel::getDbName));
|
||||||
|
|
||||||
|
final HashMap<String, List<?>> cacheQueryByDB = new HashMap<>();
|
||||||
|
|
||||||
|
for (String dbName : databases.keySet()) {
|
||||||
|
try {
|
||||||
|
String profileName = databases.get(dbName).get(0).getProfileName();
|
||||||
|
cacheQueryByDB(dbName, profileName, query, clazz, cacheQueryByDB);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error(ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheQueryByDB;
|
||||||
|
};
|
||||||
|
|
||||||
|
addItem(key, invalidateTimeInMins, refreshAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheQueryByDB(String dbName, String profileName, String query, Class<?> clazz, HashMap<String, List<?>> cacheObjectByDB) throws Exception {
|
||||||
|
MultiDBTransactionManager m = new MultiDBTransactionManager(profileName, false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<?> objects = UtilityDB.executeSimpleQueryDTO(m.getPrimaryConnection(), query, clazz);
|
||||||
|
cacheObjectByDB.putIfAbsent(dbName.toLowerCase(), objects);
|
||||||
|
} finally {
|
||||||
|
m.closeAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends EntityBase> List<T> getObject(Keys key, String dbName) {
|
||||||
|
dbName = dbName.toLowerCase();
|
||||||
|
|
||||||
|
final HashMap<String, List<?>> cacheObjectByDB = (HashMap<String, List<?>>) cacheData.getOrDefault(key, null);
|
||||||
|
if (cacheObjectByDB == null) return null;
|
||||||
|
|
||||||
|
final List<T> cachedEntityList = (List<T>) cacheObjectByDB.getOrDefault(dbName, null);
|
||||||
|
if (cachedEntityList == null) return null;
|
||||||
|
|
||||||
|
return cachedEntityList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package it.integry.ems.entity_logger.service;
|
|||||||
import com.annimon.stream.Optional;
|
import com.annimon.stream.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.dynamic_cache.DynamicCacheService;
|
||||||
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.DatabaseFile;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseFile;
|
||||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
||||||
@@ -15,6 +16,7 @@ import it.integry.ems.settings.SettingsController;
|
|||||||
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;
|
||||||
|
import it.integry.ems_model.entity.StbLogEntitySetup;
|
||||||
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 org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -46,7 +48,7 @@ public class EntityLoggerComponent {
|
|||||||
@PostContextConstruct(priority = 10)
|
@PostContextConstruct(priority = 10)
|
||||||
private void init() {
|
private void init() {
|
||||||
try {
|
try {
|
||||||
if (!UtilityDebug.isDebugExecution()) {
|
if (!UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) {
|
||||||
this.syncDBScheme();
|
this.syncDBScheme();
|
||||||
|
|
||||||
looperService.add(this::deleteOldlogs, 12 * 60 * 60 * 1000, EntityLoggerComponent.class.getName()); //Ogni 12 ore
|
looperService.add(this::deleteOldlogs, 12 * 60 * 60 * 1000, EntityLoggerComponent.class.getName()); //Ogni 12 ore
|
||||||
@@ -223,7 +225,7 @@ public class EntityLoggerComponent {
|
|||||||
|
|
||||||
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
for (AvailableConnectionsModel sourceConnectionModel : connectionsModels) {
|
||||||
String sql = "SELECT * FROM stb_log_entity_setup" +
|
String sql = "SELECT * FROM stb_log_entity_setup" +
|
||||||
" WHERE entity_name <> 'stb_log_entity_setup'";
|
" WHERE entity_name <> " + UtilityDB.valueToString(StbLogEntitySetup.ENTITY);
|
||||||
|
|
||||||
sourceMultiDB = new MultiDBTransactionManager(sourceConnectionModel.getProfileName());
|
sourceMultiDB = new MultiDBTransactionManager(sourceConnectionModel.getProfileName());
|
||||||
List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(sourceMultiDB.getPrimaryConnection(), sql);
|
List<HashMap<String, Object>> result = UtilityDB.executeSimpleQuery(sourceMultiDB.getPrimaryConnection(), sql);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package it.integry.ems.exception;
|
||||||
|
|
||||||
|
public class SystemNotInitializedException extends Exception {
|
||||||
|
|
||||||
|
private final int statusCode;
|
||||||
|
|
||||||
|
public SystemNotInitializedException(int statusCode, String message) {
|
||||||
|
super(message);
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatusCode() {
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -352,6 +352,12 @@ public abstract class BaseEntityExporter implements IEntityExporter {
|
|||||||
|
|
||||||
case EMAIL:
|
case EMAIL:
|
||||||
|
|
||||||
|
if (UtilityString.isNullOrEmpty(wtbUserInfo.getEmail()) &&
|
||||||
|
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCc()) &&
|
||||||
|
UtilityString.isNullOrEmpty(wtbUserInfo.getEmailCcn())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(entityExportResponse.getMessageSubject())) {
|
if (UtilityString.isNullOrEmpty(entityExportResponse.getMessageSubject())) {
|
||||||
entityExportResponse.setMessageSubject("INVIO " + type);
|
entityExportResponse.setMessageSubject("INVIO " + type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package it.integry.ems.menu;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class MenuStaticCreator {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
System.out.println("Running the Menu UPDATE");
|
||||||
|
|
||||||
|
String connectionString = String.format("jdbc:sqlserver://%s;databaseName=%s;applicationName=%s", "SERVERDB2019", "studioml", "IntelliJ Connection");
|
||||||
|
String username = "sa";
|
||||||
|
String password = "sa";
|
||||||
|
|
||||||
|
Connection connection = DriverManager.getConnection(connectionString, username, password);
|
||||||
|
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
|
final String baseProjectPath = new File("").getAbsolutePath() + "\\ems-core\\src\\main\\";
|
||||||
|
final String menuJsonResourceFolder = baseProjectPath + "resources\\menus\\";
|
||||||
|
|
||||||
|
ObjectMapper jsonObjectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
final List<StbMenuOpzDTO> stbMenuOpzs = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu_opz", StbMenuOpzDTO.class);
|
||||||
|
|
||||||
|
final List<StbTipoAziendaDTO> stbTipoAziendas = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_tipo_azienda", StbTipoAziendaDTO.class);
|
||||||
|
|
||||||
|
final List<StbMenuDTO> stbMenus = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu", StbMenuDTO.class);
|
||||||
|
final Map<String, List<StbMenuDTO>> menusByAzienda = stbMenus.stream().collect(Collectors.groupingBy(StbMenuDTO::getTipoAzienda));
|
||||||
|
|
||||||
|
|
||||||
|
MenuConfigDTO menuConfigDTO = new MenuConfigDTO(Integer.parseInt(CommonConstants.DATESTAMP_FORMATTER.format(UtilityLocalDate.getNow())))
|
||||||
|
.setStbMenuOpz(stbMenuOpzs)
|
||||||
|
.setStbTipoAzienda(stbTipoAziendas)
|
||||||
|
.setMenusByAzienda(menusByAzienda);
|
||||||
|
|
||||||
|
writeContentToFile(menuJsonResourceFolder + "menu_config.json", jsonObjectMapper.writeValueAsString(menuConfigDTO), true);
|
||||||
|
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void writeContentToFile(String filePath, String content, boolean overwrite) throws IOException {
|
||||||
|
File f = new File(filePath);
|
||||||
|
if (overwrite && f.exists()) f.delete();
|
||||||
|
|
||||||
|
FileOutputStream outputStream = new FileOutputStream(filePath);
|
||||||
|
byte[] strToBytes = content.getBytes();
|
||||||
|
outputStream.write(strToBytes);
|
||||||
|
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package it.integry.ems.menu.controller;
|
||||||
|
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.menu.service.MenuConfigurationService;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope("request")
|
||||||
|
@RequestMapping("system/menu")
|
||||||
|
public class MenuConfigurationController {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MenuConfigurationService menuConfigurationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@RequestMapping(value = "refresh", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody
|
||||||
|
ServiceRestResponse refresh(@RequestParam(CommonConstants.PROFILE_DB) String profileDB) throws Exception {
|
||||||
|
menuConfigurationService.refresh(multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MenuConfigDTO {
|
||||||
|
|
||||||
|
private int version;
|
||||||
|
private List<StbMenuOpzDTO> stbMenuOpz;
|
||||||
|
private List<StbTipoAziendaDTO> stbTipoAzienda;
|
||||||
|
private Map<String, List<StbMenuDTO>> menusByAzienda;
|
||||||
|
|
||||||
|
public MenuConfigDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO(int version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StbMenuOpzDTO> getStbMenuOpz() {
|
||||||
|
return stbMenuOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setStbMenuOpz(List<StbMenuOpzDTO> stbMenuOpz) {
|
||||||
|
this.stbMenuOpz = stbMenuOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StbTipoAziendaDTO> getStbTipoAzienda() {
|
||||||
|
return stbTipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setStbTipoAzienda(List<StbTipoAziendaDTO> stbTipoAzienda) {
|
||||||
|
this.stbTipoAzienda = stbTipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<StbMenuDTO>> getMenusByAzienda() {
|
||||||
|
return menusByAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuConfigDTO setMenusByAzienda(Map<String, List<StbMenuDTO>> menusByAzienda) {
|
||||||
|
this.menusByAzienda = menusByAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
283
ems-core/src/main/java/it/integry/ems/menu/dto/StbMenuDTO.java
Normal file
283
ems-core/src/main/java/it/integry/ems/menu/dto/StbMenuDTO.java
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbMenu;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
|
public class StbMenuDTO {
|
||||||
|
|
||||||
|
private String type = "stb_menu";
|
||||||
|
|
||||||
|
@SqlField(value = "cod_opz", maxLength = 5, nullable = false)
|
||||||
|
private String codOpz;
|
||||||
|
|
||||||
|
@SqlField(value = "cod_parent", maxLength = 5, nullable = false)
|
||||||
|
private String codParent;
|
||||||
|
|
||||||
|
@SqlField(value = "tipo_azienda", maxLength = 40, nullable = false)
|
||||||
|
private String tipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 255, nullable = true)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione_estesa", maxLength = 8000, nullable = true)
|
||||||
|
private String descrizioneEstesa;
|
||||||
|
|
||||||
|
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_attivo", maxLength = 1, nullable = true, defaultObjectValue = "S")
|
||||||
|
private String flagAttivo;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||||
|
private String flagPrinterSetup;
|
||||||
|
|
||||||
|
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||||
|
private String gestName;
|
||||||
|
|
||||||
|
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||||
|
private String objectType;
|
||||||
|
|
||||||
|
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||||
|
private String openType;
|
||||||
|
|
||||||
|
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||||
|
private String parameter;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureMenu;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureSelect;
|
||||||
|
|
||||||
|
@SqlField(value = "pos", nullable = true)
|
||||||
|
private Integer pos;
|
||||||
|
|
||||||
|
@SqlField(value = "pos_cliente", nullable = true)
|
||||||
|
private Integer posCliente;
|
||||||
|
|
||||||
|
@SqlField(value = "pos_tipo_azienda", nullable = true)
|
||||||
|
private Integer posTipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "type", maxLength = -1, nullable = true, defaultObjectValue = "F")
|
||||||
|
private String menuType;
|
||||||
|
|
||||||
|
@SqlField(value = "url_descrizione", maxLength = 1024, nullable = true)
|
||||||
|
private String urlDescrizione;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodOpz() {
|
||||||
|
return codOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setCodOpz(String codOpz) {
|
||||||
|
this.codOpz = codOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodParent() {
|
||||||
|
return codParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setCodParent(String codParent) {
|
||||||
|
this.codParent = codParent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTipoAzienda() {
|
||||||
|
return tipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setTipoAzienda(String tipoAzienda) {
|
||||||
|
this.tipoAzienda = tipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizioneEstesa() {
|
||||||
|
return descrizioneEstesa;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setDescrizioneEstesa(String descrizioneEstesa) {
|
||||||
|
this.descrizioneEstesa = descrizioneEstesa;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setEntityName(String entityName) {
|
||||||
|
this.entityName = entityName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagAttivo() {
|
||||||
|
return flagAttivo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setFlagAttivo(String flagAttivo) {
|
||||||
|
this.flagAttivo = flagAttivo;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagPrinterSetup() {
|
||||||
|
return flagPrinterSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setFlagPrinterSetup(String flagPrinterSetup) {
|
||||||
|
this.flagPrinterSetup = flagPrinterSetup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGestName() {
|
||||||
|
return gestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setGestName(String gestName) {
|
||||||
|
this.gestName = gestName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setNote(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjectType() {
|
||||||
|
return objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setObjectType(String objectType) {
|
||||||
|
this.objectType = objectType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenType() {
|
||||||
|
return openType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setOpenType(String openType) {
|
||||||
|
this.openType = openType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setParameter(String parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureMenu() {
|
||||||
|
return pictureMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPictureMenu(String pictureMenu) {
|
||||||
|
this.pictureMenu = pictureMenu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureSelect() {
|
||||||
|
return pictureSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPictureSelect(String pictureSelect) {
|
||||||
|
this.pictureSelect = pictureSelect;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPos() {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPos(Integer pos) {
|
||||||
|
this.pos = pos;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPosCliente() {
|
||||||
|
return posCliente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPosCliente(Integer posCliente) {
|
||||||
|
this.posCliente = posCliente;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPosTipoAzienda() {
|
||||||
|
return posTipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setPosTipoAzienda(Integer posTipoAzienda) {
|
||||||
|
this.posTipoAzienda = posTipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMenuType() {
|
||||||
|
return menuType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setMenuType(String menuType) {
|
||||||
|
this.menuType = menuType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrlDescrizione() {
|
||||||
|
return urlDescrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuDTO setUrlDescrizione(String urlDescrizione) {
|
||||||
|
this.urlDescrizione = urlDescrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenu toEntity() {
|
||||||
|
return new StbMenu()
|
||||||
|
.setCodOpz(getCodOpz())
|
||||||
|
.setCodParent(UtilityString.isNullOrEmpty(getCodParent()) ? "ROOT" : getCodParent())
|
||||||
|
.setTipoAzienda(getTipoAzienda())
|
||||||
|
.setDescrizione(getDescrizione())
|
||||||
|
.setDescrizioneEstesa(getDescrizioneEstesa())
|
||||||
|
.setEntityName(getEntityName())
|
||||||
|
.setFlagAttivo(getFlagAttivo())
|
||||||
|
.setFlagPrinterSetup(getFlagPrinterSetup())
|
||||||
|
.setGestName(getGestName())
|
||||||
|
.setNote(getNote())
|
||||||
|
.setObjectType(getObjectType())
|
||||||
|
.setOpenType(getOpenType())
|
||||||
|
.setParameter(getParameter())
|
||||||
|
.setPictureMenu(getPictureMenu())
|
||||||
|
.setPictureSelect(getPictureSelect())
|
||||||
|
.setPos(getPos())
|
||||||
|
.setPosCliente(getPosCliente())
|
||||||
|
.setPosTipoAzienda(getPosTipoAzienda())
|
||||||
|
.setMenuType(getMenuType())
|
||||||
|
.setUrlDescrizione(getUrlDescrizione());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbMenuOpz;
|
||||||
|
|
||||||
|
public class StbMenuOpzDTO {
|
||||||
|
|
||||||
|
private String type = "stb_menu_opz";
|
||||||
|
|
||||||
|
@SqlField(value = "cod_opz", maxLength = 5, nullable = false)
|
||||||
|
private String codOpz;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 255, nullable = false)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||||
|
private String flagPrinterSetup;
|
||||||
|
|
||||||
|
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||||
|
private String gestName;
|
||||||
|
|
||||||
|
@SqlField(value = "is_deprecated", maxLength = 1, nullable = false, defaultObjectValue = "N")
|
||||||
|
private String isDeprecated;
|
||||||
|
|
||||||
|
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||||
|
private String objectType;
|
||||||
|
|
||||||
|
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||||
|
private String openType;
|
||||||
|
|
||||||
|
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||||
|
private String parameter;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureMenu;
|
||||||
|
|
||||||
|
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||||
|
private String pictureSelect;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodOpz() {
|
||||||
|
return codOpz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setCodOpz(String codOpz) {
|
||||||
|
this.codOpz = codOpz;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setEntityName(String entityName) {
|
||||||
|
this.entityName = entityName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlagPrinterSetup() {
|
||||||
|
return flagPrinterSetup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setFlagPrinterSetup(String flagPrinterSetup) {
|
||||||
|
this.flagPrinterSetup = flagPrinterSetup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGestName() {
|
||||||
|
return gestName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setGestName(String gestName) {
|
||||||
|
this.gestName = gestName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsDeprecated() {
|
||||||
|
return isDeprecated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setIsDeprecated(String isDeprecated) {
|
||||||
|
this.isDeprecated = isDeprecated;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setNote(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getObjectType() {
|
||||||
|
return objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setObjectType(String objectType) {
|
||||||
|
this.objectType = objectType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenType() {
|
||||||
|
return openType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setOpenType(String openType) {
|
||||||
|
this.openType = openType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setParameter(String parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureMenu() {
|
||||||
|
return pictureMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setPictureMenu(String pictureMenu) {
|
||||||
|
this.pictureMenu = pictureMenu;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPictureSelect() {
|
||||||
|
return pictureSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbMenuOpzDTO setPictureSelect(String pictureSelect) {
|
||||||
|
this.pictureSelect = pictureSelect;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StbMenuOpz toEntity() {
|
||||||
|
return new StbMenuOpz()
|
||||||
|
.setCodOpz(getCodOpz())
|
||||||
|
.setDescrizione(getDescrizione())
|
||||||
|
.setEntityName(getEntityName())
|
||||||
|
.setFlagPrinterSetup(getFlagPrinterSetup())
|
||||||
|
.setGestName(getGestName())
|
||||||
|
.setIsDeprecated(getIsDeprecated())
|
||||||
|
.setNote(getNote())
|
||||||
|
.setObjectType(getObjectType())
|
||||||
|
.setOpenType(getOpenType())
|
||||||
|
.setParameter(getParameter())
|
||||||
|
.setPictureMenu(getPictureMenu())
|
||||||
|
.setPictureSelect(getPictureSelect());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package it.integry.ems.menu.dto;
|
||||||
|
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
|
import it.integry.ems_model.entity.StbTipoAzienda;
|
||||||
|
|
||||||
|
public class StbTipoAziendaDTO {
|
||||||
|
|
||||||
|
private String type = "stb_tipo_azienda";
|
||||||
|
|
||||||
|
@SqlField(value = "tipo_azienda", maxLength = 40, nullable = false)
|
||||||
|
private String tipoAzienda;
|
||||||
|
|
||||||
|
@SqlField(value = "descrizione", maxLength = 1024)
|
||||||
|
private String descrizione;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTipoAzienda() {
|
||||||
|
return tipoAzienda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setTipoAzienda(String tipoAzienda) {
|
||||||
|
this.tipoAzienda = tipoAzienda;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescrizione() {
|
||||||
|
return descrizione;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StbTipoAziendaDTO setDescrizione(String descrizione) {
|
||||||
|
this.descrizione = descrizione;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StbTipoAzienda toEntity() {
|
||||||
|
return new StbTipoAzienda()
|
||||||
|
.setTipoAzienda(getTipoAzienda())
|
||||||
|
.setDescrizione(getDescrizione());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
package it.integry.ems.menu.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import it.integry.annotations.PostContextAutowired;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||||
|
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||||
|
import it.integry.ems.settings.SettingsController;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.entity.Azienda;
|
||||||
|
import it.integry.ems_model.entity.StbMenu;
|
||||||
|
import it.integry.ems_model.entity.StbMenuOpz;
|
||||||
|
import it.integry.ems_model.entity.StbTipoAzienda;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static it.integry.ems_model.utility.UtilityDB.executeStatement;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MenuConfigurationService {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsController settingsController;
|
||||||
|
|
||||||
|
@PostContextAutowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
@PostContextConstruct(priority = 5)
|
||||||
|
public void init() throws Exception {
|
||||||
|
if(UtilityDebug.isDebugExecution()) return;
|
||||||
|
|
||||||
|
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Refresh menu");
|
||||||
|
|
||||||
|
final MenuConfigDTO menuConfig = loadMenuData();
|
||||||
|
|
||||||
|
for (AdvancedDataSource advancedDataSource : multiDBTransactionManager.getActiveConnections()) {
|
||||||
|
|
||||||
|
if (advancedDataSource.getDataSource().getDbName().equalsIgnoreCase("studioml") || isHistoryDB(advancedDataSource))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||||
|
internalRefresh(advancedDataSource.getConnection(), menuConfig);
|
||||||
|
//logger.debug("Menu refresh time: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Errore durante l'aggiornamento del menu di " + advancedDataSource.getProfileName(), ex);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHistoryDB(AdvancedDataSource advancedDataSource) throws Exception {
|
||||||
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
|
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(Connection connection) throws Exception {
|
||||||
|
final MenuConfigDTO menuConfig = loadMenuData();
|
||||||
|
internalRefresh(connection, menuConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MenuConfigDTO loadMenuData() throws IOException {
|
||||||
|
|
||||||
|
ObjectMapper jsonObjectMapper = new ObjectMapper();
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
|
||||||
|
final URL resourceMenuConfigURL = classLoader.getResource("menus/menu_config.json");
|
||||||
|
final MenuConfigDTO menuConfig = jsonObjectMapper.readValue(resourceMenuConfigURL, MenuConfigDTO.class);
|
||||||
|
|
||||||
|
return menuConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalRefresh(Connection connection, MenuConfigDTO menuConfig) throws Exception {
|
||||||
|
final Azienda azienda = Azienda.getDefaultAzienda(connection);
|
||||||
|
int lastMenuUpd = Integer.parseInt(azienda.getLastUpgDbMenu().replace("QM", ""));
|
||||||
|
|
||||||
|
if (menuConfig.getVersion() <= lastMenuUpd)
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(connection, "DELETE FROM stb_menu",
|
||||||
|
"EXECUTE dbo.DropForeignKey 'azienda', 'stb_tipo_azienda'",
|
||||||
|
"DELETE FROM stb_tipo_azienda",
|
||||||
|
"DELETE FROM stb_menu_opz");
|
||||||
|
|
||||||
|
for (StbMenuOpzDTO stbMenuOpzDto : menuConfig.getStbMenuOpz()) {
|
||||||
|
StbMenuOpz stbMenuOpz = stbMenuOpzDto.toEntity();
|
||||||
|
stbMenuOpz.setOperation(OperationType.INSERT);
|
||||||
|
stbMenuOpz.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (StbTipoAziendaDTO stbTipoAziendaDto : menuConfig.getStbTipoAzienda()) {
|
||||||
|
StbTipoAzienda stbTipoAzienda = stbTipoAziendaDto.toEntity();
|
||||||
|
stbTipoAzienda.setOperation(OperationType.INSERT);
|
||||||
|
stbTipoAzienda.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<StbMenuDTO> stbMenus = menuConfig.getMenusByAzienda().get(azienda.getTipoAzienda().toUpperCase());
|
||||||
|
|
||||||
|
if (stbMenus == null)
|
||||||
|
logger.error("Nessuna configurazione trovata per il menu " + azienda.getTipoAzienda() + " di " + azienda.getNomeDitta());
|
||||||
|
else
|
||||||
|
for (StbMenuDTO stbMenuDto : stbMenus) {
|
||||||
|
StbMenu stbMenu = stbMenuDto.toEntity();
|
||||||
|
stbMenu.setOperation(OperationType.INSERT);
|
||||||
|
stbMenu.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
executeStatement(connection, "ALTER TABLE azienda ADD CONSTRAINT FK_azienda_stb_tipo_azienda FOREIGN KEY (tipo_azienda) REFERENCES stb_tipo_azienda ( tipo_azienda )",
|
||||||
|
"DELETE FROM stb_abil WHERE cod_opz not in (select cod_opz from stb_menu_opz )",
|
||||||
|
"INSERT INTO stb_Abil SELECT opz2Abil.cod_parent AS cod_opz, opz2Abil.user_name, 'S' flag_Abil, NULL gest_name\n" +
|
||||||
|
"FROM (SELECT DISTINCT opz.cod_parent, abil.user_name\n" +
|
||||||
|
" FROM stb_menu opz\n" +
|
||||||
|
" LEFT OUTER JOIN stb_menu root ON opz.cod_parent = root.cod_opz,\n" +
|
||||||
|
" stb_abil Abil,\n" +
|
||||||
|
" azienda\n" +
|
||||||
|
" WHERE opz.cod_parent <> 'ROOT'\n" +
|
||||||
|
" AND ISNULL(root.cod_parent, '') <> 'WM002'\n" +
|
||||||
|
" AND opz.cod_opz = abil.cod_opz\n" +
|
||||||
|
" AND opz.tipo_azienda = azienda.tipo_azienda\n" +
|
||||||
|
" AND abil.flag_Abil <> 'N') Opz2Abil\n" +
|
||||||
|
" LEFT OUTER JOIN stb_Abil ON stb_Abil.cod_opz = Opz2Abil.cod_parent AND stb_abil.user_name = Opz2Abil.user_name\n" +
|
||||||
|
"WHERE stb_abil.cod_opz IS NULL",
|
||||||
|
"UPDATE azienda SET last_upg_db_menu = " + UtilityDB.valueToString("QM" + menuConfig.getVersion()));
|
||||||
|
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,8 +35,8 @@ public class MetricFilter implements Filter {
|
|||||||
double stopTime = System.nanoTime();
|
double stopTime = System.nanoTime();
|
||||||
double execTime = (stopTime - startTime) / 1000000000;
|
double execTime = (stopTime - startTime) / 1000000000;
|
||||||
// final int status = ((HttpServletResponse) response).getStatus();
|
// final int status = ((HttpServletResponse) response).getStatus();
|
||||||
Double duration = Double.valueOf(execTime);
|
|
||||||
metricService.updateCountTimeForService(req, duration);
|
metricService.updateCountTimeForService(req, execTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
package it.integry.ems.migration;
|
package it.integry.ems.migration;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
import com.gentlyweb.utils.GeneralUtils;
|
||||||
import it.integry.annotations.PostContextAutowired;
|
import it.integry.annotations.PostContextAutowired;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
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.AdvancedDataSource;
|
||||||
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.entity.Azienda;
|
import it.integry.ems_model.entity.Azienda;
|
||||||
|
import it.integry.ems_model.entity.StbMigrationStatus;
|
||||||
|
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.OperationType;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityServer;
|
import it.integry.ems_model.utility.UtilityServer;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
@@ -21,12 +26,11 @@ import org.reflections.Reflections;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MigrationService {
|
public class MigrationService {
|
||||||
@@ -48,17 +52,27 @@ public class MigrationService {
|
|||||||
@PostContextAutowired
|
@PostContextAutowired
|
||||||
private MultiDBTransactionManager multiDBTransactionManager;
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
private List<Class<? extends MigrationModelInterface>> allMigrationsList;
|
||||||
|
|
||||||
|
private final HashMap<String, Boolean> migrationsErrorMapByProfiles = new HashMap<>();
|
||||||
|
|
||||||
@PostContextConstruct
|
@PostContextConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
Reflections reflections = new Reflections("it.integry.ems.migration.model");
|
Reflections reflections = new Reflections("it.integry.ems.migration.model");
|
||||||
|
|
||||||
List<Class<? extends MigrationModelInterface>> clssList = new ArrayList<>(Stream.of(reflections.getSubTypesOf(MigrationModelInterface.class))
|
allMigrationsList = new ArrayList<>(Stream.of(reflections.getSubTypesOf(MigrationModelInterface.class))
|
||||||
.map(x -> x)
|
.map(x -> x)
|
||||||
.filter(x -> !Modifier.isAbstract(x.getModifiers()))
|
.filter(x -> !Modifier.isAbstract(x.getModifiers()))
|
||||||
.sortBy(Class::getSimpleName)
|
.sortBy(Class::getSimpleName)
|
||||||
.toList());
|
.toList());
|
||||||
|
|
||||||
|
if (UtilityDebug.isDebugExecution())
|
||||||
|
return;
|
||||||
|
|
||||||
|
startMigrationsGlobally(multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) {
|
||||||
List<AdvancedDataSource> advancedDataSources;
|
List<AdvancedDataSource> advancedDataSources;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -72,32 +86,33 @@ public class MigrationService {
|
|||||||
logger.error("MigrationService - Init", e);
|
logger.error("MigrationService - Init", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ArrayList<Runnable> calls = new ArrayList<>();
|
|
||||||
|
|
||||||
for (final AdvancedDataSource advancedDataSource : advancedDataSources) {
|
for (final AdvancedDataSource advancedDataSource : advancedDataSources) {
|
||||||
|
executeMigrationGroup(advancedDataSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//calls.add(() -> {
|
public void executeMigrationGroup(AdvancedDataSource advancedDataSource) {
|
||||||
|
|
||||||
try {
|
|
||||||
initLastVersionField(advancedDataSource);
|
|
||||||
|
|
||||||
for (Class<? extends MigrationModelInterface> migrationClass : clssList) {
|
|
||||||
try {
|
try {
|
||||||
|
migrateStatus(advancedDataSource);
|
||||||
|
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(advancedDataSource);
|
||||||
|
|
||||||
|
for (Class<? extends MigrationModelInterface> migrationClass : allMigrationsList) {
|
||||||
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
||||||
long lastMigration = getLastMigrationFromDB(advancedDataSource);
|
|
||||||
|
|
||||||
if (migrationNumber <= lastMigration) continue;
|
if (migrationStatuses.stream().anyMatch(x -> x.getMigrationCode() == migrationNumber && (x.isCompleted() || x.isSkipped())))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||||
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||||
|
//logger.debug("MIGRATION TIME: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||||
|
|
||||||
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
advancedDataSource.getConnection().commit();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() +")", e);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
advancedDataSource.getConnection().rollback();
|
advancedDataSource.getConnection().rollback();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -105,61 +120,19 @@ public class MigrationService {
|
|||||||
logger.error("MigrationService - Rollback", ex);
|
logger.error("MigrationService - Rollback", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) break;
|
trackMigrationError(advancedDataSource, migrationNumber, e);
|
||||||
|
|
||||||
try {
|
|
||||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(settingsModel.getDefaultProfile());
|
|
||||||
Azienda azienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
|
||||||
|
|
||||||
mailService.sendSystemWarningLog("[" + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Aggiornamento sistema",
|
|
||||||
"anomalia durante l'aggiornamento",
|
|
||||||
"La migrazione " + migrationClass.getSimpleName() + " non è andata a buon fine sul DB " + advancedDataSource.getProfileName() + ". Controllare il log per ulteriori dettagli.",
|
|
||||||
e, new Date());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error("MigrationService - Mail", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), false);
|
||||||
|
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), false);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
//});
|
|
||||||
}
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// UtilityThread.executeParallel(calls);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.error("MigrationService", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initLastVersionField(AdvancedDataSource advancedDataSource) throws Exception {
|
|
||||||
|
|
||||||
String sql = "SELECT CAST(COUNT(*) AS BIT) as exist " +
|
|
||||||
"FROM sys.columns " +
|
|
||||||
"WHERE Name = N'last_migration' " +
|
|
||||||
" AND Object_ID = Object_ID(N'dbo.azienda')";
|
|
||||||
|
|
||||||
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
|
||||||
|
|
||||||
if (!fieldExists) {
|
|
||||||
String alterTableSql = "ALTER TABLE azienda ADD last_migration VARCHAR(14)";
|
|
||||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
|
||||||
statement.execute(alterTableSql);
|
|
||||||
statement.close();
|
|
||||||
|
|
||||||
// String updateSql = "UPDATE azienda SET last_migration = " + UtilityDB.valueToString(settingsModel.getLastMigration());
|
|
||||||
// PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(updateSql);
|
|
||||||
// ps.executeUpdate();
|
|
||||||
// ps.close();
|
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
private void executeMigration(Class<? extends MigrationModelInterface> migrationClass,
|
||||||
@@ -173,6 +146,65 @@ public class MigrationService {
|
|||||||
MigrationModelInterface migrationInstance = migrationClass.newInstance();
|
MigrationModelInterface migrationInstance = migrationClass.newInstance();
|
||||||
migrationInstance.init(advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
migrationInstance.init(advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||||
migrationInstance.up();
|
migrationInstance.up();
|
||||||
|
|
||||||
|
advancedDataSource.getConnection().commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLastMigrationIntoDB(AdvancedDataSource advancedDataSource, long lastMigraton) throws Exception {
|
||||||
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + lastMigraton;
|
||||||
|
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
|
if (stbMigrationStatus == null) {
|
||||||
|
stbMigrationStatus = new StbMigrationStatus()
|
||||||
|
.setMigrationCode(lastMigraton)
|
||||||
|
.setCompleted(true)
|
||||||
|
.setSkipped(false);
|
||||||
|
stbMigrationStatus.setOperation(OperationType.INSERT);
|
||||||
|
} else {
|
||||||
|
stbMigrationStatus.setCompleted(true)
|
||||||
|
.setSkipped(false)
|
||||||
|
.setErrorMessage(EmsRestConstants.NULL);
|
||||||
|
stbMigrationStatus.setOperation(OperationType.UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
||||||
|
|
||||||
|
advancedDataSource.getConnection().commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Long> getMigrationCodes() {
|
||||||
|
return allMigrationsList.stream()
|
||||||
|
.map(x -> Long.parseLong(x.getSimpleName().replace("Migration_", "")))
|
||||||
|
.sorted(Collections.reverseOrder())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void migrateStatus(AdvancedDataSource advancedDataSource) throws Exception {
|
||||||
|
final long lastMigrationNumber = getLastMigrationFromDB(advancedDataSource);
|
||||||
|
final List<Long> alreadyExecutedMigrations = retrieveAllMigrationsStatus(advancedDataSource)
|
||||||
|
.stream()
|
||||||
|
.map(StbMigrationStatus::getMigrationCode)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
final List<StbMigrationStatus> migrationStatusesToMigrate = allMigrationsList.stream()
|
||||||
|
.map(x -> Long.parseLong(x.getSimpleName().replace("Migration_", "")))
|
||||||
|
.filter(x -> x <= lastMigrationNumber && !alreadyExecutedMigrations.contains(x))
|
||||||
|
.map(x -> {
|
||||||
|
final StbMigrationStatus stbMigrationStatus = new StbMigrationStatus()
|
||||||
|
.setMigrationCode(x)
|
||||||
|
.setCompleted(true);
|
||||||
|
stbMigrationStatus.setOperation(OperationType.INSERT);
|
||||||
|
return stbMigrationStatus;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (StbMigrationStatus stbMigrationStatus : migrationStatusesToMigrate)
|
||||||
|
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
||||||
|
|
||||||
|
|
||||||
|
advancedDataSource.getConnection().commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getLastMigrationFromDB(AdvancedDataSource advancedDataSource) throws Exception {
|
private Long getLastMigrationFromDB(AdvancedDataSource advancedDataSource) throws Exception {
|
||||||
@@ -183,13 +215,65 @@ public class MigrationService {
|
|||||||
return Long.parseLong(lastMigration);
|
return Long.parseLong(lastMigration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLastMigrationIntoDB(AdvancedDataSource advancedDataSource, long lastMigraton) throws Exception {
|
|
||||||
String updateSql = "UPDATE azienda SET last_migration = " + UtilityDB.valueToString(String.valueOf(lastMigraton));
|
|
||||||
PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(updateSql);
|
|
||||||
ps.executeUpdate();
|
|
||||||
ps.close();
|
|
||||||
|
|
||||||
advancedDataSource.getConnection().commit();
|
private List<StbMigrationStatus> retrieveAllMigrationsStatus(AdvancedDataSource advancedDataSource) throws SQLException, IOException, DataConverterNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY;
|
||||||
|
List<StbMigrationStatus> stbMigrationStatuses = UtilityDB.executeSimpleQueryDTO(advancedDataSource.getConnection(), sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
|
if (stbMigrationStatuses == null) return new ArrayList<>();
|
||||||
|
|
||||||
|
stbMigrationStatuses = stbMigrationStatuses.stream()
|
||||||
|
.sorted(Comparator.comparing(StbMigrationStatus::getMigrationCode))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
return stbMigrationStatuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void trackMigrationError(AdvancedDataSource advancedDataSource, long migrationCode, Exception e) {
|
||||||
|
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), true);
|
||||||
|
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), true);
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(advancedDataSource.getProfileName())) {
|
||||||
|
final String exceptionTraceAsString = GeneralUtils.getExceptionTraceAsString(e);
|
||||||
|
|
||||||
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
|
||||||
|
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
|
if (stbMigrationStatus == null) {
|
||||||
|
stbMigrationStatus = new StbMigrationStatus();
|
||||||
|
stbMigrationStatus.setOperation(OperationType.INSERT);
|
||||||
|
} else {
|
||||||
|
stbMigrationStatus.setOperation(OperationType.UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
stbMigrationStatus
|
||||||
|
.setMigrationCode(migrationCode)
|
||||||
|
.setCompleted(false)
|
||||||
|
.setSkipped(false)
|
||||||
|
.setErrorMessage(e.getMessage() + "\n" + exceptionTraceAsString);
|
||||||
|
stbMigrationStatus.manageWithParentConnection(advancedDataSource.getConnection());
|
||||||
|
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) return;
|
||||||
|
|
||||||
|
Azienda azienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
|
||||||
|
mailService.sendSystemWarningLog("[" + azienda.getNomeDitta() + "][" + UtilityServer.getHostName() + "] Aggiornamento sistema",
|
||||||
|
"anomalia durante l'aggiornamento",
|
||||||
|
"La migrazione " + migrationCode + " non è andata a buon fine sul DB " + advancedDataSource.getProfileName() + ". Controllare il log per ulteriori dettagli.",
|
||||||
|
e, new Date());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("MigrationService - Mail", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isAnyMigrationFailed() {
|
||||||
|
for (String profileDb : migrationsErrorMapByProfiles.keySet())
|
||||||
|
if (migrationsErrorMapByProfiles.get(profileDb)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package it.integry.ems.migration._base;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.settings.SettingsController;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems_model.entity.StbGestSetup;
|
||||||
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.web.context.ContextLoader;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
protected AdvancedDataSource advancedDataSource;
|
||||||
|
protected SettingsController settingsController;
|
||||||
|
protected SettingsModel settingsModel;
|
||||||
|
protected DroolsDataCompleting droolsDataCompleting;
|
||||||
|
|
||||||
|
protected final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(AdvancedDataSource advancedDataSource, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
|
||||||
|
this.advancedDataSource = advancedDataSource;
|
||||||
|
this.settingsController = settingsController;
|
||||||
|
this.settingsModel = settingsModel;
|
||||||
|
this.droolsDataCompleting = droolsDataCompleting;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <R> R getContextBean(Class<R> clazz) {
|
||||||
|
TypeReference<R> type = new TypeReference<R>() {
|
||||||
|
};
|
||||||
|
return ContextLoader.getCurrentWebApplicationContext().getBean(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isHistoryDB() throws Exception {
|
||||||
|
String historyProfileDB = settingsController.getHistoryProfileDb();
|
||||||
|
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDebug() throws Exception {
|
||||||
|
return UtilityDebug.isDebugExecution();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void executeStatement(Connection connection, String... sqls) throws SQLException {
|
||||||
|
Statement statement = connection.createStatement();
|
||||||
|
|
||||||
|
for (String sql : sqls) {
|
||||||
|
statement.execute(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean existsColumn(Connection connection, String tableName, String columnName) throws SQLException {
|
||||||
|
String sql = Query.format("SELECT 1 FROM sys.columns\n" +
|
||||||
|
" WHERE Name = N{}\n" +
|
||||||
|
" AND Object_ID = Object_ID(N{})", columnName, "dbo." + tableName);
|
||||||
|
|
||||||
|
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
|
return val != null && val == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renameColumn(Connection connection, String tableName, String oldColumnname, String newColumnName) throws SQLException {
|
||||||
|
String sql = "exec sp_rename 'dbo." + tableName + "." + oldColumnname + "', " + newColumnName + ", 'COLUMN'";
|
||||||
|
executeStatement(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean existsTable(Connection connection, String tableName) throws SQLException {
|
||||||
|
String sql = Query.format("SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N%s", tableName);
|
||||||
|
|
||||||
|
return UtilityDB.<Boolean>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected long executeInsertStatement(Connection connection, String sql) throws SQLException {
|
||||||
|
long generatedId = -1;
|
||||||
|
|
||||||
|
try (PreparedStatement pstmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) {
|
||||||
|
|
||||||
|
int affectedRows = pstmt.executeUpdate();
|
||||||
|
|
||||||
|
if (affectedRows > 0) {
|
||||||
|
// get the ID back
|
||||||
|
try (ResultSet rs = pstmt.getGeneratedKeys()) {
|
||||||
|
if (rs.next()) {
|
||||||
|
generatedId = rs.getLong(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return generatedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateFunction(Connection connection, String sql) throws SQLException {
|
||||||
|
executeStatement(connection, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dropTable(Connection connection, String tableName) throws SQLException {
|
||||||
|
String dropSql = "DROP TABLE " + tableName;
|
||||||
|
executeStatement(connection, dropSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void createSetup(Connection connection, String gestName, String section, String keySection, String value, String description, String codQuery) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection)
|
||||||
|
.setValue(value)
|
||||||
|
.setDescription(description)
|
||||||
|
.setQueryDefault(codQuery);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected void deleteSetup(Connection connection, 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 updateSetupValue(Connection connection, String gestName, String section, String keySection, String newValue) throws Exception {
|
||||||
|
StbGestSetup stbGestSetup = new StbGestSetup()
|
||||||
|
.setGestName(gestName)
|
||||||
|
.setSection(section)
|
||||||
|
.setKeySection(keySection)
|
||||||
|
.setValue(newValue);
|
||||||
|
|
||||||
|
stbGestSetup.setOperation(OperationType.UPDATE);
|
||||||
|
stbGestSetup.manageWithParentConnection(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAutomatedOperation(BaseScheduledOperationDTO operation) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(120 * 1000);
|
||||||
|
|
||||||
|
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
||||||
|
automatedOperationHandlerComponent.add(operation);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAutomatedOperations(List<? extends BaseScheduledOperationDTO> operations) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(120 * 1000);
|
||||||
|
|
||||||
|
AutomatedOperationHandlerComponent automatedOperationHandlerComponent = ContextLoader.getCurrentWebApplicationContext().getBean(AutomatedOperationHandlerComponent.class);
|
||||||
|
for (BaseScheduledOperationDTO operation : operations)
|
||||||
|
automatedOperationHandlerComponent.add(operation);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package it.integry.ems.migration.model._base;
|
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.AdvancedDataSource;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
|
|
||||||
public interface MigrationModelInterface {
|
public interface MigrationModelInterface {
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package it.integry.ems.migration.controller;
|
||||||
|
|
||||||
|
import it.integry.ems.migration.service.MigrationSetupService;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope(value = "request")
|
||||||
|
@RequestMapping("system/migration/setup")
|
||||||
|
public class MigrationSetupController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MigrationSetupService migrationSetupService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody ServiceRestResponse retrieveList() throws Exception {
|
||||||
|
return ServiceRestResponse.createPositiveResponse(migrationSetupService.retrieveAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "executeAll", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody ServiceRestResponse executeAll() throws Exception {
|
||||||
|
migrationSetupService.executeAll();
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "{migrationCode}/retry", method = RequestMethod.POST)
|
||||||
|
public @ResponseBody ServiceRestResponse retryMigration(@PathVariable long migrationCode) throws Exception {
|
||||||
|
migrationSetupService.retry(migrationCode);
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "{migrationCode}/skip", method = RequestMethod.POST)
|
||||||
|
public @ResponseBody ServiceRestResponse skipMigration(@PathVariable long migrationCode) throws Exception {
|
||||||
|
migrationSetupService.skip(migrationCode);
|
||||||
|
return ServiceRestResponse.createPositiveResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package it.integry.ems.migration.dto;
|
||||||
|
|
||||||
|
public class MigrationStatusDTO {
|
||||||
|
|
||||||
|
private long migrationCode;
|
||||||
|
private String profileDb;
|
||||||
|
private MigrationStatusEnum status;
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
public long getMigrationCode() {
|
||||||
|
return migrationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MigrationStatusDTO setMigrationCode(long migrationCode) {
|
||||||
|
this.migrationCode = migrationCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfileDb() {
|
||||||
|
return profileDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MigrationStatusDTO setProfileDb(String profileDb) {
|
||||||
|
this.profileDb = profileDb;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MigrationStatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MigrationStatusDTO setStatus(MigrationStatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MigrationStatusDTO setErrorMessage(String errorMessage) {
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package it.integry.ems.migration.dto;
|
||||||
|
|
||||||
|
public enum MigrationStatusEnum {
|
||||||
|
|
||||||
|
COMPLETED(0),
|
||||||
|
PENDING(1),
|
||||||
|
SKIPPED(2),
|
||||||
|
ERROR(3);
|
||||||
|
|
||||||
|
|
||||||
|
private int tipo;
|
||||||
|
|
||||||
|
MigrationStatusEnum(int tipo) {
|
||||||
|
this.tipo = tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MigrationStatusEnum fromString(String text) {
|
||||||
|
for (MigrationStatusEnum b : MigrationStatusEnum.values()) {
|
||||||
|
if (b.tipo == Integer.parseInt(text)) return b;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTipo() {
|
||||||
|
return this.tipo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import com.annimon.stream.Optional;
|
import com.annimon.stream.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.entity.StbUser;
|
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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
||||||
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
import org.springframework.web.context.ContextLoader;
|
import org.springframework.web.context.ContextLoader;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._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_model.entity.GrlAnagJrept;
|
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||||
import it.integry.ems_model.entity.MtbDepo;
|
import it.integry.ems_model.entity.MtbDepo;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.entity.StbUser;
|
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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.settings.Model.MailConfigurationModel;
|
import it.integry.ems.settings.Model.MailConfigurationModel;
|
||||||
import it.integry.ems_model.entity.StbEmail;
|
import it.integry.ems_model.entity.StbEmail;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._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_model.entity.GrlAnagJrept;
|
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||||
import it.integry.ems_model.entity.MtbDepo;
|
import it.integry.ems_model.entity.MtbDepo;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package it.integry.ems.migration.model;
|
|||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import io.jsonwebtoken.io.Encoders;
|
import io.jsonwebtoken.io.Encoders;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import io.jsonwebtoken.security.Keys;
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.entity.Azienda;
|
import it.integry.ems_model.entity.Azienda;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
public class Migration_20221128132717 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20221128132717 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
public class Migration_20230406164731 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20230406164731 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.media.MimeTypesHandler;
|
import it.integry.ems.media.MimeTypesHandler;
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
public class Migration_20230414183851 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20230414183851 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.utility.UtilityDirs;
|
import it.integry.ems.utility.UtilityDirs;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
public class Migration_20230419161529 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20230419161529 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
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.dto.IndexTableDTO;
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
|
||||||
public class Migration_20231130152938 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20231130152938 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package it.integry.ems.migration.model;
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Migration_20231201094005 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20231201094005 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package it.integry.ems.migration.model;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import it.integry.ems.migration.model._base.BaseMigration;
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
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 javax.json.Json;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Migration_20231201161808 extends BaseMigration implements MigrationModelInterface {
|
public class Migration_20231201161808 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.service.SetupGest;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240125114347 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetupGest setupGest = getContextBean(SetupGest.class);
|
||||||
|
|
||||||
|
final String gestName = "PICKING";
|
||||||
|
final String section = "LOGISTICA";
|
||||||
|
final String keySection = "COD_DTIP_DOC_TRASF_INTERNI";
|
||||||
|
String jsonString = setupGest.getSetup(advancedDataSource.getConnection(), gestName, section, keySection);
|
||||||
|
|
||||||
|
if (UtilityString.isNullOrEmpty(jsonString))
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> queries = new ArrayList<>();
|
||||||
|
|
||||||
|
JSONArray jsonArray = new JSONArray(jsonString);
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
String codMdep = jsonArray.getJSONObject(i).getString("codMdep");
|
||||||
|
String codDtip = jsonArray.getJSONObject(i).getString("codDtip");
|
||||||
|
|
||||||
|
queries.add(Query.format("INSERT INTO stb_gest_setup_depo (gest_name, section, key_section, cod_mdep, value) VALUES (%s, %s, %s, %s, %s)",
|
||||||
|
gestName, section, keySection, codMdep, codDtip));
|
||||||
|
}
|
||||||
|
|
||||||
|
queries.add(Query.format("UPDATE stb_gest_setup SET flag_setup_depo = 'S', value = NULL WHERE gest_name = %s AND section = %s AND key_section = %s",
|
||||||
|
gestName, section, keySection));
|
||||||
|
|
||||||
|
for (String query : queries) {
|
||||||
|
System.out.println(query);
|
||||||
|
executeStatement(advancedDataSource.getConnection(), query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
|
public class Migration_20240201160125 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String existsCheckSql = "SELECT CAST(COUNT(*) AS BIT) AS exist FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'stb_migration_status'";
|
||||||
|
boolean exists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), existsCheckSql);
|
||||||
|
|
||||||
|
if(exists)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String createTable = "CREATE TABLE dbo.stb_migration_status\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY,\n" +
|
||||||
|
" migration_code BIGINT NOT NULL,\n" +
|
||||||
|
" error_message VARCHAR(MAX),\n" +
|
||||||
|
" completed BIT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" skipped BIT DEFAULT 0 NOT NULL\n" +
|
||||||
|
")";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), createTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240205105025 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
updateFunction(advancedDataSource.getConnection(), "ALTER FUNCTION [dbo].[f_getEAN128UL](@gestione VARCHAR(1), @dataCollo DATETIME, @serCollo VARCHAR(2), @numCollo int, @customPrefissoEan VARCHAR(7))\n" +
|
||||||
|
" RETURNS TABLE AS\n" +
|
||||||
|
" RETURN\n" +
|
||||||
|
"\n" +
|
||||||
|
"-- DECLARE @gestione AS VARCHAR(1) = 'L'\n" +
|
||||||
|
"-- DECLARE @serCollo AS VARCHAR(10) = '/'\n" +
|
||||||
|
"-- DECLARE @numCollo AS INT = 4427\n" +
|
||||||
|
"-- DECLARE @dataCollo AS DATETIME = '2024-02-05';\n" +
|
||||||
|
"-- DECLARE @customPrefissoEan AS VARCHAR(7);-- = '8017596';\n" +
|
||||||
|
"\n" +
|
||||||
|
"WITH barcodes AS (\n" +
|
||||||
|
" SELECT CONCAT(CASE WHEN @customPrefissoEan IS NULL THEN azienda.prefisso_ean ELSE @customPrefissoEan END,\n" +
|
||||||
|
" CAST(CAST(mtb_colt.num_collo / 100000 AS INT) AS varchar),\n" +
|
||||||
|
" CASE mtb_colt.gestione\n" +
|
||||||
|
" WHEN 'A' THEN '1'\n" +
|
||||||
|
" WHEN 'L' THEN '2'\n" +
|
||||||
|
" WHEN 'V' THEN '3' END,\n" +
|
||||||
|
" RIGHT(CAST(DATEPART(YEAR, mtb_colt.data_collo) AS varchar), 2),\n" +
|
||||||
|
" RIGHT(FORMAT(mtb_colt.num_collo, REPLICATE('0', 5)), 5)) AS AI_00,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_aart.cod_barre_imb IS NOT NULL AND LEN(mtb_aart.cod_barre_imb) < 14 THEN\n" +
|
||||||
|
" FORMAT(CONVERT(NUMERIC, ISNULL(NULLIF(mtb_aart.cod_barre_imb, ''), '0')), REPLICATE('0', 13))\n" +
|
||||||
|
" ELSE mtb_aart.cod_barre_imb\n" +
|
||||||
|
" END AS AI_01,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_aart.bar_code IS NOT NULL AND LEN(mtb_aart.bar_code) < 14\n" +
|
||||||
|
" THEN\n" +
|
||||||
|
" FORMAT(CONVERT(BIGINT, mtb_aart.bar_code), REPLICATE('0', 14))\n" +
|
||||||
|
" ELSE mtb_aart.bar_code\n" +
|
||||||
|
" END AS AI_02,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_colr.partita_mag IS NOT NULL THEN\n" +
|
||||||
|
" mtb_colr.partita_mag + CHAR(29)\n" +
|
||||||
|
" END AS AI_10,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN mtb_partita_mag.data_scad IS NOT NULL THEN\n" +
|
||||||
|
" REPLACE(CONVERT(varchar(10), mtb_partita_mag.data_scad, 2), '.', '')\n" +
|
||||||
|
" END AS AI_15,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 6 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000000'), '.', '')\n" +
|
||||||
|
" END AS AI_3100,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 5 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00000.0'), '.', '')\n" +
|
||||||
|
" END AS AI_3101,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 4 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0000.00'), '.', '')\n" +
|
||||||
|
" END AS AI_3102,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 3 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '000.000'), '.', '')\n" +
|
||||||
|
" END AS AI_3103,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 2 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '00.0000'), '.', '')\n" +
|
||||||
|
" END AS AI_3104,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_aart.peso_kg * mtb_colr.qta_cnf AS INTEGER)) <= 1 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_aart.peso_kg * mtb_colr.qta_cnf, '0.00000'), '.', '')\n" +
|
||||||
|
" END AS AI_3105,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 6 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '000000'), '.', '')\n" +
|
||||||
|
" END AS AI_3300,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 5 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '00000.0'), '.', '')\n" +
|
||||||
|
" END AS AI_3301,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 4 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '0000.00'), '.', '')\n" +
|
||||||
|
" END AS AI_3302,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 3 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '000.000'), '.', '')\n" +
|
||||||
|
" END AS AI_3303,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 2 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '00.0000'), '.', '')\n" +
|
||||||
|
" END AS AI_3304,\n" +
|
||||||
|
" CASE\n" +
|
||||||
|
" WHEN LEN(CAST(mtb_colt.peso_kg AS INTEGER)) <= 1 THEN\n" +
|
||||||
|
" REPLACE(FORMAT(mtb_colt.peso_kg, '0.00000'), '.', '')\n" +
|
||||||
|
" END AS AI_3305,\n" +
|
||||||
|
" CONVERT(varchar, CONVERT(integer, SUM(mtb_colr.qta_col / mtb_colr.qta_cnf))) AS AI_37\n" +
|
||||||
|
" FROM mtb_colt\n" +
|
||||||
|
" INNER JOIN mtb_colr\n" +
|
||||||
|
" ON mtb_colt.gestione = mtb_colr.gestione and mtb_colt.data_collo = mtb_colr.data_collo and\n" +
|
||||||
|
" mtb_colt.ser_collo = mtb_colr.ser_collo and mtb_colt.num_collo = mtb_colr.num_collo\n" +
|
||||||
|
" INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart\n" +
|
||||||
|
" LEFT outer JOIN mtb_partita_mag ON mtb_colr.cod_mart = mtb_partita_mag.cod_mart AND\n" +
|
||||||
|
" mtb_colr.partita_mag = mtb_partita_mag.partita_mag,\n" +
|
||||||
|
" azienda\n" +
|
||||||
|
" WHERE mtb_colt.gestione = @gestione\n" +
|
||||||
|
" AND mtb_colt.data_collo = @dataCollo\n" +
|
||||||
|
" AND mtb_colt.ser_collo = @serCollo\n" +
|
||||||
|
" AND mtb_colt.num_collo = @numCollo\n" +
|
||||||
|
" GROUP BY mtb_colr.qta_col,\n" +
|
||||||
|
" mtb_colr.qta_cnf,\n" +
|
||||||
|
" mtb_colt.data_vers,\n" +
|
||||||
|
" nome_ditta,\n" +
|
||||||
|
" azienda.indirizzo,\n" +
|
||||||
|
" azienda.cap,\n" +
|
||||||
|
" azienda.citta,\n" +
|
||||||
|
" azienda.prov,\n" +
|
||||||
|
" prefisso_ean,\n" +
|
||||||
|
" mtb_colt.data_collo,\n" +
|
||||||
|
" mtb_colt.num_collo,\n" +
|
||||||
|
" mtb_aart.cod_barre_imb,\n" +
|
||||||
|
" mtb_aart.bar_code,\n" +
|
||||||
|
" mtb_aart.descrizione_estesa,\n" +
|
||||||
|
" mtb_colr.partita_mag,\n" +
|
||||||
|
" mtb_partita_mag.data_scad,\n" +
|
||||||
|
" mtb_colt.peso_netto_kg,\n" +
|
||||||
|
" mtb_colr.cod_mart, \n" +
|
||||||
|
"\t\t\t mtb_colt.gestione,\n" +
|
||||||
|
"\t\t\t mtb_colt.peso_kg,\n" +
|
||||||
|
"\t\t\t mtb_aart.peso_kg\n" +
|
||||||
|
"),\n" +
|
||||||
|
" appoggio AS (\n" +
|
||||||
|
" SELECT CONCAT(\n" +
|
||||||
|
" REPLICATE('0', 17 - LEN(AI_00)),\n" +
|
||||||
|
" AI_00) AS AI_00,\n" +
|
||||||
|
" CASE WHEN AI_01 IS NOT NULL AND LEN(AI_01) = 13 THEN CONCAT(AI_01, dbo.getCheckDigitITF14(AI_01)) ELSE AI_01 END AS AI_01,\n" +
|
||||||
|
" AI_02,\n" +
|
||||||
|
" AI_10,\n" +
|
||||||
|
" AI_15,\n" +
|
||||||
|
" AI_3100,\n" +
|
||||||
|
" AI_3101,\n" +
|
||||||
|
" AI_3102,\n" +
|
||||||
|
" AI_3103,\n" +
|
||||||
|
" AI_3104,\n" +
|
||||||
|
" AI_3105,\n" +
|
||||||
|
" AI_3300,\n" +
|
||||||
|
" AI_3301,\n" +
|
||||||
|
" AI_3302,\n" +
|
||||||
|
" AI_3303,\n" +
|
||||||
|
" AI_3304,\n" +
|
||||||
|
" AI_3305,\n" +
|
||||||
|
" AI_37\n" +
|
||||||
|
" FROM barcodes\n" +
|
||||||
|
" )\n" +
|
||||||
|
"SELECT CONCAT(AI_00,\n" +
|
||||||
|
" dbo.getCheckDigitSSCC(AI_00)) AS AI_00,\n" +
|
||||||
|
" AI_01,\n" +
|
||||||
|
" AI_02,\n" +
|
||||||
|
" AI_10,\n" +
|
||||||
|
" AI_15,\n" +
|
||||||
|
" AI_3100,\n" +
|
||||||
|
" AI_3101,\n" +
|
||||||
|
" AI_3102,\n" +
|
||||||
|
" AI_3103,\n" +
|
||||||
|
" AI_3104,\n" +
|
||||||
|
" AI_3105,\n" +
|
||||||
|
" AI_3300,\n" +
|
||||||
|
" AI_3301,\n" +
|
||||||
|
" AI_3302,\n" +
|
||||||
|
" AI_3303,\n" +
|
||||||
|
" AI_3304,\n" +
|
||||||
|
" AI_3305,\n" +
|
||||||
|
" AI_37\n" +
|
||||||
|
"FROM appoggio");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityHashMap;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240212000000 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "SELECT * FROM stb_publications";
|
||||||
|
final List<HashMap<String, Object>> oldStbPublications = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
||||||
|
|
||||||
|
sql = "SELECT * FROM stb_publications_detail";
|
||||||
|
final List<HashMap<String, Object>> oldStbPublicationsDetails = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
||||||
|
|
||||||
|
dropOldTables(advancedDataSource.getConnection());
|
||||||
|
createNewTables(advancedDataSource.getConnection());
|
||||||
|
|
||||||
|
|
||||||
|
for (HashMap<String, Object> oldStbPublication : oldStbPublications) {
|
||||||
|
String publicationDescription = UtilityHashMap.getValueIfExists(oldStbPublication, "publication_description");
|
||||||
|
|
||||||
|
String insertSql = Query.format("INSERT INTO stb_publications (publication_description) VALUES (%s)", publicationDescription);
|
||||||
|
long generatedId = executeInsertStatement(advancedDataSource.getConnection(), insertSql);
|
||||||
|
oldStbPublication.putIfAbsent("id", generatedId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (HashMap<String, Object> oldStbPublicationDetail : oldStbPublicationsDetails) {
|
||||||
|
String active = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "syncronize");
|
||||||
|
String oldId = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "publication_id");
|
||||||
|
String entityName = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "entity_name");
|
||||||
|
String whereCondSql = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "where_cond_sql");
|
||||||
|
String recalcColumns = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "recalc_columns");
|
||||||
|
String whereCond = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "where_cond");
|
||||||
|
|
||||||
|
Long newParentId = getNewGeneratedIdFromOldKey(oldId, oldStbPublications);
|
||||||
|
|
||||||
|
String insertSql = Query.format("INSERT INTO stb_publications_detail " +
|
||||||
|
"(stb_publication_id, entity_name, where_cond_sql, recalc_columns, active, where_cond, ready_to_transmit) " +
|
||||||
|
"VALUES (%s, %s, %s, %s, %s, %s, %s)",
|
||||||
|
newParentId,
|
||||||
|
entityName,
|
||||||
|
whereCondSql,
|
||||||
|
recalcColumns,
|
||||||
|
active.equalsIgnoreCase("S") || active.equalsIgnoreCase("R"),
|
||||||
|
whereCond,
|
||||||
|
true);
|
||||||
|
long generatedId = executeInsertStatement(advancedDataSource.getConnection(), insertSql);
|
||||||
|
oldStbPublicationDetail.putIfAbsent("id", generatedId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void dropOldTables(@NotNull Connection connection) throws SQLException {
|
||||||
|
dropTable(connection, "stb_publications_detail");
|
||||||
|
dropTable(connection, "stb_publications");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createNewTables(@NotNull Connection connection) throws SQLException {
|
||||||
|
String createSql = "CREATE TABLE dbo.stb_publications\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY,\n" +
|
||||||
|
" publication_description VARCHAR(1024) NOT NULL\n" +
|
||||||
|
")";
|
||||||
|
executeStatement(connection, createSql);
|
||||||
|
|
||||||
|
createSql = "CREATE UNIQUE CLUSTERED INDEX stb_publications_id_uindex\n" +
|
||||||
|
" ON dbo.stb_publications (id)";
|
||||||
|
executeStatement(connection, createSql);
|
||||||
|
|
||||||
|
createSql = "CREATE TABLE dbo.stb_publications_detail\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT stb_publications_detail_pk\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" stb_publication_id BIGINT NOT NULL\n" +
|
||||||
|
" CONSTRAINT stb_publications_detail_stb_publications_id_fk\n" +
|
||||||
|
" REFERENCES dbo.stb_publications (id),\n" +
|
||||||
|
" entity_name VARCHAR(40) NOT NULL,\n" +
|
||||||
|
" active BIT DEFAULT 1 NOT NULL,\n" +
|
||||||
|
" ready_to_transmit BIT DEFAULT 0 NOT NULL,\n" +
|
||||||
|
" where_cond_sql VARCHAR(MAX),\n" +
|
||||||
|
" recalc_columns VARCHAR(MAX),\n" +
|
||||||
|
" where_cond VARCHAR(MAX)" +
|
||||||
|
")";
|
||||||
|
executeStatement(connection, createSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getNewGeneratedIdFromOldKey(String oldKey, List<HashMap<String, Object>> oldList) {
|
||||||
|
return oldList.stream()
|
||||||
|
.filter(x -> ((String) x.getOrDefault("publication_id", "")).equalsIgnoreCase(oldKey))
|
||||||
|
.map(x -> (long) x.getOrDefault("id", -1))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240212000001 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!existsTable(advancedDataSource.getConnection(), "stb_transaction_log_db"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_transaction_log_db");
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_transaction_log");
|
||||||
|
|
||||||
|
String createTransactionTableSql = "\n" +
|
||||||
|
"CREATE TABLE dbo.stb_transaction_log\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT stb_transaction_log_pk\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" publication_group_id BIGINT NOT NULL,\n" +
|
||||||
|
" created_at DATETIME DEFAULT GETDATE() NOT NULL,\n" +
|
||||||
|
" user_name VARCHAR(40),\n" +
|
||||||
|
" entities VARCHAR(MAX),\n" +
|
||||||
|
" entities_json VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" group_id BIGINT NOT NULL\n" +
|
||||||
|
")";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), createTransactionTableSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240212000002 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "ALTER TABLE dbo.stb_publications_detail\n" +
|
||||||
|
" ADD export_history BIT DEFAULT 0 NOT NULL";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240219094933 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "ALTER TABLE mtb_colt\n" +
|
||||||
|
" ADD barcode_ul VARCHAR(20)";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240219103840 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"PICKING", "ACCETTAZIONE", "FLAG_ALLOW_BARCODE_FORNITORE", "N",
|
||||||
|
"Abilita la possibilità di effettuare l'accettazione merci utilizzando direttamente l'SSCC del fornitore (salvato poi nella colonna barcode_pedana)",
|
||||||
|
"SI_NO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240220114903 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql = "EXEC DropDefault 'mtb_colr', 'causale';\n" +
|
||||||
|
"ALTER TABLE mtb_colr\n" +
|
||||||
|
" ALTER COLUMN causale TINYINT NOT NULL;\n" +
|
||||||
|
"ALTER TABLE mtb_colr\n" +
|
||||||
|
" ADD DEFAULT 0 FOR causale;";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240221190821 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"DATI_AZIENDA", "SETUP", "FLAG_ANSI_PADDING", "N",
|
||||||
|
"Abilita l'ansi padding nella connessione del gestionale. Il valore suggerito è ON (prima era OFF).",
|
||||||
|
"SI_NO");
|
||||||
|
|
||||||
|
createSetup(advancedDataSource.getConnection(),
|
||||||
|
"DATI_AZIENDA", "SETUP", "FLAG_CONCAT_NULL_YIELDS_NULL", "N",
|
||||||
|
"Abilita il concat null yields null nella connessione del gestionale. Il valore suggerito è ON (prima era OFF).",
|
||||||
|
"SI_NO");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240228160024 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_subscriptions_user_detail");
|
||||||
|
dropTable(advancedDataSource.getConnection(), "stb_subscriptions_user");
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(),
|
||||||
|
|
||||||
|
"CREATE TABLE dbo.stb_remote_subscription\n" +
|
||||||
|
"(\n" +
|
||||||
|
" id BIGINT IDENTITY\n" +
|
||||||
|
" CONSTRAINT stb_remote_subscription_pk\n" +
|
||||||
|
" PRIMARY KEY,\n" +
|
||||||
|
" publication_id BIGINT NOT NULL,\n" +
|
||||||
|
" publication_description VARCHAR(MAX),\n" +
|
||||||
|
" endpoint_protocol VARCHAR(5) DEFAULT 'HTTP' NOT NULL,\n" +
|
||||||
|
" endpoint_host VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" endpoint_port INT DEFAULT 80 NOT NULL,\n" +
|
||||||
|
" username VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" password VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" profile_db VARCHAR(MAX) NOT NULL,\n" +
|
||||||
|
" last_transaction_id BIGINT,\n" +
|
||||||
|
" last_transaction_id_imported BIGINT,\n" +
|
||||||
|
" active BIT DEFAULT 0 NOT NULL\n" +
|
||||||
|
")",
|
||||||
|
|
||||||
|
"EXEC sp_addextendedproperty 'MS_Description', 'HTTP or HTTPS', 'SCHEMA', 'dbo', 'TABLE', 'stb_remote_subscription',\n" +
|
||||||
|
" 'COLUMN', 'endpoint_protocol'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
|
||||||
|
public class Migration_20240304165725 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (advancedDataSource.getProfileName().equalsIgnoreCase("carelli") ||
|
||||||
|
advancedDataSource.getProfileName().equalsIgnoreCase("gestfood") ||
|
||||||
|
advancedDataSource.getProfileName().equalsIgnoreCase("panimal")) {
|
||||||
|
|
||||||
|
String sql = "UPDATE carelli_giacenza_prog\n" +
|
||||||
|
"SET tipo_car = 'R'\n" +
|
||||||
|
"WHERE tipo_car = 'C'";
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ExportAutomatedOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.service.AutomatedOperationHandlerComponent;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240307103608 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> elencoDb = new ArrayList<String>() {{
|
||||||
|
add("CARELLI");
|
||||||
|
add("GESTFOOD");
|
||||||
|
add("PANIMAL");
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(advancedDataSource.getDataSource().getDbName())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String sql =
|
||||||
|
"SELECT UPPER(stb_user.user_name) AS user_name,\n" +
|
||||||
|
" dbo.sys_dcd_pss(stb_user.password) AS password,\n" +
|
||||||
|
" mtb_depo.cod_mdep\n" +
|
||||||
|
"FROM stb_user\n" +
|
||||||
|
" INNER JOIN wtb_depo ON stb_user.user_name = wtb_depo.user_name\n" +
|
||||||
|
" INNER JOIN mtb_depo ON wtb_depo.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||||
|
" INNER JOIN wtb_users_info\n" +
|
||||||
|
" ON stb_user.user_name = wtb_users_info.user_name AND wtb_users_info.export_type = 'VARIAZIONE PV'\n" +
|
||||||
|
"WHERE stb_user.flag_attivo = 'S'\n" +
|
||||||
|
" AND mtb_depo.flag_movimentabile = 'S'\n" +
|
||||||
|
" AND wtb_users_info.flag_state = 'S'\n" +
|
||||||
|
" AND stb_user.key_group = '10'";
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> elencoUtenti = UtilityDB.executeSimpleQuery(advancedDataSource.getConnection(), sql);
|
||||||
|
|
||||||
|
List<ExportAutomatedOperationDTO> operations = new ArrayList<>();
|
||||||
|
for (HashMap<String, Object> user : elencoUtenti) {
|
||||||
|
final String operationName = "Invio Variazioni Griglia - " + user.get("cod_mdep");
|
||||||
|
|
||||||
|
|
||||||
|
ExportAutomatedOperationDTO exportAutomatedOperationDTO =
|
||||||
|
new ExportAutomatedOperationDTO()
|
||||||
|
.setFormat("XML_DIALOGO")
|
||||||
|
.setType("VARIAZIONE PV")
|
||||||
|
.setUsername((String) user.get("user_name"))
|
||||||
|
.setPassword((String) user.get("password"))
|
||||||
|
.setJsonRequest("{ \t\"tipoReport\": \"G\" }")
|
||||||
|
.setProfileDb(advancedDataSource.getProfileName());
|
||||||
|
exportAutomatedOperationDTO
|
||||||
|
.setCronTrigger("0 0 22 1/1 * *")
|
||||||
|
.setName(operationName);
|
||||||
|
|
||||||
|
operations.add(exportAutomatedOperationDTO);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
addAutomatedOperations(operations);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Migration_20240307123633 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<String> elencoDb = new ArrayList<String>() {{
|
||||||
|
add("CARELLI");
|
||||||
|
add("GESTFOOD");
|
||||||
|
add("PANIMAL");
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (elencoDb.stream().noneMatch(x -> x.equalsIgnoreCase(advancedDataSource.getDataSource().getDbName())))
|
||||||
|
return;
|
||||||
|
|
||||||
|
executeStatement(advancedDataSource.getConnection(), "UPDATE vtb_promo SET flag_tipo_promo = 'T' WHERE cod_promo like '%TAGLIO%'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package it.integry.ems.migration.model._base;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
|
||||||
import it.integry.ems.settings.Model.SettingsModel;
|
|
||||||
import it.integry.ems.settings.SettingsController;
|
|
||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
|
||||||
import it.integry.ems.utility.UtilityDebug;
|
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
|
||||||
import it.integry.ems_model.utility.Query;
|
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.springframework.web.context.ContextLoader;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
|
|
||||||
public abstract class BaseMigration implements MigrationModelInterface {
|
|
||||||
|
|
||||||
protected AdvancedDataSource advancedDataSource;
|
|
||||||
protected SettingsController settingsController;
|
|
||||||
protected SettingsModel settingsModel;
|
|
||||||
protected DroolsDataCompleting droolsDataCompleting;
|
|
||||||
|
|
||||||
protected final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(AdvancedDataSource advancedDataSource, SettingsController settingsController, SettingsModel settingsModel, DroolsDataCompleting droolsDataCompleting) {
|
|
||||||
this.advancedDataSource = advancedDataSource;
|
|
||||||
this.settingsController = settingsController;
|
|
||||||
this.settingsModel = settingsModel;
|
|
||||||
this.droolsDataCompleting = droolsDataCompleting;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <R>R getContextBean(Class<R> clazz) {
|
|
||||||
TypeReference<R> type = new TypeReference<R>() {};
|
|
||||||
return ContextLoader.getCurrentWebApplicationContext().getBean(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isHistoryDB() throws Exception {
|
|
||||||
String historyProfileDB = settingsController.getHistoryProfileDb();
|
|
||||||
return historyProfileDB.equalsIgnoreCase(advancedDataSource.getProfileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isDebug() throws Exception {
|
|
||||||
return UtilityDebug.isDebugExecution();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void executeStatement(Connection connection, String... sqls) throws SQLException {
|
|
||||||
Statement statement = connection.createStatement();
|
|
||||||
|
|
||||||
for (String sql : sqls) {
|
|
||||||
statement.execute(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean existsColumn(Connection connection, String tableName, String columnName) throws SQLException {
|
|
||||||
String sql = Query.format("SELECT 1 FROM sys.columns\n" +
|
|
||||||
" WHERE Name = N{}\n" +
|
|
||||||
" AND Object_ID = Object_ID(N{})", columnName, "dbo." + tableName);
|
|
||||||
|
|
||||||
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
|
||||||
|
|
||||||
return val != null && val == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package it.integry.ems.migration.service;
|
||||||
|
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
|
import it.integry.ems.migration.MigrationService;
|
||||||
|
import it.integry.ems.migration.dto.MigrationStatusDTO;
|
||||||
|
import it.integry.ems.migration.dto.MigrationStatusEnum;
|
||||||
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
|
import it.integry.ems.settings.Model.SettingsModel;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems_model.entity.StbMigrationStatus;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
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.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Scope("request")
|
||||||
|
public class MigrationSetupService {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingsModel settingsModel;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MigrationService migrationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityProcessor entityProcessor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RequestDataDTO requestDataDTO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
public List<MigrationStatusDTO> retrieveAll() throws Exception {
|
||||||
|
final List<Long> migrationCodes = migrationService.getMigrationCodes();
|
||||||
|
|
||||||
|
final List<MigrationStatusDTO> migrationStatuses = new ArrayList<>();
|
||||||
|
|
||||||
|
final List<AvailableConnectionsModel> databases = settingsModel.getAvailableConnections().stream()
|
||||||
|
.filter(AvailableConnectionsModel::getInternalDb)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (AvailableConnectionsModel availableConnectionsModel : databases) {
|
||||||
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(availableConnectionsModel.getProfileName())) {
|
||||||
|
|
||||||
|
List<StbMigrationStatus> stbMigrationStatuses = retrieveStatuses(multiDBTransactionManager);
|
||||||
|
|
||||||
|
for (long migrationCode : migrationCodes) {
|
||||||
|
StbMigrationStatus stbMigrationStatus = stbMigrationStatuses.stream()
|
||||||
|
.filter(x -> x.getMigrationCode() == migrationCode)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
|
||||||
|
MigrationStatusEnum status = MigrationStatusEnum.PENDING;
|
||||||
|
if (migrationCode < 20240201160125L) //Ignoro le migration che esistono da prima di questo sistema
|
||||||
|
status = MigrationStatusEnum.COMPLETED;
|
||||||
|
|
||||||
|
String errorMessage = null;
|
||||||
|
|
||||||
|
if (stbMigrationStatus != null) {
|
||||||
|
if (stbMigrationStatus.isCompleted()) {
|
||||||
|
if (stbMigrationStatus.isSkipped()) status = MigrationStatusEnum.SKIPPED;
|
||||||
|
else status = MigrationStatusEnum.COMPLETED;
|
||||||
|
} else {
|
||||||
|
status = MigrationStatusEnum.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorMessage = stbMigrationStatus.getErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
migrationStatuses.add(new MigrationStatusDTO()
|
||||||
|
.setStatus(status)
|
||||||
|
.setMigrationCode(migrationCode)
|
||||||
|
.setProfileDb(availableConnectionsModel.getProfileName())
|
||||||
|
.setErrorMessage(errorMessage));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return migrationStatuses;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<StbMigrationStatus> retrieveStatuses(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY;
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbMigrationStatus.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void retry(long migrationCode) throws Exception {
|
||||||
|
migrationService.executeMigrationGroup(multiDBTransactionManager.getActiveConnections().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void skip(long migrationCode) throws Exception {
|
||||||
|
final AdvancedDataSource advancedDataSource = multiDBTransactionManager.getActiveConnections().get(0);
|
||||||
|
|
||||||
|
String sql = "SELECT * FROM " + StbMigrationStatus.ENTITY + " WHERE migration_code = " + migrationCode;
|
||||||
|
StbMigrationStatus stbMigrationStatus = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbMigrationStatus.class);
|
||||||
|
|
||||||
|
|
||||||
|
if (stbMigrationStatus != null) {
|
||||||
|
stbMigrationStatus
|
||||||
|
.setMigrationCode(migrationCode)
|
||||||
|
.setCompleted(true)
|
||||||
|
.setSkipped(true);
|
||||||
|
stbMigrationStatus.setOperation(OperationType.UPDATE);
|
||||||
|
entityProcessor.processEntity(stbMigrationStatus, multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
migrationService.updateLastMigrationIntoDB(advancedDataSource, migrationCode);
|
||||||
|
migrationService.executeMigrationGroup(advancedDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void executeAll() throws Exception {
|
||||||
|
for (AvailableConnectionsModel availableConnectionsModel : settingsModel.getAvailableConnections()) {
|
||||||
|
if (!Stream.of(multiDBTransactionManager.getActiveConnections())
|
||||||
|
.anyMatch(advancedDataSource -> advancedDataSource.getDataSource().getDbName().equalsIgnoreCase(availableConnectionsModel.getDbName()))) {
|
||||||
|
multiDBTransactionManager.addConnection(availableConnectionsModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
migrationService.startMigrationsGlobally(multiDBTransactionManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,6 @@ import it.integry.ems_model.types.OperationType;
|
|||||||
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;
|
||||||
import org.kie.api.runtime.rule.ConsequenceException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
@@ -80,9 +79,6 @@ public class ServiceRestResponse {
|
|||||||
public ServiceRestResponse(EsitoType esito, String profileDb, Exception e) {
|
public ServiceRestResponse(EsitoType esito, String profileDb, Exception e) {
|
||||||
this(esito);
|
this(esito);
|
||||||
|
|
||||||
if (esito == EsitoType.KO)
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
this.profileDB = profileDb;
|
this.profileDB = profileDb;
|
||||||
this.errorType = e.getClass().getCanonicalName();
|
this.errorType = e.getClass().getCanonicalName();
|
||||||
this.errorMessage = e.getMessage();
|
this.errorMessage = e.getMessage();
|
||||||
|
|||||||
@@ -447,31 +447,31 @@ public class AccountingBusinessLogic {
|
|||||||
if (UtilityString.isNullOrEmpty(tipoPartita)) tipoPartita = 1;
|
if (UtilityString.isNullOrEmpty(tipoPartita)) tipoPartita = 1;
|
||||||
|
|
||||||
BigDecimal impScad = ctbScadOrig.getImpDare().subtract(ctbScadOrig.getImpAvere());
|
BigDecimal impScad = ctbScadOrig.getImpDare().subtract(ctbScadOrig.getImpAvere());
|
||||||
Date dataPag = ctbScadOrig.getDataPag();
|
|
||||||
impScad = impScad.abs();
|
impScad = impScad.abs();
|
||||||
|
|
||||||
if (residuo.compareTo(BigDecimal.ZERO) > 0 && dataPag == null) {
|
if (!UtilityBigDecimal.isNullOrZero(residuo) && ctbScadOrig.getDataPag() == null ) {
|
||||||
residuo = residuo.abs();
|
residuo = residuo.abs();
|
||||||
if (residuo.compareTo(impScad) >= 0) {
|
if (UtilityBigDecimal.equalsOrGreaterThan(residuo, impScad)) {
|
||||||
if (residuo.equals(impScad)) {
|
if (UtilityBigDecimal.equalsTo(residuo, impScad)) {
|
||||||
residuo = BigDecimal.ZERO;
|
residuo = BigDecimal.ZERO;
|
||||||
} else {
|
} else {
|
||||||
// il controllo del segno della partita è necessario solo nel caso in cui si passa un importo a copertuta di più scadenze che si possono compensare
|
// il controllo del segno della partita è necessario solo nel caso in cui si passa un importo a copertuta di più scadenze che si possono compensare
|
||||||
// registrazione dei titoli
|
// registrazione dei titoli
|
||||||
if (tipoPartita == 1 || countScad == 1) {
|
if (tipoPartita == TipoPartita.ATTIVA.getValue() || countScad == 1) {
|
||||||
residuo = residuo.subtract(impScad);
|
residuo = residuo.subtract(impScad);
|
||||||
} else if (tipoPartita == 0) {
|
} else if (tipoPartita == 0) {
|
||||||
residuo = residuo.add(impScad);
|
residuo = residuo.add(impScad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctbScadOrig.getImpDare().compareTo(BigDecimal.ZERO) > 0) {
|
if (!UtilityBigDecimal.isNullOrZero(ctbScadOrig.getImpDare())) {
|
||||||
ctbScadOrig.setImpAvere(impScad);
|
ctbScadOrig.setImpAvere(impScad);
|
||||||
} else {
|
} else {
|
||||||
ctbScadOrig.setImpDare(impScad);
|
ctbScadOrig.setImpDare(impScad);
|
||||||
}
|
}
|
||||||
ctbScadOrig.setDataPag(dataCmov);
|
ctbScadOrig.setDataPag(dataCmov);
|
||||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||||
|
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
} else {
|
} else {
|
||||||
//Clona scadenza
|
//Clona scadenza
|
||||||
CtbScad ctbScadNew = (CtbScad) ctbScadOrig.clone();
|
CtbScad ctbScadNew = (CtbScad) ctbScadOrig.clone();
|
||||||
@@ -481,6 +481,7 @@ public class AccountingBusinessLogic {
|
|||||||
ctbScadOrig.setImpAvere(residuo);
|
ctbScadOrig.setImpAvere(residuo);
|
||||||
ctbScadOrig.setDataPag(dataCmov);
|
ctbScadOrig.setDataPag(dataCmov);
|
||||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||||
|
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
|
|
||||||
// calcola importo residuo della nuova scadenza
|
// calcola importo residuo della nuova scadenza
|
||||||
residuo = residuo.subtract(impScad);
|
residuo = residuo.subtract(impScad);
|
||||||
@@ -494,6 +495,7 @@ public class AccountingBusinessLogic {
|
|||||||
} else {
|
} else {
|
||||||
ctbScadNew.setImpAvere(residuo.abs());
|
ctbScadNew.setImpAvere(residuo.abs());
|
||||||
}
|
}
|
||||||
|
residuo = BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elencoScadenzeNew.add(ctbScadOrig);
|
elencoScadenzeNew.add(ctbScadOrig);
|
||||||
|
|||||||
@@ -647,12 +647,14 @@ public class DocumentBusinessLogic {
|
|||||||
}
|
}
|
||||||
//RIGHE COSTI
|
//RIGHE COSTI
|
||||||
if (!isAutofattura) {
|
if (!isAutofattura) {
|
||||||
if (dtbDoct.getGestione().equalsIgnoreCase("A")) {
|
if (dtbDoct.getGestione().equalsIgnoreCase("A") &&
|
||||||
|
!UtilityString.isNullOrEmpty(codCconDocAp) && dtbDoct.getGestione().equalsIgnoreCase("A")) {
|
||||||
listaCosti = Stream.of(listaCosti)
|
listaCosti = Stream.of(listaCosti)
|
||||||
.filter(value -> !value.getCostoAP())
|
.filter(value -> !value.getCostoAP()).toList();
|
||||||
.sorted((o1, o2) -> o1.getCodCcon().compareTo(o2.getCodCcon())).toList();
|
|
||||||
}
|
}
|
||||||
//listaCosti = Coollection.from(listaCosti).orderBy("dataInizComp").orderBy("codCcon").all();
|
listaCosti = Stream.of(listaCosti)
|
||||||
|
.sorted(Comparator.comparing(CostiDTO::getCodCcon)).toList();
|
||||||
|
|
||||||
String codCconCosto, codCconCostoOld = "";
|
String codCconCosto, codCconCostoOld = "";
|
||||||
List<CtbMovrCoan> costiCoan = null;
|
List<CtbMovrCoan> costiCoan = null;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.sql.ResultSet;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Scope("request")
|
@Scope("request")
|
||||||
public class LoadColliService {
|
public class LoadColliService {
|
||||||
@@ -262,6 +264,16 @@ public class LoadColliService {
|
|||||||
dtbDoct.setMtbColt(mtbColt);
|
dtbDoct.setMtbColt(mtbColt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acquisizione ID_LOTTO del primo collo da agganciare
|
||||||
|
if (loadDatiFromDB) {
|
||||||
|
query = "SELECT TOP 1 id_lotto FROM mtb_colt ";
|
||||||
|
query = UtilityDB.addwhereCond(query, whereCond, false);
|
||||||
|
Integer idLotto = (Integer) getSingleValue(multiDBTransactionManager.getPrimaryConnection(), query);
|
||||||
|
if (idLotto != null){
|
||||||
|
dtbDoct.setIdLotto(idLotto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Stream.of(loadColli.getColli()).forEach(x -> x.setUpdateColliFromDoc(true));
|
Stream.of(loadColli.getColli()).forEach(x -> x.setUpdateColliFromDoc(true));
|
||||||
|
|
||||||
//AGGIUNGERE CAMPI CHE PASSIAMO DA FUORI
|
//AGGIUNGERE CAMPI CHE PASSIAMO DA FUORI
|
||||||
@@ -585,7 +597,8 @@ public class LoadColliService {
|
|||||||
" dtb_ordr.cod_promo as 'cod_promo', " +
|
" dtb_ordr.cod_promo as 'cod_promo', " +
|
||||||
" dtb_ordr.cod_art_for as 'cod_art_for', " +
|
" dtb_ordr.cod_art_for as 'cod_art_for', " +
|
||||||
" mvw_kit.flag_kit as 'articolo_composto', " +
|
" mvw_kit.flag_kit as 'articolo_composto', " +
|
||||||
" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom) as 'cod_jcom', " +
|
/*" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom) as 'cod_jcom', " +*/
|
||||||
|
" dtb_ordr.cod_jcom as 'cod_jcom', " +
|
||||||
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2) as 'unt_doc2', " +
|
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2) as 'unt_doc2', " +
|
||||||
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3) as 'unt_doc3', " +
|
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3) as 'unt_doc3', " +
|
||||||
" mtb_aart.tara_kg as 'tara_kg', " +
|
" mtb_aart.tara_kg as 'tara_kg', " +
|
||||||
@@ -652,7 +665,8 @@ public class LoadColliService {
|
|||||||
" mtb_aart.flag_stato, " +
|
" mtb_aart.flag_stato, " +
|
||||||
" dtb_ordr.cod_art_for, " +
|
" dtb_ordr.cod_art_for, " +
|
||||||
" mvw_kit.flag_kit, " +
|
" mvw_kit.flag_kit, " +
|
||||||
" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom), " +
|
/*" IsNull(mvw_colr_sum.cod_jcom, dtb_ordr.cod_jcom), " +*/
|
||||||
|
" dtb_ordr.cod_jcom, " +
|
||||||
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2), " +
|
" IsNull(dtb_ordr.unt_ord2, mtb_aart.unt_mis2), " +
|
||||||
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3), " +
|
" IsNull(dtb_ordr.unt_ord3, mtb_aart.unt_mis3), " +
|
||||||
" mtb_aart.tara_kg, " +
|
" mtb_aart.tara_kg, " +
|
||||||
|
|||||||
@@ -18,4 +18,8 @@ public enum TipoPartita {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import it.integry.ems_model.types.OperationType;
|
|||||||
import it.integry.ems_model.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -67,19 +68,23 @@ public class AccountingRules extends QueryRules {
|
|||||||
Integer numIreg = entity.getNumIreg();
|
Integer numIreg = entity.getNumIreg();
|
||||||
Integer numProt = entity.getNumProt();
|
Integer numProt = entity.getNumProt();
|
||||||
|
|
||||||
|
if (numIreg == 0) {
|
||||||
|
numIreg = 1;
|
||||||
|
entity.setNumIreg(numIreg);
|
||||||
|
}
|
||||||
|
|
||||||
if (numProt == null) numProt = 0;
|
if (numProt == null) numProt = 0;
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT num_prot "
|
"SELECT Cast(count(*) as bit)"
|
||||||
+ "FROM ctb_inum "
|
+ "FROM ctb_inum "
|
||||||
+ "WHERE cod_ireg = " + UtilityDB.valueToString(codIreg) + " AND "
|
+ "WHERE cod_ireg = " + UtilityDB.valueToString(codIreg) + " AND "
|
||||||
+ " num_ireg = " + UtilityDB.valueToString(numIreg) + " AND "
|
+ " num_ireg = " + UtilityDB.valueToString(numIreg) + " AND "
|
||||||
+ " anno = " + UtilityDB.valueToString(annoComp);
|
+ " anno = " + UtilityDB.valueToString(annoComp);
|
||||||
|
|
||||||
PreparedStatement ps = connection.prepareStatement(sql);
|
boolean existReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
ResultSet rs = ps.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
CallableStatement cs = connection.prepareCall("{call dbo.NextNumProt(?, ?, ?, ?)}");
|
|
||||||
|
|
||||||
|
if (existReg) {
|
||||||
|
CallableStatement cs = connection.prepareCall("{call dbo.NextNumProt(?, ?, ?, ?)}");
|
||||||
cs.setShort(1, annoComp.shortValue());
|
cs.setShort(1, annoComp.shortValue());
|
||||||
cs.setString(2, codIreg);
|
cs.setString(2, codIreg);
|
||||||
cs.setShort(3, numIreg.shortValue());
|
cs.setShort(3, numIreg.shortValue());
|
||||||
@@ -89,12 +94,13 @@ public class AccountingRules extends QueryRules {
|
|||||||
numProt = cs.getInt(4);
|
numProt = cs.getInt(4);
|
||||||
cs.close();
|
cs.close();
|
||||||
} else {
|
} else {
|
||||||
numProt = 1;
|
if (numProt == 0) numProt = 1;
|
||||||
CtbInum ctbInum = new CtbInum();
|
CtbInum ctbInum =
|
||||||
ctbInum.setAnno(annoComp);
|
new CtbInum()
|
||||||
ctbInum.setCodIreg(codIreg);
|
.setAnno(annoComp)
|
||||||
ctbInum.setNumIreg(numIreg);
|
.setCodIreg(codIreg)
|
||||||
ctbInum.setNumProt(numProt);
|
.setNumIreg(numIreg)
|
||||||
|
.setNumProt(numProt);
|
||||||
entity.setCtbInum(ctbInum);
|
entity.setCtbInum(ctbInum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +452,7 @@ public class AccountingRules extends QueryRules {
|
|||||||
List<CtbScad> elencoScadenzeNew = new ArrayList<>();
|
List<CtbScad> elencoScadenzeNew = new ArrayList<>();
|
||||||
String finalDesAgg = desAgg;
|
String finalDesAgg = desAgg;
|
||||||
for (CtbScad scad : ctbMovr.getCtbScad()) {
|
for (CtbScad scad : ctbMovr.getCtbScad()) {
|
||||||
|
|
||||||
CtbScad ctbScad = (CtbScad) scad.clone();
|
CtbScad ctbScad = (CtbScad) scad.clone();
|
||||||
|
|
||||||
com.annimon.stream.Optional<CtbParr> ctbParrFirst = Stream.of(elencoPartite)
|
com.annimon.stream.Optional<CtbParr> ctbParrFirst = Stream.of(elencoPartite)
|
||||||
@@ -461,16 +468,18 @@ public class AccountingRules extends QueryRules {
|
|||||||
if (ctbParrFirst.isPresent()) {
|
if (ctbParrFirst.isPresent()) {
|
||||||
elencoPartite.remove(ctbParrFirst.get());
|
elencoPartite.remove(ctbParrFirst.get());
|
||||||
ctbParr = ctbParrFirst.get();
|
ctbParr = ctbParrFirst.get();
|
||||||
if (ctbParr.getTipoPartitaEnum() == TipoPartita.PASSIVA) {
|
if (UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO)) {
|
||||||
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare()));
|
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||||
} else {
|
} else {
|
||||||
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere()));
|
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
BigDecimal cambioScad = BigDecimal.ONE;
|
||||||
Integer tipoPartita = ctbMovr.getTipoPartita();
|
Integer tipoPartita = ctbMovr.getTipoPartita();
|
||||||
if (tipoPartita == null) {
|
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT Cast(tipo_partita as integer) as tipo_partita " +
|
"SELECT Cast(tipo_partita as integer) as tipo_partita, cambio " +
|
||||||
" FROM ctb_part " +
|
" FROM ctb_part " +
|
||||||
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
||||||
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
||||||
@@ -478,7 +487,10 @@ public class AccountingRules extends QueryRules {
|
|||||||
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
||||||
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
||||||
|
|
||||||
tipoPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
HashMap<String, Object> datiCtbPart = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||||
|
if ( UtilityHashMap.isPresent(datiCtbPart)) {
|
||||||
|
if ( tipoPartita == null ) tipoPartita = UtilityHashMap.getValueIfExists(datiCtbPart, "tipo_partita");
|
||||||
|
cambioScad = UtilityHashMap.getValueIfExists(datiCtbPart, "cambio", BigDecimal.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctbScad.setTipoAnag(UtilityString.isNullOrEmpty(ctbScad.getTipoAnag()) ? ctbMovr.getTipoAnag() : ctbScad.getTipoAnag())
|
ctbScad.setTipoAnag(UtilityString.isNullOrEmpty(ctbScad.getTipoAnag()) ? ctbMovr.getTipoAnag() : ctbScad.getTipoAnag())
|
||||||
@@ -487,7 +499,6 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovr.getSerDoc() : ctbScad.getSerDoc())
|
.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovr.getSerDoc() : ctbScad.getSerDoc())
|
||||||
.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovr.getNumDoc() : ctbScad.getNumDoc());
|
.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovr.getNumDoc() : ctbScad.getNumDoc());
|
||||||
|
|
||||||
|
|
||||||
ctbParr =
|
ctbParr =
|
||||||
new CtbParr()
|
new CtbParr()
|
||||||
.setCodCcon(ctbMovr.getCodCcon())
|
.setCodCcon(ctbMovr.getCodCcon())
|
||||||
@@ -498,12 +509,13 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setNumDoc(ctbScad.getNumDoc())
|
.setNumDoc(ctbScad.getNumDoc())
|
||||||
.setDataCmov(ctbMovr.getDataCmov())
|
.setDataCmov(ctbMovr.getDataCmov())
|
||||||
.setIdRiga(ctbMovr.getIdRiga())
|
.setIdRiga(ctbMovr.getIdRiga())
|
||||||
.setImpDare(TipoPartita.fromValue(tipoPartita) == TipoPartita.PASSIVA ? ctbScad.getImpDare() : BigDecimal.ZERO)
|
.setImpDare(UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO) ? ctbScad.getImpDare().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||||
.setImpAvere(TipoPartita.fromValue(tipoPartita) == TipoPartita.ATTIVA ? ctbScad.getImpAvere() : BigDecimal.ZERO)
|
.setImpAvere(UtilityBigDecimal.greaterThan(ctbMovr.getImpAvere(), BigDecimal.ZERO) ? ctbScad.getImpAvere().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||||
.setCodCcau(ctbMovr.getCodCcau())
|
.setCodCcau(ctbMovr.getCodCcau())
|
||||||
.setDesAgg(finalDesAgg)
|
.setDesAgg(finalDesAgg)
|
||||||
.setTipoPartita(tipoPartita)
|
.setTipoPartita(tipoPartita)
|
||||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
.setChiudiScad(ctbMovr.getChiudiScad())
|
||||||
|
.setCambioDiviScad(cambioScad);
|
||||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,6 +540,21 @@ public class AccountingRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
ctbMovr.setCtbScad(elencoScadenzeNew);
|
ctbMovr.setCtbScad(elencoScadenzeNew);
|
||||||
} else {
|
} else {
|
||||||
|
String sql =
|
||||||
|
Query.format(
|
||||||
|
"SELECT cast(case when count(*) > 1 THEN 1 ELSE 0 eND as bit)" +
|
||||||
|
" FROM ctb_parr " +
|
||||||
|
" WHERE cod_anag = %s AND " +
|
||||||
|
"tipo_anag = %s AND " +
|
||||||
|
"anno_part = %s AND " +
|
||||||
|
"ser_doc = %s AND " +
|
||||||
|
"num_doc = %s AND " +
|
||||||
|
"id_riga = %s ",
|
||||||
|
ctbMovr.getCodAnag(), ctbMovr.getTipoAnag(), ctbMovr.getAnnoPart(), ctbMovr.getSerDoc(), ctbMovr.getNumDoc(), ctbMovr.getIdRiga());
|
||||||
|
|
||||||
|
boolean existRow = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||||
|
|
||||||
|
if (!existRow) {
|
||||||
CtbParr ctbParr =
|
CtbParr ctbParr =
|
||||||
new CtbParr()
|
new CtbParr()
|
||||||
.setCodCcon(ctbMovr.getCodCcon())
|
.setCodCcon(ctbMovr.getCodCcon())
|
||||||
@@ -546,6 +573,7 @@ public class AccountingRules extends QueryRules {
|
|||||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
elencoPartite.add(ctbParr);
|
elencoPartite.add(ctbParr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return elencoPartite;
|
return elencoPartite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,7 +914,7 @@ public class AccountingRules extends QueryRules {
|
|||||||
ResultSetMapper resultSetMapper = new ResultSetMapper();
|
ResultSetMapper resultSetMapper = new ResultSetMapper();
|
||||||
List<CtbScad> ctbScad = resultSetMapper.mapQuerySetToList(conn, sql, CtbScad.class);
|
List<CtbScad> ctbScad = resultSetMapper.mapQuerySetToList(conn, sql, CtbScad.class);
|
||||||
if (ctbMovr.getOperation() == OperationType.DELETE && ctbScad.size() > 0) {
|
if (ctbMovr.getOperation() == OperationType.DELETE && ctbScad.size() > 0) {
|
||||||
Stream.of(ctbScad).forEach(x -> {
|
for ( CtbScad x: ctbScad) {
|
||||||
x.setOperation(x.getIsInsoluto() ? OperationType.DELETE : OperationType.UPDATE);
|
x.setOperation(x.getIsInsoluto() ? OperationType.DELETE : OperationType.UPDATE);
|
||||||
CrlScadParr crlScadParr =
|
CrlScadParr crlScadParr =
|
||||||
new CrlScadParr()
|
new CrlScadParr()
|
||||||
@@ -900,8 +928,9 @@ public class AccountingRules extends QueryRules {
|
|||||||
.setNumCmov(ctbMovr.getNumCmov())
|
.setNumCmov(ctbMovr.getNumCmov())
|
||||||
.setId(x.getPkRelazione());
|
.setId(x.getPkRelazione());
|
||||||
crlScadParr.setOperation(OperationType.DELETE);
|
crlScadParr.setOperation(OperationType.DELETE);
|
||||||
|
if (x.getCrlScadParr() == null ) x.setCrlScadParr(new ArrayList<>());
|
||||||
x.getCrlScadParr().add(crlScadParr);
|
x.getCrlScadParr().add(crlScadParr);
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctbScad;
|
return ctbScad;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import it.integry.ems.service.comuni.Comune;
|
|||||||
import it.integry.ems.service.comuni.service.ComuniService;
|
import it.integry.ems.service.comuni.service.ComuniService;
|
||||||
import it.integry.ems_model.entity.*;
|
import it.integry.ems_model.entity.*;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
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.UtilityDate;
|
import it.integry.ems_model.utility.UtilityDate;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
@@ -230,9 +231,15 @@ public class AnagRules extends QueryRules {
|
|||||||
gtbAnagNote.getGrlAnagNoteFiles().add(grlAnagNoteFiles);
|
gtbAnagNote.getGrlAnagNoteFiles().add(grlAnagNoteFiles);
|
||||||
gtbAnagNote.setOperation(OperationType.INSERT_OR_UPDATE);
|
gtbAnagNote.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String completeCodVvet(Connection connection, VtbVett vtbVett) throws Exception {
|
||||||
|
String sql = Query.format(
|
||||||
|
"SELECT dbo.f_suggestCodeCodVvet(%s)",
|
||||||
|
vtbVett.getPrecode()
|
||||||
|
);
|
||||||
|
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import com.annimon.stream.ComparatorCompat;
|
|||||||
import com.annimon.stream.Optional;
|
import com.annimon.stream.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems_model.annotation.*;
|
import it.integry.ems_model.annotation.ReloadRow;
|
||||||
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.db.ResultSetMapper;
|
import it.integry.ems_model.db.ResultSetMapper;
|
||||||
@@ -16,7 +17,6 @@ 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.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.expression.Expression;
|
import org.springframework.expression.Expression;
|
||||||
import org.springframework.expression.ExpressionParser;
|
import org.springframework.expression.ExpressionParser;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
@@ -179,7 +179,7 @@ public class CommonRules extends QueryRules {
|
|||||||
Object object = field.get(testata);
|
Object object = field.get(testata);
|
||||||
if (object != null && field.getType().isAssignableFrom(List.class) && ( field.getAnnotation(ReloadRow.class) != null || testata.getOperation() == OperationType.SUBSTITUTE)) {
|
if (object != null && field.getType().isAssignableFrom(List.class) && ( field.getAnnotation(ReloadRow.class) != null || testata.getOperation() == OperationType.SUBSTITUTE)) {
|
||||||
List<? extends EntityBase> rows = (ArrayList<EntityBase>) object;
|
List<? extends EntityBase> rows = (ArrayList<EntityBase>) object;
|
||||||
List<EntityBase> list = null;
|
List<? extends EntityBase> list = null;
|
||||||
if (testata.getOperation() != OperationType.DELETE_THEN_INSERT &&
|
if (testata.getOperation() != OperationType.DELETE_THEN_INSERT &&
|
||||||
testata.getOperation() != OperationType.INSERT) {
|
testata.getOperation() != OperationType.INSERT) {
|
||||||
list = UtilityDB.reloadOnlyDbRow(conn, testata, rows, field);
|
list = UtilityDB.reloadOnlyDbRow(conn, testata, rows, field);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ConfigActivityRules extends QueryRules {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<Date> dataDaControllare = new ArrayList<>();
|
List<Date> dataDaControllare = new ArrayList<>();
|
||||||
if (stbActivity.getEstimatedDate() != null) dataDaControllare.add(stbActivity.getEstimatedDate());
|
//if (stbActivity.getEstimatedDate() != null) dataDaControllare.add(stbActivity.getEstimatedDate());
|
||||||
if (stbActivity.getEffectiveDate() != null) dataDaControllare.add(stbActivity.getEffectiveDate());
|
if (stbActivity.getEffectiveDate() != null) dataDaControllare.add(stbActivity.getEffectiveDate());
|
||||||
|
|
||||||
for (Date data : dataDaControllare) {
|
for (Date data : dataDaControllare) {
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ public class DocOrdRules extends QueryRules {
|
|||||||
.setGestione(ordine.getGestione())
|
.setGestione(ordine.getGestione())
|
||||||
.setDataOrd(ordine.getDataOrd())
|
.setDataOrd(ordine.getDataOrd())
|
||||||
.setNumOrd(ordine.getNumOrd())
|
.setNumOrd(ordine.getNumOrd())
|
||||||
.setPartitaMag(dtbOrdt.getOperation() == OperationType.DELETE ? EmsRestConstants.NULL : dtbOrdt.getPartitaMag())
|
.setPartitaMag(dtbOrdt.getOperation() == OperationType.DELETE || ordine.getFlagScollegaPartitaMag() ? EmsRestConstants.NULL : dtbOrdt.getPartitaMag())
|
||||||
);
|
);
|
||||||
|
|
||||||
righeOrdine.forEach(rigaOrdine -> rigaOrdine.setOperation(OperationType.UPDATE));
|
righeOrdine.forEach(rigaOrdine -> rigaOrdine.setOperation(OperationType.UPDATE));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package it.integry.ems.rules.completing;
|
package it.integry.ems.rules.completing;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
|
||||||
import it.integry.ems_model.entity.DtbDoct;
|
import it.integry.ems_model.entity.DtbDoct;
|
||||||
import it.integry.ems_model.entity.WdtbDoct;
|
import it.integry.ems_model.entity.WdtbDoct;
|
||||||
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
import it.integry.ems_model.entity.common.DtbDocOrdT;
|
||||||
@@ -39,7 +38,7 @@ public class OrdWebRules extends QueryRules {
|
|||||||
if (testata instanceof WdtbDoct || testata instanceof DtbDoct)
|
if (testata instanceof WdtbDoct || testata instanceof DtbDoct)
|
||||||
throw new Exception("Impossibile eseguire completeIdArtOrd su un documento");
|
throw new Exception("Impossibile eseguire completeIdArtOrd su un documento");
|
||||||
|
|
||||||
if (testata.getApplicationName().equalsIgnoreCase("TEXTILES")) {
|
if (testata.getApplicationName().equalsIgnoreCase(ApplicationName.TEXTILES.toString())) {
|
||||||
String codMartOld = "";
|
String codMartOld = "";
|
||||||
String gruppoConsOld = "";
|
String gruppoConsOld = "";
|
||||||
String noteRigaOld = "";
|
String noteRigaOld = "";
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ public class OrderRules extends QueryRules {
|
|||||||
public static Boolean checkExistOrdW(Connection conn, WdtbOrdt wdtbOrdt) throws Exception {
|
public static Boolean checkExistOrdW(Connection conn, WdtbOrdt wdtbOrdt) throws Exception {
|
||||||
String sql = null;
|
String sql = null;
|
||||||
|
|
||||||
if (wdtbOrdt.getApplicationName().equalsIgnoreCase("TEXTILES")) {
|
if (wdtbOrdt.getApplicationName().equalsIgnoreCase(ApplicationName.TEXTILES.toString())) {
|
||||||
|
|
||||||
String codFirtMart = wdtbOrdt.getWdtbOrdr().get(0).getCodMart();
|
String codFirtMart = wdtbOrdt.getWdtbOrdr().get(0).getCodMart();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package it.integry.ems.rules.completing;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
import it.integry.ems.rules.completing.dto.DatiPartitaMagDTO;
|
||||||
import it.integry.ems_model.annotation.SqlField;
|
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
import it.integry.ems_model.entity.MtbColr;
|
import it.integry.ems_model.entity.MtbColr;
|
||||||
import it.integry.ems_model.entity.MtbCols;
|
import it.integry.ems_model.entity.MtbCols;
|
||||||
@@ -11,12 +10,13 @@ import it.integry.ems_model.entity.MtbColt;
|
|||||||
import it.integry.ems_model.entity.MtbPartitaMag;
|
import it.integry.ems_model.entity.MtbPartitaMag;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
import it.integry.ems_model.utility.*;
|
import it.integry.ems_model.utility.*;
|
||||||
import org.springframework.util.ReflectionUtils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.sql.*;
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -381,7 +381,7 @@ public class PackagesRules extends QueryRules {
|
|||||||
if (mtbColt.getCalcPeso()) {
|
if (mtbColt.getCalcPeso()) {
|
||||||
mtbColt.setPesoKg(pesoLordo);
|
mtbColt.setPesoKg(pesoLordo);
|
||||||
mtbColt.setPesoNettoKg(pesoNetto);
|
mtbColt.setPesoNettoKg(pesoNetto);
|
||||||
|
if (mtbColt.getOperation() != OperationType.SUBSTITUTE)
|
||||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||||
} else if (!mtbColt.getCalcPeso() && righe.size() > 0 && UtilityBigDecimal.greaterThan(pesoLordo, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(pesoNetto, BigDecimal.ZERO)) {
|
} else if (!mtbColt.getCalcPeso() && righe.size() > 0 && UtilityBigDecimal.greaterThan(pesoLordo, BigDecimal.ZERO) && UtilityBigDecimal.greaterThan(pesoNetto, BigDecimal.ZERO)) {
|
||||||
long countRowKG = Stream.of(righe).filter(x -> x.getOperation() != OperationType.DELETE && "S".equalsIgnoreCase(x.getArtAPeso())).count();
|
long countRowKG = Stream.of(righe).filter(x -> x.getOperation() != OperationType.DELETE && "S".equalsIgnoreCase(x.getArtAPeso())).count();
|
||||||
@@ -447,6 +447,7 @@ public class PackagesRules extends QueryRules {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSerCollo(Connection conn, String codMdep) throws Exception {
|
public static String getSerCollo(Connection conn, String codMdep) throws Exception {
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT dbo.f_getSerCollo(" + UtilityDB.valueToString(codMdep) + ")";
|
"SELECT dbo.f_getSerCollo(" + UtilityDB.valueToString(codMdep) + ")";
|
||||||
|
|||||||
@@ -218,6 +218,21 @@ public class ProductionsRules extends QueryRules {
|
|||||||
ps.close();
|
ps.close();
|
||||||
return mezzo;
|
return mezzo;
|
||||||
}
|
}
|
||||||
|
public static String completeCodLingua(Connection connection, String codAnag) throws SQLException {
|
||||||
|
String sql = "SELECT case when gtb_anag.nazione is null then (select cod_lingua from azienda inner join gtb_nazi on azienda.nazione = gtb_nazi.nazione) else gtb_nazi.cod_lingua end " +
|
||||||
|
" FROM gtb_anag left outer join gtb_nazi on gtb_anag.nazione = gtb_nazi.nazione " +
|
||||||
|
" left outer join gtb_lingue on gtb_nazi.cod_lingua = gtb_lingue.cod_lingua " +
|
||||||
|
" WHERE gtb_anag.cod_anag = " + UtilityDB.valueToString(codAnag);
|
||||||
|
PreparedStatement ps = connection.prepareStatement(sql);
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
String codLingua = null;
|
||||||
|
if (rs.next()) {
|
||||||
|
codLingua = rs.getString(1);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
return codLingua;
|
||||||
|
}
|
||||||
|
|
||||||
public static Integer completeNumOrdWeb(Connection connection, String serie,
|
public static Integer completeNumOrdWeb(Connection connection, String serie,
|
||||||
String gestione, Date dataOrd) throws Exception {
|
String gestione, Date dataOrd) throws Exception {
|
||||||
|
|||||||
@@ -159,6 +159,31 @@ public class SalesRules extends QueryRules {
|
|||||||
return untMisVend;
|
return untMisVend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VtbList insertVtbList(Connection connection, VtbListData vtbListData) throws SQLException {
|
||||||
|
String sql = Query.format(
|
||||||
|
"SELECT CAST(COUNT(*) AS BIT) FROM vtb_list WHERE cod_vlis = %s",
|
||||||
|
vtbListData.getCodVlis()
|
||||||
|
);
|
||||||
|
|
||||||
|
Boolean countVtbList = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||||
|
|
||||||
|
if (!countVtbList) {
|
||||||
|
VtbList vtbList = new VtbList();
|
||||||
|
|
||||||
|
vtbList
|
||||||
|
.setCodVlis(vtbListData.getCodVlis())
|
||||||
|
.setDescrizione(vtbListData.getDescrizione())
|
||||||
|
.setCodDivi(vtbListData.getCodDivi());
|
||||||
|
|
||||||
|
vtbList.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
return vtbList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static VtbPromo completePromoVend(VtbListData vtbListData) {
|
public static VtbPromo completePromoVend(VtbListData vtbListData) {
|
||||||
if (vtbListData.getVtbPromo() != null) {
|
if (vtbListData.getVtbPromo() != null) {
|
||||||
VtbPromo vtbPromo = vtbListData.getVtbPromo().setCodPromo(vtbListData.getCodPromo());
|
VtbPromo vtbPromo = vtbListData.getVtbPromo().setCodPromo(vtbListData.getCodPromo());
|
||||||
@@ -486,6 +511,8 @@ public class SalesRules extends QueryRules {
|
|||||||
valUntIva != null) {
|
valUntIva != null) {
|
||||||
|
|
||||||
BigDecimal percAliq = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "perc_aliq");
|
BigDecimal percAliq = (BigDecimal) DroolsUtil.getEntityFieldValue(entity, "perc_aliq");
|
||||||
|
if ( percAliq == null )
|
||||||
|
throw new Exception ( String.format("Aliquota iva mancante sull'articolo ", entity.getCodMart()));
|
||||||
BigDecimal valUnt = CommonRules.scorporoIva(valUntIva, percAliq);
|
BigDecimal valUnt = CommonRules.scorporoIva(valUntIva, percAliq);
|
||||||
entity.setValUnt(valUnt);
|
entity.setValUnt(valUnt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class ForeignKeyDTO {
|
|||||||
put(CtbIreg.ENTITY, "Codice registro documenti inesistente");
|
put(CtbIreg.ENTITY, "Codice registro documenti inesistente");
|
||||||
put(WtbJrept.ENTITY, "Report inesistente");
|
put(WtbJrept.ENTITY, "Report inesistente");
|
||||||
put(StbDevice.ENTITY, "Dispositivo inesistente");
|
put(StbDevice.ENTITY, "Dispositivo inesistente");
|
||||||
|
put(StbPublications.ENTITY, "Pubblicazione inesistente");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
String tableName;
|
String tableName;
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package it.integry.ems.schedule.new_cron_job.dto.operations;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
@JsonInclude
|
@JsonInclude
|
||||||
public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO {
|
public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO {
|
||||||
|
|
||||||
|
@OperationField()
|
||||||
|
private RequestMethod methodType;
|
||||||
|
|
||||||
@OperationField(required = true)
|
@OperationField(required = true)
|
||||||
private String methodName;
|
private String methodName;
|
||||||
|
|
||||||
@@ -25,6 +29,15 @@ public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO
|
|||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
public RequestMethod getMethodType() {
|
||||||
|
return methodType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceCallAutomatedOperationDTO setMethodType(RequestMethod methodType) {
|
||||||
|
this.methodType = methodType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMethodName() {
|
public String getMethodName() {
|
||||||
return methodName;
|
return methodName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import it.integry.ems.service.HttpRestWrapper;
|
|||||||
import it.integry.ems_model.utility.UtilityServer;
|
import it.integry.ems_model.utility.UtilityServer;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationRunner<ServiceCallAutomatedOperationDTO> {
|
public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationRunner<ServiceCallAutomatedOperationDTO> {
|
||||||
|
|
||||||
@@ -21,13 +22,52 @@ public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationR
|
|||||||
+ (getDtoInstance().getQueryParams() != null ? ("&" + getDtoInstance().getQueryParams()) : "");
|
+ (getDtoInstance().getQueryParams() != null ? ("&" + getDtoInstance().getQueryParams()) : "");
|
||||||
|
|
||||||
StringBuilder responseBody = new StringBuilder();
|
StringBuilder responseBody = new StringBuilder();
|
||||||
int status = HttpRestWrapper.callGeneric(
|
|
||||||
|
int status;
|
||||||
|
|
||||||
|
RequestMethod methodType = getDtoInstance().getMethodType();
|
||||||
|
|
||||||
|
if (methodType == null) {
|
||||||
|
methodType = RequestMethod.POST;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (methodType) {
|
||||||
|
case GET:
|
||||||
|
status = HttpRestWrapper.callGenericGet(
|
||||||
|
baseUrl,
|
||||||
|
getDtoInstance().getUsername(),
|
||||||
|
getDtoInstance().getPassword(),
|
||||||
|
responseBody,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case POST:
|
||||||
|
status = HttpRestWrapper.callGeneric(
|
||||||
baseUrl,
|
baseUrl,
|
||||||
getDtoInstance().getUsername(),
|
getDtoInstance().getUsername(),
|
||||||
getDtoInstance().getPassword(),
|
getDtoInstance().getPassword(),
|
||||||
getDtoInstance().getBody(),
|
getDtoInstance().getBody(),
|
||||||
ContentType.APPLICATION_JSON,
|
ContentType.APPLICATION_JSON,
|
||||||
responseBody);
|
responseBody
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PUT:
|
||||||
|
status = HttpRestWrapper.callGeneric(
|
||||||
|
baseUrl,
|
||||||
|
getDtoInstance().getUsername(),
|
||||||
|
getDtoInstance().getPassword(),
|
||||||
|
getDtoInstance().getBody(),
|
||||||
|
ContentType.APPLICATION_JSON,
|
||||||
|
responseBody,
|
||||||
|
null,
|
||||||
|
RequestMethod.PUT
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
String responseJson = responseBody.toString();
|
String responseJson = responseBody.toString();
|
||||||
|
|
||||||
|
|||||||
@@ -53,10 +53,16 @@ public class AutomatedOperationService {
|
|||||||
operationFieldDTO.setDefaultValues(profiles);
|
operationFieldDTO.setDefaultValues(profiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x.getType().isEnum()) {
|
||||||
|
operationFieldDTO
|
||||||
|
.setType("Enum")
|
||||||
|
.setDefaultValues(Stream.of(x.getType().getEnumConstants()).map(Object::toString).toList());
|
||||||
|
} else {
|
||||||
String type = x.getType().getName();
|
String type = x.getType().getName();
|
||||||
|
|
||||||
String[] explodedType = type.split("\\.");
|
String[] explodedType = type.split("\\.");
|
||||||
operationFieldDTO.setType(explodedType[explodedType.length - 1]);
|
operationFieldDTO.setType(explodedType[explodedType.length - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (x.isAnnotationPresent(OperationField.class)) {
|
if (x.isAnnotationPresent(OperationField.class)) {
|
||||||
OperationField operationField = x.getAnnotation(OperationField.class);
|
OperationField operationField = x.getAnnotation(OperationField.class);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.annimon.stream.Stream;
|
|||||||
import it.integry.annotations.PostContextAutowired;
|
import it.integry.annotations.PostContextAutowired;
|
||||||
import it.integry.annotations.PostWebServerConstruct;
|
import it.integry.annotations.PostWebServerConstruct;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
import it.integry.ems.schedule.new_cron_job.dto.AutomatedOperationTypeEnum;
|
||||||
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ExportAutomatedOperationDTO;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.ServiceCallAutomatedOperationDTO;
|
||||||
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseAutomatedOperationDTO;
|
||||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||||
@@ -11,6 +12,7 @@ import it.integry.ems.settings.Model.SettingsModel;
|
|||||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||||
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.utility.UtilityDB;
|
||||||
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.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -43,7 +45,6 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
|
|
||||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||||
deleteJobFileDeleter(multiDBTransactionManager);
|
deleteJobFileDeleter(multiDBTransactionManager);
|
||||||
//initFileDeleterJob(multiDBTransactionManager);
|
|
||||||
initServerInfoCheckJob();
|
initServerInfoCheckJob();
|
||||||
initRemoveFpxInvioFilesJob();
|
initRemoveFpxInvioFilesJob();
|
||||||
initChkAutofatture();
|
initChkAutofatture();
|
||||||
@@ -51,6 +52,7 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
initMinioOrphanFileCleaner(multiDBTransactionManager);
|
initMinioOrphanFileCleaner(multiDBTransactionManager);
|
||||||
initPassaggioAnno(multiDBTransactionManager);
|
initPassaggioAnno(multiDBTransactionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -161,43 +163,6 @@ public class DefaultAutomatedOperationHandlerComponent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFileDeleterJob(MultiDBTransactionManager data) {
|
|
||||||
try {
|
|
||||||
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
|
||||||
|
|
||||||
HashMap<AutomatedOperationTypeEnum, List<BaseAutomatedOperationDTO>> activeOperations = automatedOperationHandlerComponent.get(AutomatedOperationTypeEnum.METHOD_CALLS, null);
|
|
||||||
if (!activeOperations.containsKey(AutomatedOperationTypeEnum.METHOD_CALLS))
|
|
||||||
activeOperations.put(AutomatedOperationTypeEnum.METHOD_CALLS, new ArrayList<>());
|
|
||||||
|
|
||||||
activeConnections = Stream.of(activeConnections)
|
|
||||||
.filter(x -> x.isInternalDb() && x.getDataSource().getProfile().equalsIgnoreCase(x.getDataSource().getDbName()))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
for (AdvancedDataSource activeConnection : activeConnections) {
|
|
||||||
final String filesDeleterOperationName = "File deleter " + activeConnection.getProfileName().toUpperCase();
|
|
||||||
|
|
||||||
boolean jobExists = Stream.of(activeOperations.get(AutomatedOperationTypeEnum.METHOD_CALLS))
|
|
||||||
.anyMatch(iScheduledOperation -> iScheduledOperation.getName().equals(filesDeleterOperationName));
|
|
||||||
|
|
||||||
if (!jobExists) {
|
|
||||||
ServiceCallAutomatedOperationDTO serviceCallAutomatedOperationDTO = new ServiceCallAutomatedOperationDTO()
|
|
||||||
.setMethodName("cleanDirectories")
|
|
||||||
.setProfileDb(activeConnection.getProfileName());
|
|
||||||
serviceCallAutomatedOperationDTO
|
|
||||||
.setCronTrigger("0 0 0 1/1 * ?")
|
|
||||||
.setName(filesDeleterOperationName);
|
|
||||||
|
|
||||||
automatedOperationHandlerComponent.add(serviceCallAutomatedOperationDTO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteJobFileDeleter(MultiDBTransactionManager data) {
|
private void deleteJobFileDeleter(MultiDBTransactionManager data) {
|
||||||
try {
|
try {
|
||||||
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import it.integry.ems_model.annotation.SqlField;
|
|||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
import it.integry.ems_model.config.EmsRestConstants;
|
import it.integry.ems_model.config.EmsRestConstants;
|
||||||
|
import it.integry.ems_model.entity.Azienda;
|
||||||
import it.integry.ems_model.entity.MrlPartitaMagAttached;
|
import it.integry.ems_model.entity.MrlPartitaMagAttached;
|
||||||
import it.integry.ems_model.entity.StbFilesAttached;
|
import it.integry.ems_model.entity.StbFilesAttached;
|
||||||
import it.integry.ems_model.entity.WtbUsersInfo;
|
import it.integry.ems_model.entity.WtbUsersInfo;
|
||||||
@@ -211,9 +212,11 @@ public class EmsServices {
|
|||||||
IEntityImporter entityImporter = EntityImporterUtility.getRightImporterClassByType(enumType).newInstance();
|
IEntityImporter entityImporter = EntityImporterUtility.getRightImporterClassByType(enumType).newInstance();
|
||||||
setEntityImporter(entityImporter, file, multiDBTransactionManager, type, format, body, headless);
|
setEntityImporter(entityImporter, file, multiDBTransactionManager, type, format, body, headless);
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(body.getFileName())) {
|
// if (UtilityString.isNullOrEmpty(body.getFileName())) {
|
||||||
|
// body.setFileName(file.getName());
|
||||||
|
// }
|
||||||
|
|
||||||
body.setFileName(file.getName());
|
body.setFileName(file.getName());
|
||||||
}
|
|
||||||
|
|
||||||
List<EntityBase> tmpResult = (List<EntityBase>) entityImporter.doImport();
|
List<EntityBase> tmpResult = (List<EntityBase>) entityImporter.doImport();
|
||||||
response.getAnomalie().addAll(entityImporter.getAnomalie());
|
response.getAnomalie().addAll(entityImporter.getAnomalie());
|
||||||
@@ -718,10 +721,13 @@ public class EmsServices {
|
|||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
if (arguments.containsKey("nomeAzienda")) arguments.remove("nomeAzienda");
|
final Azienda defaultAzienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
|
||||||
|
|
||||||
|
if (arguments.containsKey("nomeAzienda")) arguments.remove("nomeAzienda");
|
||||||
arguments.put("nomeAzienda", settingsModel.getDefaultProfile());
|
arguments.put("nomeAzienda", settingsModel.getDefaultProfile());
|
||||||
|
|
||||||
|
arguments.put("partitaIva", defaultAzienda.getPartIva());
|
||||||
|
|
||||||
String jsonBody = gson.toJson(arguments);
|
String jsonBody = gson.toJson(arguments);
|
||||||
|
|
||||||
StringBuilder srb = new StringBuilder();
|
StringBuilder srb = new StringBuilder();
|
||||||
@@ -987,7 +993,7 @@ public class EmsServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityHierarchyDTO> getEntityMapping() {
|
public List<EntityHierarchyDTO> getEntityMapping() {
|
||||||
return entityPropertyHolder.getEntityMapping();
|
return entityPropertyHolder.getEntityHierarchyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityFieldDTO> getEntityDetails(String entityName) {
|
public List<EntityFieldDTO> getEntityDetails(String entityName) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package it.integry.ems.service;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.annotations.PostContextConstruct;
|
import it.integry.annotations.PostContextConstruct;
|
||||||
import it.integry.ems.datasource.DataSource;
|
import it.integry.ems.dynamic_cache.DynamicCacheService;
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
import it.integry.ems.looper.service.LooperService;
|
import it.integry.ems.looper.service.LooperService;
|
||||||
import it.integry.ems.service.dto.EntityToLogDTO;
|
import it.integry.ems.service.dto.EntityToLogDTO;
|
||||||
@@ -14,9 +14,9 @@ import it.integry.ems.utility.UtilityDebug;
|
|||||||
import it.integry.ems_model.annotation.EntityChild;
|
import it.integry.ems_model.annotation.EntityChild;
|
||||||
import it.integry.ems_model.annotation.SqlField;
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
import it.integry.ems_model.base.EntityInterface;
|
import it.integry.ems_model.base.EntityInterface;
|
||||||
|
import it.integry.ems_model.entity.StbLogEntitySetup;
|
||||||
import it.integry.ems_model.resolver.SqlFieldHolder;
|
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||||
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.UtilityReflection;
|
import it.integry.ems_model.utility.UtilityReflection;
|
||||||
import it.integry.ems_model.utility.UtilityString;
|
import it.integry.ems_model.utility.UtilityString;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -27,9 +27,9 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class EntityLoggerNewService {
|
public class EntityLoggerNewService {
|
||||||
@@ -46,19 +46,18 @@ public class EntityLoggerNewService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private JSONObjectMapper jsonObjectMapper;
|
private JSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
private final ArrayList<EntityToLogDTO> queue = new ArrayList<>();
|
@Autowired
|
||||||
private final Logger logger = LogManager.getLogger();
|
private DynamicCacheService dynamicCacheService;
|
||||||
|
|
||||||
private final HashMap<String, List<String>> logSetup = new HashMap<>();
|
private final ArrayList<EntityToLogDTO> queue = new ArrayList<>();
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@PostContextConstruct
|
@PostContextConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
initSetup();
|
||||||
|
|
||||||
refreshEntityLogSetup();
|
if (!UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) {
|
||||||
|
|
||||||
if (!UtilityDebug.isDebugExecution()) {
|
|
||||||
looperService.add(this::refreshEntityLogSetup, 5 * 60 * 1000, EntityLoggerNewService.class.getName());
|
|
||||||
|
|
||||||
looperService.add(() -> {
|
looperService.add(() -> {
|
||||||
try {
|
try {
|
||||||
consumeQueue();
|
consumeQueue();
|
||||||
@@ -67,16 +66,25 @@ public class EntityLoggerNewService {
|
|||||||
}
|
}
|
||||||
}, 10 * 1000, "LOG_" + EntityLoggerNewService.class.getName());
|
}, 10 * 1000, "LOG_" + EntityLoggerNewService.class.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSetup() {
|
||||||
|
List<String> dbNames = settingsModel.getAvailableConnections().stream()
|
||||||
|
.filter(AvailableConnectionsModel::getInternalDb)
|
||||||
|
.map(AvailableConnectionsModel::getDbName)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
dynamicCacheService.addEntity(DynamicCacheService.Keys.ENTITY_LOGGER_SETUP, 5, StbLogEntitySetup.class, dbNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized void log(String profileDB, String username, EntityInterface entity) throws Exception {
|
public synchronized <T extends EntityInterface>void log(String profileDB, String dbName, String username, T entity) throws Exception {
|
||||||
// if (entity.getOperation() == OperationType.SELECT_OBJECT || entity.getOperation() == OperationType.SELECT)
|
// if (entity.getOperation() == OperationType.SELECT_OBJECT || entity.getOperation() == OperationType.SELECT)
|
||||||
// return;
|
// return;
|
||||||
profileDB = profileDB.toUpperCase();
|
profileDB = profileDB.toUpperCase();
|
||||||
|
|
||||||
if (!shouldLogEntity(profileDB, entity))
|
if (!shouldLogEntity(dbName, entity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
synchronized (queue) {
|
synchronized (queue) {
|
||||||
@@ -92,46 +100,16 @@ public class EntityLoggerNewService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean shouldLogEntity(String profileDB, EntityInterface entityInterface) {
|
private <T extends EntityInterface>boolean shouldLogEntity(String dbName, T entity) {
|
||||||
if (!logSetup.containsKey(profileDB)) return false;
|
final List<StbLogEntitySetup> logEntitySetup = dynamicCacheService.getEntity(DynamicCacheService.Keys.ENTITY_LOGGER_SETUP, dbName.toLowerCase());
|
||||||
|
if(logEntitySetup == null) return false;
|
||||||
return Stream.of(logSetup.get(profileDB))
|
|
||||||
.anyMatch(x -> x.equalsIgnoreCase(entityInterface.getTableName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshEntityLogSetup() {
|
|
||||||
String sql = "SELECT entity_name FROM stb_log_entity_setup";
|
|
||||||
|
|
||||||
for (AvailableConnectionsModel availableConnectionsModel : settingsModel.getAvailableConnections()) {
|
|
||||||
if (!availableConnectionsModel.getInternalDb()) continue;
|
|
||||||
|
|
||||||
DataSource ds = new DataSource();
|
|
||||||
String profileDb = availableConnectionsModel.getProfileName();
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!logSetup.containsKey(profileDb)) logSetup.put(profileDb, new ArrayList<>());
|
|
||||||
ds.initialize(profileDb, "EMS Connection - Logger", true);
|
|
||||||
|
|
||||||
logSetup.get(profileDb).clear();
|
|
||||||
logSetup.get(profileDb).addAll(UtilityDB.executeSimpleQueryOnlyFirstColumn(ds.getConnection(), sql));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
logger.error("EntityLogger", exception);
|
|
||||||
exception.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
ds.forceClose();
|
|
||||||
} catch (SQLException throwables) {
|
|
||||||
logger.error("EntityLogger", throwables);
|
|
||||||
throwables.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return logEntitySetup.stream().anyMatch(x -> x.getEntityName().equalsIgnoreCase(entity.getTableName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void consumeQueue() throws Exception {
|
private synchronized void consumeQueue() throws Exception {
|
||||||
synchronized (queue) {
|
synchronized (queue) {
|
||||||
if (queue.size() > 0) {
|
if (!queue.isEmpty()) {
|
||||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(settingsController.getHistoryProfileDb());
|
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(settingsController.getHistoryProfileDb());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -175,7 +153,7 @@ public class EntityLoggerNewService {
|
|||||||
|
|
||||||
String columns = StringUtils.join(entityMap.keySet(), ", ");
|
String columns = StringUtils.join(entityMap.keySet(), ", ");
|
||||||
String values = StringUtils.join(Stream.of(entityMap.values())
|
String values = StringUtils.join(Stream.of(entityMap.values())
|
||||||
.map(SqlFieldHolder::getSqlValueField).toList(), ", ");
|
.map(SqlFieldHolder::getSqlValueFieldAsString).toList(), ", ");
|
||||||
|
|
||||||
String sql = "INSERT INTO " + entityToLog.getEntity().getTableName() +
|
String sql = "INSERT INTO " + entityToLog.getEntity().getTableName() +
|
||||||
"(" + columns + ") VALUES (" + values + ")";
|
"(" + columns + ") VALUES (" + values + ")";
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import it.integry.common.var.CommonConstants;
|
|||||||
import it.integry.ems.datasource.DataSource;
|
import it.integry.ems.datasource.DataSource;
|
||||||
import it.integry.ems.dto.EntityPermissionsDTO;
|
import it.integry.ems.dto.EntityPermissionsDTO;
|
||||||
import it.integry.ems.exception.InvalidPermissionsException;
|
import it.integry.ems.exception.InvalidPermissionsException;
|
||||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
|
||||||
import it.integry.ems.javabeans.RequestDataDTO;
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
import it.integry.ems.json.JSONObjectMapper;
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
import it.integry.ems.model.ColumnMetadataDTO;
|
import it.integry.ems.model.ColumnMetadataDTO;
|
||||||
import it.integry.ems.object_storage.minio.sdk.errors.MinioException;
|
|
||||||
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.AdvancedDataSource;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
@@ -24,7 +22,7 @@ import it.integry.ems_model.annotation.Master;
|
|||||||
import it.integry.ems_model.base.EntityBase;
|
import it.integry.ems_model.base.EntityBase;
|
||||||
import it.integry.ems_model.base.EntityInterface;
|
import it.integry.ems_model.base.EntityInterface;
|
||||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
import it.integry.ems_model.exception.*;
|
import it.integry.ems_model.exception.EntityException;
|
||||||
import it.integry.ems_model.resolver.ResultSetSerializer;
|
import it.integry.ems_model.resolver.ResultSetSerializer;
|
||||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||||
import it.integry.ems_model.types.OperationType;
|
import it.integry.ems_model.types.OperationType;
|
||||||
@@ -38,14 +36,9 @@ import org.josql.QueryResults;
|
|||||||
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.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -97,7 +90,7 @@ public class EntityProcessor {
|
|||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (T) processEntity(entity, true, false, username, multiDBTransactionManager, true);
|
return (T) processEntity(entity, true, false, username, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBase processEntity(EntityInterface entity, boolean skipCommit, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
public EntityBase processEntity(EntityInterface entity, boolean skipCommit, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
@@ -108,13 +101,20 @@ public class EntityProcessor {
|
|||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (EntityBase) processEntity(entity, true, skipCommit, username, multiDBTransactionManager, true);
|
return (EntityBase) processEntity(entity, true, skipCommit, username, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityBase processEntity(EntityInterface entity, Boolean isSync,
|
public EntityBase processEntity(EntityInterface entity, Boolean isSync,
|
||||||
boolean skipCommit, String username,
|
boolean skipCommit, String username,
|
||||||
MultiDBTransactionManager mdb) throws Exception {
|
MultiDBTransactionManager mdb) throws Exception {
|
||||||
return (EntityBase) processEntity(entity, true, skipCommit, username, mdb, true);
|
return (EntityBase) processEntity(entity, isSync, skipCommit, username, mdb, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processEntity(EntityInterface entity, Boolean isSync,
|
||||||
|
boolean skipCommit, String username,
|
||||||
|
MultiDBTransactionManager mdb,
|
||||||
|
boolean completeEntity) throws Exception {
|
||||||
|
return processEntity(entity, isSync, skipCommit, username, mdb, completeEntity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,18 +132,19 @@ public class EntityProcessor {
|
|||||||
public Object processEntity(EntityInterface entity, Boolean isSync,
|
public Object processEntity(EntityInterface entity, Boolean isSync,
|
||||||
boolean skipCommit, String username,
|
boolean skipCommit, String username,
|
||||||
MultiDBTransactionManager mdb,
|
MultiDBTransactionManager mdb,
|
||||||
boolean completeEntity) throws Exception {
|
boolean completeEntity, boolean overrideEntityChildCheck) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
entity.setEntityHolder(entityPropertyHolder);
|
entity.setEntityHolder(entityPropertyHolder);
|
||||||
entity.setUsername(username);
|
entity.setUsername(username);
|
||||||
entity.setApplicationNameDB(mdb.getPrimaryDatasource().getProfile());
|
entity.setApplicationNameDB(mdb.getPrimaryDatasource().getProfile());
|
||||||
|
entity.setDbName(mdb.getPrimaryDatasource().getDbName());
|
||||||
entity.trimPK();
|
entity.trimPK();
|
||||||
if (entity.getOperation() == null) {
|
if (entity.getOperation() == null) {
|
||||||
entity.setOperation(OperationType.NO_OP);
|
entity.setOperation(OperationType.NO_OP);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.checkEntityChildsUsage(entity, mdb);
|
if (!overrideEntityChildCheck) this.checkEntityChildsUsage(entity, mdb);
|
||||||
|
|
||||||
if (settingsModel.isEnablePermissionCheck() && !checkUserPermissions(entity))
|
if (settingsModel.isEnablePermissionCheck() && !checkUserPermissions(entity))
|
||||||
throw new InvalidPermissionsException();
|
throw new InvalidPermissionsException();
|
||||||
@@ -154,23 +155,10 @@ public class EntityProcessor {
|
|||||||
return entity.selectAndMergeEntity(mdb.getPrimaryConnection(), (EntityBase) entity);
|
return entity.selectAndMergeEntity(mdb.getPrimaryConnection(), (EntityBase) entity);
|
||||||
//return entity;
|
//return entity;
|
||||||
} else if (entity.getOperation() == OperationType.SELECT) {
|
} else if (entity.getOperation() == OperationType.SELECT) {
|
||||||
String json = (String) entity.select(mdb.getPrimaryConnection());
|
|
||||||
if (json != null) {
|
|
||||||
EntityBase[] entityList = null;
|
|
||||||
//json to entity
|
|
||||||
if (json.charAt(0) == '[') {
|
|
||||||
entityList = jsonObjectMapper.readValue(json, EntityBase[].class);
|
|
||||||
} else if (json.charAt(0) == '{') {
|
|
||||||
EntityBase ent = jsonObjectMapper.readValue(json, EntityBase.class);
|
|
||||||
entityList = new EntityBase[]{ent};
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < entityList.length; i++) {
|
|
||||||
entityList[i].setOperation(entity.getOperation());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
List<? extends EntityBase> entityList = entity.select(mdb.getPrimaryConnection());
|
||||||
return entityList;
|
return entityList;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
processInternal(entity, isSync, mdb, completeEntity);
|
processInternal(entity, isSync, mdb, completeEntity);
|
||||||
}
|
}
|
||||||
@@ -351,12 +339,12 @@ public class EntityProcessor {
|
|||||||
|
|
||||||
|
|
||||||
//Se non c'è stata alcuna eccezione allora salvo il LLLLOOOOOGGG
|
//Se non c'è stata alcuna eccezione allora salvo il LLLLOOOOOGGG
|
||||||
// if (entity.getException() == null) {
|
if (entity.getException() == null) {
|
||||||
// entityLoggerService.log(multiDBTransactionManager.getDistributoreDatasource(), entity);
|
// entityLoggerService.log(multiDBTransactionManager.getDistributoreDatasource(), entity);
|
||||||
//
|
|
||||||
// if (!UtilityString.isNullOrEmpty(primaryProfileDB))
|
if (!UtilityString.isNullOrEmpty(currentDs.getProfile()))
|
||||||
// entityLoggerNewService.log(primaryProfileDB, requestDataDTO.getUsername(), entity);
|
entityLoggerNewService.log(currentDs.getProfile(), currentDs.getDbName(), requestDataDTO.getUsername(), entity);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -471,27 +459,22 @@ public class EntityProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean singleTransaction) throws SQLException, IOException, PrimaryDatabaseNotPresentException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean singleTransaction) throws Exception {
|
||||||
return processEntityList(null, true, singleTransaction, false, entities);
|
return processEntityList(entities, null, true, singleTransaction, false, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager, boolean singleTransaction) throws SQLException, IOException, PrimaryDatabaseNotPresentException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager, boolean singleTransaction) throws Exception {
|
||||||
return processEntityList(null, true, singleTransaction, false, entities, multiDBTransactionManager);
|
return processEntityList(entities, null, true, singleTransaction, false, multiDBTransactionManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws SQLException, IOException, PrimaryDatabaseNotPresentException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||||
return processEntityList(null, isSync, singleTransaction, ordinaSuPriorita, entities);
|
return processEntityList(entities, null, isSync, singleTransaction, ordinaSuPriorita, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws SQLException, IOException, PrimaryDatabaseNotPresentException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||||
return processEntityList(username, isSync, singleTransaction, ordinaSuPriorita, entities);
|
return processEntityList(entities, username, isSync, singleTransaction, ordinaSuPriorita, mDbTransactManager, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityBase> processEntityList(String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita, List<? extends EntityBase> entities) throws SQLException, IOException, PrimaryDatabaseNotPresentException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
|
||||||
return processEntityList(username, isSync, singleTransaction, ordinaSuPriorita, entities, mDbTransactManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity List Processor
|
* Entity List Processor
|
||||||
*
|
*
|
||||||
@@ -504,7 +487,12 @@ public class EntityProcessor {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public List<EntityBase> processEntityList(String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita, List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager) throws PrimaryDatabaseNotPresentException, SQLException, IOException, MergeEntityDBToObjectException, DataConverterNotFoundException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, IllegalAccessException, ConverterNotConfiguredException, InstantiationException, RulesNotCompiledException, InvocationTargetException {
|
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username,
|
||||||
|
boolean isSync,
|
||||||
|
boolean singleTransaction,
|
||||||
|
boolean ordinaSuPriorita,
|
||||||
|
MultiDBTransactionManager multiDBTransactionManager,
|
||||||
|
boolean completeEntity, boolean overrideEntityChildCheck) throws Exception {
|
||||||
|
|
||||||
if (UtilityString.isNullOrEmpty(username) && requestDataDTO != null && requestDataDTO.isValidUsername()) {
|
if (UtilityString.isNullOrEmpty(username) && requestDataDTO != null && requestDataDTO.isValidUsername()) {
|
||||||
username = requestDataDTO.getUsername();
|
username = requestDataDTO.getUsername();
|
||||||
@@ -517,13 +505,13 @@ public class EntityProcessor {
|
|||||||
entities = entityPropertyHolder.getEntityChain(entities, multiDBTransactionManager.getPrimaryDatasource().getConnection());
|
entities = entityPropertyHolder.getEntityChain(entities, multiDBTransactionManager.getPrimaryDatasource().getConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer prevTransactionGroupId = null;
|
Long prevTransactionGroupId = null;
|
||||||
|
|
||||||
for (int i = 0; i < entities.size(); i++) {
|
for (int i = 0; i < entities.size(); i++) {
|
||||||
EntityBase entity = entities.get(i);
|
EntityBase entity = entities.get(i);
|
||||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||||
try {
|
try {
|
||||||
EntityBase entityResult = (EntityBase) this.processEntity(entity, isSync, singleTransaction, username, multiDBTransactionManager, true);
|
EntityBase entityResult = (EntityBase) this.processEntity(entity, isSync, singleTransaction, username, multiDBTransactionManager, completeEntity, overrideEntityChildCheck);
|
||||||
prevTransactionGroupId = entity.getTransactionGroupId();
|
prevTransactionGroupId = entity.getTransactionGroupId();
|
||||||
if (entityResult != null) {
|
if (entityResult != null) {
|
||||||
entityList.add(entityResult);
|
entityList.add(entityResult);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.TrustManager;
|
import javax.net.ssl.TrustManager;
|
||||||
@@ -53,10 +54,6 @@ public class HttpRestWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse) throws NoSuchAlgorithmException, KeyManagementException {
|
|
||||||
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int callGenericGet(String url, String username, String password, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
public static int callGenericGet(String url, String username, String password, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
final Client client = makeDefaultConfig();
|
final Client client = makeDefaultConfig();
|
||||||
WebTarget webTarget = client.target(url);
|
WebTarget webTarget = client.target(url);
|
||||||
@@ -80,7 +77,15 @@ public class HttpRestWrapper {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse) throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, queryParams, RequestMethod.POST);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams, RequestMethod requestMethod) throws NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
|
||||||
Entity entity = null;
|
Entity entity = null;
|
||||||
|
|
||||||
@@ -103,43 +108,18 @@ public class HttpRestWrapper {
|
|||||||
|
|
||||||
Invocation.Builder request = addBaseHeader(webTarget.request(), username, password);
|
Invocation.Builder request = addBaseHeader(webTarget.request(), username, password);
|
||||||
if (contentType == APPLICATION_JSON) request = request.header("Content-Type", "application/json");
|
if (contentType == APPLICATION_JSON) request = request.header("Content-Type", "application/json");
|
||||||
Response response = request.post(entity);
|
Response response;
|
||||||
|
|
||||||
// boolean status = response.getStatus() == 200;
|
switch (requestMethod) {
|
||||||
int status = response.getStatus();
|
default:
|
||||||
bodyResponse.append(response.readEntity(String.class));
|
case POST:
|
||||||
|
response = request.post(entity);
|
||||||
response.close();
|
break;
|
||||||
client.close();
|
case PUT:
|
||||||
|
response = request.put(entity);
|
||||||
return status;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int callPutGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
|
|
||||||
|
|
||||||
Entity entity = null;
|
|
||||||
|
|
||||||
if (!UtilityString.isNullOrEmpty(jsonBody)) {
|
|
||||||
if (contentType == APPLICATION_JSON) {
|
|
||||||
entity = Entity.json(jsonBody);
|
|
||||||
} else if (contentType == TEXT_PLAIN) {
|
|
||||||
entity = Entity.text(jsonBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Client client = makeDefaultConfig();
|
|
||||||
WebTarget webTarget = client.target(url);
|
|
||||||
|
|
||||||
if (queryParams != null) {
|
|
||||||
for (String key : queryParams.keySet()) {
|
|
||||||
webTarget = webTarget.queryParam(key, queryParams.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Invocation.Builder request = addBaseHeader(webTarget.request(), username, password);
|
|
||||||
if (contentType == APPLICATION_JSON) request = request.header("Content-Type", "application/json");
|
|
||||||
Response response = request.put(entity);
|
|
||||||
|
|
||||||
// boolean status = response.getStatus() == 200;
|
// boolean status = response.getStatus() == 200;
|
||||||
int status = response.getStatus();
|
int status = response.getStatus();
|
||||||
bodyResponse.append(response.readEntity(String.class));
|
bodyResponse.append(response.readEntity(String.class));
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import java.io.*;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -552,13 +553,13 @@ public class MailService {
|
|||||||
|
|
||||||
public byte[] createEmlFile(StbActivityEmailObject emailObject) throws MessagingException, IOException {
|
public byte[] createEmlFile(StbActivityEmailObject emailObject) throws MessagingException, IOException {
|
||||||
Message message = new MimeMessage(Session.getInstance(System.getProperties()));
|
Message message = new MimeMessage(Session.getInstance(System.getProperties()));
|
||||||
message.setFrom(new InternetAddress(emailObject.getFrom().getDisplayName() + "<" + emailObject.getFrom().getEmailAddress() + ">"));
|
message.setFrom(new InternetAddress(emailObject.getFrom().getDisplayName().replaceAll(",", "") + "<" + emailObject.getFrom().getEmailAddress().replaceAll(",", "") + ">"));
|
||||||
message.setSentDate(emailObject.getDateTimeCreated());
|
message.setSentDate(emailObject.getDateTimeCreated());
|
||||||
|
|
||||||
List<InternetAddress> toList = Stream.of(emailObject.getTo())
|
List<InternetAddress> toList = Stream.of(emailObject.getTo())
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
try {
|
try {
|
||||||
return new InternetAddress(x.getDisplayName() + "<" + x.getEmailAddress() + ">");
|
return new InternetAddress(x.getDisplayName().replaceAll(",", "") + "<" + x.getEmailAddress().replaceAll(",", "") + ">");
|
||||||
} catch (AddressException e) {
|
} catch (AddressException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
return null;
|
return null;
|
||||||
@@ -572,6 +573,9 @@ public class MailService {
|
|||||||
|
|
||||||
String body = emailObject.getBody();
|
String body = emailObject.getBody();
|
||||||
|
|
||||||
|
if(body != null && emailObject.isBodyInBase64())
|
||||||
|
body = new String(Base64.decodeBase64(body), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
body = body.replaceAll("@.{8}\\..{8}", "");
|
body = body.replaceAll("@.{8}\\..{8}", "");
|
||||||
|
|
||||||
message.setSubject(emailObject.getSubject());
|
message.setSubject(emailObject.getSubject());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
|||||||
import it.integry.ems.utility.UtilityDirs;
|
import it.integry.ems.utility.UtilityDirs;
|
||||||
import it.integry.ems.utility.UtilityFile;
|
import it.integry.ems.utility.UtilityFile;
|
||||||
import it.integry.ems.utility.UtilityPdf;
|
import it.integry.ems.utility.UtilityPdf;
|
||||||
|
import it.integry.ems.utility.UtilityURL;
|
||||||
import it.integry.ems_model.entity.WtbJrept;
|
import it.integry.ems_model.entity.WtbJrept;
|
||||||
import it.integry.ems_model.entity.WtbJreptSetup;
|
import it.integry.ems_model.entity.WtbJreptSetup;
|
||||||
import it.integry.ems_model.service.SetupGest;
|
import it.integry.ems_model.service.SetupGest;
|
||||||
@@ -41,7 +42,12 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import javax.management.MBeanServer;
|
||||||
|
import javax.management.ObjectName;
|
||||||
|
import javax.management.Query;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -329,6 +335,14 @@ public class ReportProcessor {
|
|||||||
hm_parameters.put("ROOT_DIR", pathJrxmlHome);
|
hm_parameters.put("ROOT_DIR", pathJrxmlHome);
|
||||||
hm_parameters.put("SUBREPORT_DIR", this.getSubreportPath()/* pathJrxmlHome*/);
|
hm_parameters.put("SUBREPORT_DIR", this.getSubreportPath()/* pathJrxmlHome*/);
|
||||||
|
|
||||||
|
HashMap<String, String> ipAddressAndPort = UtilityURL.getIpAddressAndPort();
|
||||||
|
String url = null;
|
||||||
|
if ( ipAddressAndPort.get("host") != null ) {
|
||||||
|
url = ipAddressAndPort.get("host");
|
||||||
|
url = url + (UtilityHashMap.getValueIfExists(ipAddressAndPort, "port")!=null?":"+UtilityHashMap.getValueIfExists(ipAddressAndPort, "port"):"" );
|
||||||
|
}
|
||||||
|
hm_parameters.put("api_webservices", url);
|
||||||
|
|
||||||
JasperReportsContext jasperReportsContext = DefaultJasperReportsContext.getInstance();
|
JasperReportsContext jasperReportsContext = DefaultJasperReportsContext.getInstance();
|
||||||
jasperReportsContext.setProperty("net.sf.jasperreports.default.pdf.embedded", "true");
|
jasperReportsContext.setProperty("net.sf.jasperreports.default.pdf.embedded", "true");
|
||||||
jasperReportsContext.setProperty("net.sf.jasperreports.query.executer.factory.xmla-mdx", "net.sf.jasperreports.engine.query.JRXmlaQueryExecuterFactory");
|
jasperReportsContext.setProperty("net.sf.jasperreports.query.executer.factory.xmla-mdx", "net.sf.jasperreports.engine.query.JRXmlaQueryExecuterFactory");
|
||||||
|
|||||||
@@ -0,0 +1,277 @@
|
|||||||
|
package it.integry.ems.sync;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||||
|
import it.integry.annotations.PostContextConstruct;
|
||||||
|
import it.integry.ems.datasource.DataSource;
|
||||||
|
import it.integry.ems.json.JSONObjectMapper;
|
||||||
|
import it.integry.ems.looper.service.LooperService;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryGroupDTO;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryItemDTO;
|
||||||
|
import it.integry.ems.sync.dto.ExportHistoryStatusDTO;
|
||||||
|
import it.integry.ems.sync.dto.PublicationDTO;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||||
|
import it.integry.ems_model.entity.StbPublications;
|
||||||
|
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||||
|
import it.integry.ems_model.entity.StbTransactionLog;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AsyncHistoryManager {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LooperService looperService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntityPropertyHolder entityPropertyHolder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JSONObjectMapper jsonObjectMapper;
|
||||||
|
|
||||||
|
//Implement check list like distribuzione
|
||||||
|
private final AtomicReference<List<ExportHistoryGroupDTO>> currentlyInExecutionG = new AtomicReference<>(new ArrayList<>());
|
||||||
|
|
||||||
|
|
||||||
|
@PostContextConstruct
|
||||||
|
public void init() {
|
||||||
|
this.looperService.add(this::consumeRetrieveQueue, 10 * 1000, "async-history-read");
|
||||||
|
this.looperService.add(this::consumeProcessedQueue, 2 * 1000, "async-history-save");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToExportQueue(DataSource dataSource, long groupId, PublicationDTO publication) throws Exception {
|
||||||
|
|
||||||
|
tryAddInExecutionList(groupId, dataSource, new ExportHistoryItemDTO()
|
||||||
|
.setPublication(publication));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryAddInExecutionList(long groupId, DataSource dataSource, ExportHistoryItemDTO exportHistoryItemDTO) throws Exception {
|
||||||
|
|
||||||
|
ExportHistoryGroupDTO currentlyInExec = currentlyInExecutionG.get().stream()
|
||||||
|
.filter(x -> x.getGroupId() == groupId)
|
||||||
|
.findFirst().orElseGet(() ->
|
||||||
|
{
|
||||||
|
final ExportHistoryGroupDTO exportHistoryGroupDTO = new ExportHistoryGroupDTO()
|
||||||
|
.setDataSource(dataSource)
|
||||||
|
.setGroupId(groupId);
|
||||||
|
|
||||||
|
currentlyInExecutionG.get().add(exportHistoryGroupDTO);
|
||||||
|
return exportHistoryGroupDTO;
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ExportHistoryItemDTO> list = currentlyInExec.getItems();
|
||||||
|
final boolean alreadyRegistered = list.stream()
|
||||||
|
.anyMatch(x -> x.getPublication().getId() == exportHistoryItemDTO.getPublication().getId());
|
||||||
|
|
||||||
|
if (alreadyRegistered) {
|
||||||
|
throw new Exception("Il sistema sta già elaborando questa publication");
|
||||||
|
}
|
||||||
|
|
||||||
|
currentlyInExec.setTotalItemCount(currentlyInExec.getTotalItemCount() + countExistingItems(dataSource, exportHistoryItemDTO));
|
||||||
|
|
||||||
|
list.add(exportHistoryItemDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void consumeRetrieveQueue() {
|
||||||
|
|
||||||
|
for (ExportHistoryGroupDTO currentGroup : currentlyInExecutionG.get()) {
|
||||||
|
List<ExportHistoryItemDTO> entitiesToExport = currentGroup.getItems();
|
||||||
|
|
||||||
|
if (currentGroup.getStartTime() != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
currentGroup.setStartTime(UtilityLocalDate.getNowTime());
|
||||||
|
|
||||||
|
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
||||||
|
try {
|
||||||
|
internalExportEntity(currentGroup, entityToExport);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
logger.error(ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentGroup.setCompletedRead(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void internalExportEntity(ExportHistoryGroupDTO exportHistoryGroup, ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||||
|
if (entityHistoryToExport.getStartDate() == null)
|
||||||
|
entityHistoryToExport.setStartDate(UtilityLocalDate.getNowTime());
|
||||||
|
|
||||||
|
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(exportHistoryGroup.getDataSource().getProfile())) {
|
||||||
|
retrieveEntitiesByChunk(newConnection.getPrimaryConnection(), exportHistoryGroup, entityHistoryToExport, entityClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long countExistingItems(DataSource dataSource, ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||||
|
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(dataSource.getProfile())) {
|
||||||
|
String sql = "SELECT CONVERT(BIGINT, COUNT(*)) FROM " + entityClass.newInstance().getTableName();
|
||||||
|
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(newConnection.getPrimaryConnection(), sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void retrieveEntitiesByChunk(Connection connection, ExportHistoryGroupDTO exportHistoryGroup, ExportHistoryItemDTO exportHistoryItem, Class<? extends EntityBase> entityClass) throws Exception {
|
||||||
|
|
||||||
|
String innerSql = "SELECT * " +
|
||||||
|
"FROM " + exportHistoryItem.getPublication().getEntityName();
|
||||||
|
innerSql = UtilityDB.addwhereCond(innerSql, exportHistoryItem.getPublication().getWhereCondSql(), true);
|
||||||
|
|
||||||
|
UtilityDB.executeSimpleQueryDTOAsync(connection, innerSql, entityClass, data -> {
|
||||||
|
|
||||||
|
exportHistoryGroup.setProcessedItemCount(exportHistoryGroup.getProcessedItemCount() + 1);
|
||||||
|
// exportHistoryItem.getToProcessQueue().add(JSON.toJSONString(data));
|
||||||
|
|
||||||
|
data.setOperation(OperationType.INSERT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
exportHistoryGroup.getToProcessQueue().add(new AbstractMap.SimpleEntry<>(exportHistoryItem.getPublication().getEntityName(), jsonObjectMapper.writeValueAsString(data)));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while ((float) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().totalMemory() > 0.9f) {
|
||||||
|
logger.debug("Memory limit reached: " + (((float) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().totalMemory()) * 100) + "%");
|
||||||
|
try {
|
||||||
|
Thread.sleep(1 * 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void consumeProcessedQueue() {
|
||||||
|
List<ExportHistoryGroupDTO> list = currentlyInExecutionG.get();
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
ExportHistoryGroupDTO currentGroup = list.get(i);
|
||||||
|
try {
|
||||||
|
internalProcessQueue(currentGroup);
|
||||||
|
|
||||||
|
if (currentGroup.isCompletedRead() && currentGroup.getEndTime() == null) {
|
||||||
|
currentGroup.setEndTime(UtilityLocalDate.getNowTime());
|
||||||
|
updateReadyToTransmit(currentGroup);
|
||||||
|
list.remove(i--);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentGroup.getDataSource().getConnection().commit();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
logger.error(ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalProcessQueue(ExportHistoryGroupDTO currentGroup) throws Exception {
|
||||||
|
String insertSQL = "INSERT INTO " + StbTransactionLog.ENTITY + " (publication_group_id, created_at, user_name, entities, entities_json, group_id)" +
|
||||||
|
" VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(currentGroup.getDataSource().getProfile())) {
|
||||||
|
|
||||||
|
while (!currentGroup.getToProcessQueue().isEmpty()) {
|
||||||
|
try (SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||||
|
Map.Entry<String, String> entityJson;
|
||||||
|
while ((entityJson = currentGroup.getToProcessQueue().poll()) != null) {
|
||||||
|
insertBulkPs.setLong(1, currentGroup.getGroupId());
|
||||||
|
insertBulkPs.setObject(2, UtilityLocalDate.getNowTime());
|
||||||
|
insertBulkPs.setString(3, null);
|
||||||
|
insertBulkPs.setString(4, entityJson.getKey());
|
||||||
|
insertBulkPs.setString(5, entityJson.getValue());
|
||||||
|
insertBulkPs.setLong(6, Long.MIN_VALUE + currentGroup.getSyncronizedItemCount());
|
||||||
|
|
||||||
|
insertBulkPs.addBatch();
|
||||||
|
currentGroup.setSyncronizedItemCount(currentGroup.getSyncronizedItemCount() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
insertBulkPs.executeLargeBatch();
|
||||||
|
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateReadyToTransmit(ExportHistoryGroupDTO exportHistoryGroup) throws Exception {
|
||||||
|
StbPublications stbPublications = new StbPublications()
|
||||||
|
.setId(exportHistoryGroup.getGroupId());
|
||||||
|
stbPublications.setOperation(OperationType.NO_OP);
|
||||||
|
|
||||||
|
stbPublications.setStbPublicationsDetails(exportHistoryGroup.getItems().stream()
|
||||||
|
.map(x -> {
|
||||||
|
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||||
|
.setId(x.getPublication().getId())
|
||||||
|
.setReadyToTransmit(true);
|
||||||
|
|
||||||
|
stbPublicationsDetail.setOperation(OperationType.UPDATE);
|
||||||
|
return stbPublicationsDetail;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
stbPublications.manageWithParentConnection(exportHistoryGroup.getDataSource().getConnection());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExportHistoryStatusDTO> getStatus() {
|
||||||
|
List<ExportHistoryStatusDTO> statusList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ExportHistoryGroupDTO currentGroup : currentlyInExecutionG.get()) {
|
||||||
|
|
||||||
|
final LocalDateTime startDate = currentGroup.getStartTime();
|
||||||
|
|
||||||
|
long totalCount = 0;
|
||||||
|
long processedCount = 0;
|
||||||
|
long itemsPerSec = 1;
|
||||||
|
LocalDateTime estimatedEnd = currentGroup.getEndTime();
|
||||||
|
|
||||||
|
if (startDate != null) {
|
||||||
|
totalCount = currentGroup.getTotalItemCount();
|
||||||
|
processedCount = currentGroup.getSyncronizedItemCount();
|
||||||
|
|
||||||
|
final long secondsBetween = ChronoUnit.SECONDS.between(startDate, estimatedEnd != null ? estimatedEnd : UtilityLocalDate.getNowTime());
|
||||||
|
itemsPerSec = processedCount / (secondsBetween == 0 ? 1 : secondsBetween);
|
||||||
|
|
||||||
|
double secsToEnd = (double) totalCount / (itemsPerSec == 0 ? 1 : itemsPerSec);
|
||||||
|
estimatedEnd = startDate.plusSeconds((long) secsToEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
statusList.add(new ExportHistoryStatusDTO()
|
||||||
|
.setPublicationGroupId(currentGroup.getGroupId())
|
||||||
|
.setStartedAt(startDate)
|
||||||
|
.setTotalCount(totalCount)
|
||||||
|
.setProcessedCount(processedCount)
|
||||||
|
.setSpeedPerMinute((int) (itemsPerSec * 60))
|
||||||
|
.setEstimatedEnd(estimatedEnd));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return statusList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user