Compare commits
361 Commits
20240131_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 | |||
| 9f2b70f03c | |||
| ee1a22fcce | |||
| 265de6ffd2 | |||
| f363269313 | |||
| 4cc3732e30 | |||
| 42237f463f | |||
| 81b312e14b | |||
| cc8f17cad5 | |||
| 3a6556cce2 | |||
| 48b7621291 | |||
| 45cd5bd53b | |||
| ffee3197e2 | |||
| 1242f95270 | |||
| b1bd3ac5ad | |||
| c0dc4afd3b | |||
| f12428ae62 | |||
| c14f99fc3a | |||
| 20822a5755 | |||
| 0d923a10d1 | |||
| 838482171f | |||
| f0e5beac2e | |||
| 04be79d70a | |||
| d6666dff10 | |||
| b7c214fee2 | |||
| 467a763502 | |||
| 3b8fbd02dd | |||
| 224cf2a2b6 | |||
| 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/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.01.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/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/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/binding.jxb -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-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.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-core: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.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.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:httpcore:4.3.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" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="PWA">
|
||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||
@@ -829,6 +831,44 @@
|
||||
</option>
|
||||
</method>
|
||||
</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">
|
||||
<option name="COMMON_VM_ARGUMENTS" value="-DDISABLE_DROOLS_COMPILE=TRUE -Xms256m -Xmx1024m -XX:PermSize=1024m" />
|
||||
<deployment>
|
||||
@@ -900,6 +940,21 @@
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
</SHUTDOWN>
|
||||
</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">
|
||||
<option name="USE_ENV_VARIABLES" value="true" />
|
||||
<STARTUP>
|
||||
@@ -1065,6 +1120,42 @@
|
||||
<root url="jar://$MAVEN_REPOSITORY$/c3p0/c3p0/0.9.1.1/c3p0-0.9.1.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</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">
|
||||
<properties groupId="com.amazonservices.mws" artifactId="MWSClientJavaRuntime" version="1.1" />
|
||||
<CLASSES>
|
||||
@@ -1449,16 +1540,16 @@
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: com.google.code.gson:gson:2.5" type="java-imported" external-system-id="Maven">
|
||||
<properties groupId="com.google.code.gson" artifactId="gson" version="2.5" />
|
||||
<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.9.1" />
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</library>
|
||||
<library name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" type="java-imported" external-system-id="Maven">
|
||||
|
||||
@@ -83,6 +83,9 @@
|
||||
<classes>
|
||||
<class>it.integry.ems.response.ServiceRestResponse</class>
|
||||
</classes>
|
||||
<excludeClasses>
|
||||
<excludeClass>it.integry.ems_model.base.EntityInterface</excludeClass>
|
||||
</excludeClasses>
|
||||
<outputFile>../ts/ems-core.module.ts</outputFile>
|
||||
<outputKind>module</outputKind>
|
||||
<outputFileType>implementationFile</outputFileType>
|
||||
@@ -434,6 +437,12 @@
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.47</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
||||
@@ -359,7 +359,7 @@ public class WooCommerceArticoliDataManager {
|
||||
" where cod_mdep = dbo.getGestSetup('WOOCOMMERCE','SETUP','COD_MDEP')";
|
||||
|
||||
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);
|
||||
|
||||
@@ -35,6 +35,12 @@ public class CommonConstants {
|
||||
public static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern(CommonConstants.TIME_FORMAT)
|
||||
.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)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
@@ -37,17 +37,10 @@ public class BooleanDeserializer extends JsonDeserializer<Boolean> {
|
||||
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");
|
||||
}
|
||||
// Otherwise, no can do:
|
||||
throw ctxt.mappingException(_valueClass);
|
||||
throw ctxt.instantiationException(_valueClass, "error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,76 +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.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
|
||||
) throws Exception {
|
||||
asyncServiceNew.startSync(subscriptionName);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@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
|
||||
) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(asyncServiceNew.retrieveTransactions(limit));
|
||||
}
|
||||
|
||||
|
||||
@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) throws Exception {
|
||||
|
||||
asyncServiceNew.updateTransactionImportCounterInDB(transactionImportID, publicationID, sender);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,35 +0,0 @@
|
||||
package it.integry.ems.async.dto;
|
||||
|
||||
public class SyncConfigDTO
|
||||
{
|
||||
private String endpoint;
|
||||
private String profileDb;
|
||||
private String username;
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public SyncConfigDTO setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getProfileDb() {
|
||||
return profileDb;
|
||||
}
|
||||
|
||||
public SyncConfigDTO setProfileDb(String profileDb) {
|
||||
this.profileDb = profileDb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public SyncConfigDTO setUsername(String username) {
|
||||
this.username = username;
|
||||
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,340 +0,0 @@
|
||||
package it.integry.ems.async.service;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.async.dto.SubscriptionDTO;
|
||||
import it.integry.ems.async.dto.SyncConfigDTO;
|
||||
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);
|
||||
|
||||
if(UtilityString.isNullOrEmpty(jsonConfigurationString))
|
||||
throw new Exception("Nessuna configurazione trovata per la sincronizzazione: " + subscriptionName);
|
||||
|
||||
final List<SyncConfigDTO> syncConfigs = jsonObjectMapper.readValue(jsonConfigurationString, new TypeReference<List<SyncConfigDTO>>() {
|
||||
});
|
||||
|
||||
for (SyncConfigDTO syncConfig : syncConfigs) {
|
||||
String wsUrlEndpoint = syncConfig.getEndpoint() + EmsRestConstants.PATH_ASYNC_BASE_ROUTE + EmsRestConstants.PATH_ASYNC_RETRIEVE_TRANSACTIONS;
|
||||
|
||||
HashMap<String, String> queryParams = new HashMap<>();
|
||||
queryParams.put("profileDb", syncConfig.getProfileDb());
|
||||
|
||||
boolean shouldStop = false;
|
||||
|
||||
int importedTransactionsCounter = 0;
|
||||
|
||||
do {
|
||||
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
int status = HttpRestWrapper.callGenericGet(wsUrlEndpoint, syncConfig.getUsername(), syncConfig.getUsername(), 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.isEmpty() || transactions.get(0).isEmpty()) {
|
||||
if (importedTransactionsCounter == 0) logger.debug("Nessuna entity da sincronizzare");
|
||||
else logger.debug("Sincronizzazione OFFLINE terminata");
|
||||
shouldStop = true;
|
||||
} else {
|
||||
importedTransactionsCounter +=
|
||||
importTransactions(syncConfig.getEndpoint(), syncConfig.getProfileDb(), syncConfig.getUsername(), 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 (List<TransactionDTO> transactionDTOS : transactionList) {
|
||||
final List<Integer> transactionsIDGroups = new ArrayList<>();
|
||||
|
||||
for (TransactionDTO dto : transactionDTOS) {
|
||||
if (!transactionsIDGroups.contains(dto.transactionGroupId))
|
||||
transactionsIDGroups.add(dto.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(transactionDTOS)
|
||||
.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.isEmpty()) {
|
||||
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<>();
|
||||
|
||||
if (obj != null) {
|
||||
if (obj instanceof EntityBase[]) {
|
||||
entityList = Arrays.asList((EntityBase[]) obj);
|
||||
if (obj instanceof List) {
|
||||
entityList = (List<EntityBase>) obj;
|
||||
} else {
|
||||
entityList.add((EntityBase) obj);
|
||||
}
|
||||
@@ -705,7 +705,7 @@ public class EmsController {
|
||||
if (ordinaSuPriorita)
|
||||
entityList = entityPropertyHolder.getEntityChain(entityList, multiDBTransactionManager.getPrimaryConnection());
|
||||
|
||||
Integer prevTransactionGroupId = null;
|
||||
Long prevTransactionGroupId = null;
|
||||
|
||||
for (EntityBase entity : entityList) {
|
||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||
@@ -726,6 +726,7 @@ public class EmsController {
|
||||
|
||||
responseList.add(response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(request.getRequestURI(), e);
|
||||
response = new ServiceRestResponse(EsitoType.KO, e, multiDBTransactionManager.getPrimaryDatasource().getProfile(), entity);
|
||||
responseList.add(response);
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -61,6 +62,10 @@ public class DataSource {
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
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," +
|
||||
" user_name() AS [user_name]," +
|
||||
" suser_name() AS [suser_name]," +
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityHierarchyDTO {
|
||||
|
||||
private Class<? extends EntityBase> clazz;
|
||||
private String entityName;
|
||||
private String tableName;
|
||||
private Field field;
|
||||
private boolean master;
|
||||
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() {
|
||||
return entityName;
|
||||
}
|
||||
@@ -24,6 +39,24 @@ public class EntityHierarchyDTO {
|
||||
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() {
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ExtendedStbActivity {
|
||||
private String codJcom;
|
||||
private String codAnag;
|
||||
private String personaRif;
|
||||
private String emailPersonaRif;
|
||||
private String userName;
|
||||
private String userCreator;
|
||||
private String note;
|
||||
@@ -70,6 +71,15 @@ public class ExtendedStbActivity {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmailPersonaRif() {
|
||||
return emailPersonaRif;
|
||||
}
|
||||
|
||||
public ExtendedStbActivity setEmailPersonaRif(String emailPersonaRif) {
|
||||
this.emailPersonaRif = emailPersonaRif;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class StbActivityEmailObject {
|
||||
private String subject;
|
||||
private List<StbActivityEmailObjectAddress> to;
|
||||
private String body;
|
||||
private boolean bodyInBase64;
|
||||
private List<StbActivityEmailObjectAttachment> attachments;
|
||||
|
||||
public StbActivityEmailObjectAddress getFrom() {
|
||||
@@ -77,6 +78,15 @@ public class StbActivityEmailObject {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isBodyInBase64() {
|
||||
return bodyInBase64;
|
||||
}
|
||||
|
||||
public StbActivityEmailObject setBodyInBase64(boolean bodyInBase64) {
|
||||
this.bodyInBase64 = bodyInBase64;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<StbActivityEmailObjectAttachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.swing.text.html.parser.Entity;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -34,7 +33,8 @@ public class DynamicCacheService {
|
||||
|
||||
public enum Keys {
|
||||
DATI_AZIENDA_KEY,
|
||||
ENTITY_LOGGER_SETUP
|
||||
ENTITY_LOGGER_SETUP,
|
||||
GRIGLIA_ACQUISTO_KEY
|
||||
}
|
||||
|
||||
public void addItem(Keys key, int invalidateTimeInMins, RunnableWithReturn<Object> refreshAction) {
|
||||
@@ -79,14 +79,14 @@ public class DynamicCacheService {
|
||||
}
|
||||
|
||||
|
||||
public <T extends EntityBase>List<T> getEntity(Keys key, String dbName) {
|
||||
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;
|
||||
if (cachedEntitiesByDB == null) return null;
|
||||
|
||||
final List<T> cachedEntityList = (List<T>) cachedEntitiesByDB.getOrDefault(dbName, null);
|
||||
if(cachedEntityList == null) return null;
|
||||
if (cachedEntityList == null) return null;
|
||||
|
||||
return cachedEntityList;
|
||||
}
|
||||
@@ -99,11 +99,60 @@ public class DynamicCacheService {
|
||||
String sql = "SELECT * FROM " + tableName;
|
||||
List<? extends EntityBase> entities = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, clazz);
|
||||
|
||||
cachedEntitiesByDB.putIfAbsent(dbName, entities);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 execTime = (stopTime - startTime) / 1000000000;
|
||||
// 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;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.gentlyweb.utils.GeneralUtils;
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
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.settings.Model.SettingsModel;
|
||||
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.config.EmsRestConstants;
|
||||
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.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityServer;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MigrationService {
|
||||
@@ -48,17 +52,27 @@ public class MigrationService {
|
||||
@PostContextAutowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
private List<Class<? extends MigrationModelInterface>> allMigrationsList;
|
||||
|
||||
private final HashMap<String, Boolean> migrationsErrorMapByProfiles = new HashMap<>();
|
||||
|
||||
@PostContextConstruct
|
||||
public void init() {
|
||||
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)
|
||||
.filter(x -> !Modifier.isAbstract(x.getModifiers()))
|
||||
.sortBy(Class::getSimpleName)
|
||||
.toList());
|
||||
|
||||
if (UtilityDebug.isDebugExecution())
|
||||
return;
|
||||
|
||||
startMigrationsGlobally(multiDBTransactionManager);
|
||||
}
|
||||
|
||||
public void startMigrationsGlobally(MultiDBTransactionManager multiDBTransactionManager) {
|
||||
List<AdvancedDataSource> advancedDataSources;
|
||||
|
||||
try {
|
||||
@@ -72,93 +86,52 @@ public class MigrationService {
|
||||
logger.error("MigrationService - Init", e);
|
||||
}
|
||||
|
||||
//ArrayList<Runnable> calls = new ArrayList<>();
|
||||
|
||||
for (final AdvancedDataSource advancedDataSource : advancedDataSources) {
|
||||
|
||||
//calls.add(() -> {
|
||||
|
||||
try {
|
||||
initLastVersionField(advancedDataSource);
|
||||
|
||||
for (Class<? extends MigrationModelInterface> migrationClass : clssList) {
|
||||
try {
|
||||
|
||||
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
||||
long lastMigration = getLastMigrationFromDB(advancedDataSource);
|
||||
|
||||
if (migrationNumber <= lastMigration) continue;
|
||||
|
||||
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
||||
|
||||
advancedDataSource.getConnection().commit();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() +")", e);
|
||||
|
||||
try {
|
||||
advancedDataSource.getConnection().rollback();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("MigrationService - Rollback", ex);
|
||||
}
|
||||
|
||||
if(UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) break;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//});
|
||||
executeMigrationGroup(advancedDataSource);
|
||||
}
|
||||
|
||||
// try {
|
||||
// UtilityThread.executeParallel(calls);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("MigrationService", e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
private void initLastVersionField(AdvancedDataSource advancedDataSource) throws Exception {
|
||||
public void executeMigrationGroup(AdvancedDataSource advancedDataSource) {
|
||||
try {
|
||||
migrateStatus(advancedDataSource);
|
||||
List<StbMigrationStatus> migrationStatuses = retrieveAllMigrationsStatus(advancedDataSource);
|
||||
|
||||
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')";
|
||||
for (Class<? extends MigrationModelInterface> migrationClass : allMigrationsList) {
|
||||
long migrationNumber = Long.parseLong(migrationClass.getSimpleName().replace("Migration_", ""));
|
||||
|
||||
boolean fieldExists = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
||||
if (migrationStatuses.stream().anyMatch(x -> x.getMigrationCode() == migrationNumber && (x.isCompleted() || x.isSkipped())))
|
||||
continue;
|
||||
|
||||
if (!fieldExists) {
|
||||
String alterTableSql = "ALTER TABLE azienda ADD last_migration VARCHAR(14)";
|
||||
Statement statement = advancedDataSource.getConnection().createStatement();
|
||||
statement.execute(alterTableSql);
|
||||
statement.close();
|
||||
try {
|
||||
//LocalDateTime startTime = UtilityLocalDate.getNowTime();
|
||||
executeMigration(migrationClass, advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||
//logger.debug("MIGRATION TIME: " + ChronoUnit.SECONDS.between(startTime, UtilityLocalDate.getNowTime()));
|
||||
|
||||
// String updateSql = "UPDATE azienda SET last_migration = " + UtilityDB.valueToString(settingsModel.getLastMigration());
|
||||
// PreparedStatement ps = advancedDataSource.getConnection().prepareStatement(updateSql);
|
||||
// ps.executeUpdate();
|
||||
// ps.close();
|
||||
updateLastMigrationIntoDB(advancedDataSource, migrationNumber);
|
||||
|
||||
advancedDataSource.getConnection().commit();
|
||||
advancedDataSource.getConnection().commit();
|
||||
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
advancedDataSource.getConnection().rollback();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("MigrationService - Rollback", ex);
|
||||
}
|
||||
|
||||
trackMigrationError(advancedDataSource, migrationNumber, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
migrationsErrorMapByProfiles.putIfAbsent(advancedDataSource.getProfileName(), false);
|
||||
migrationsErrorMapByProfiles.replace(advancedDataSource.getProfileName(), false);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("MigrationService (" + advancedDataSource.getProfileName() + ")", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +146,65 @@ public class MigrationService {
|
||||
MigrationModelInterface migrationInstance = migrationClass.newInstance();
|
||||
migrationInstance.init(advancedDataSource, settingsController, settingsModel, droolsDataCompleting);
|
||||
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 {
|
||||
@@ -183,13 +215,65 @@ public class MigrationService {
|
||||
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.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.rulescompleting.DroolsDataCompleting;
|
||||
|
||||
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;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
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.Stream;
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.StbUser;
|
||||
import it.integry.ems_model.entity.WtbUsers;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
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.service.AutomatedOperationHandlerComponent;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||
import it.integry.ems_model.entity.MtbDepo;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.StbUser;
|
||||
import it.integry.ems_model.entity.WtbUsers;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.settings.Model.MailConfigurationModel;
|
||||
import it.integry.ems_model.entity.StbEmail;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.service.PrinterService;
|
||||
import it.integry.ems_model.entity.GrlAnagJrept;
|
||||
import it.integry.ems_model.entity.MtbDepo;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
import java.sql.Statement;
|
||||
|
||||
@@ -3,8 +3,8 @@ package it.integry.ems.migration.model;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.io.Encoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.Azienda;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20221128132717 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20230406164731 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.media.MimeTypesHandler;
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20230414183851 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20230419161529 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
|
||||
public class Migration_20231130152938 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.dto.IndexTableDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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.ObjectMapper;
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
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.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
|
||||
import javax.json.Json;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class Migration_20231201161808 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration.model._base.BaseMigration;
|
||||
import it.integry.ems.migration.model._base.MigrationModelInterface;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.StbGestSetup;
|
||||
import it.integry.ems_model.entity.StbGestSetupDepo;
|
||||
import it.integry.ems_model.entity.StbGestSetupDet;
|
||||
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.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import org.json.JSONArray;
|
||||
|
||||
|
||||
@@ -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 org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.kie.api.runtime.rule.ConsequenceException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
@@ -80,9 +79,6 @@ public class ServiceRestResponse {
|
||||
public ServiceRestResponse(EsitoType esito, String profileDb, Exception e) {
|
||||
this(esito);
|
||||
|
||||
if (esito == EsitoType.KO)
|
||||
e.printStackTrace();
|
||||
|
||||
this.profileDB = profileDb;
|
||||
this.errorType = e.getClass().getCanonicalName();
|
||||
this.errorMessage = e.getMessage();
|
||||
|
||||
@@ -447,31 +447,31 @@ public class AccountingBusinessLogic {
|
||||
if (UtilityString.isNullOrEmpty(tipoPartita)) tipoPartita = 1;
|
||||
|
||||
BigDecimal impScad = ctbScadOrig.getImpDare().subtract(ctbScadOrig.getImpAvere());
|
||||
Date dataPag = ctbScadOrig.getDataPag();
|
||||
impScad = impScad.abs();
|
||||
|
||||
if (residuo.compareTo(BigDecimal.ZERO) > 0 && dataPag == null) {
|
||||
if (!UtilityBigDecimal.isNullOrZero(residuo) && ctbScadOrig.getDataPag() == null ) {
|
||||
residuo = residuo.abs();
|
||||
if (residuo.compareTo(impScad) >= 0) {
|
||||
if (residuo.equals(impScad)) {
|
||||
if (UtilityBigDecimal.equalsOrGreaterThan(residuo, impScad)) {
|
||||
if (UtilityBigDecimal.equalsTo(residuo, impScad)) {
|
||||
residuo = BigDecimal.ZERO;
|
||||
} 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
|
||||
// registrazione dei titoli
|
||||
if (tipoPartita == 1 || countScad == 1) {
|
||||
if (tipoPartita == TipoPartita.ATTIVA.getValue() || countScad == 1) {
|
||||
residuo = residuo.subtract(impScad);
|
||||
} else if (tipoPartita == 0) {
|
||||
residuo = residuo.add(impScad);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctbScadOrig.getImpDare().compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (!UtilityBigDecimal.isNullOrZero(ctbScadOrig.getImpDare())) {
|
||||
ctbScadOrig.setImpAvere(impScad);
|
||||
} else {
|
||||
ctbScadOrig.setImpDare(impScad);
|
||||
}
|
||||
ctbScadOrig.setDataPag(dataCmov);
|
||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
} else {
|
||||
//Clona scadenza
|
||||
CtbScad ctbScadNew = (CtbScad) ctbScadOrig.clone();
|
||||
@@ -481,6 +481,7 @@ public class AccountingBusinessLogic {
|
||||
ctbScadOrig.setImpAvere(residuo);
|
||||
ctbScadOrig.setDataPag(dataCmov);
|
||||
ctbScadOrig.setIdRigaMov(idRigaMov);
|
||||
ctbScadOrig.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
|
||||
// calcola importo residuo della nuova scadenza
|
||||
residuo = residuo.subtract(impScad);
|
||||
@@ -494,6 +495,7 @@ public class AccountingBusinessLogic {
|
||||
} else {
|
||||
ctbScadNew.setImpAvere(residuo.abs());
|
||||
}
|
||||
residuo = BigDecimal.ZERO;
|
||||
}
|
||||
}
|
||||
elencoScadenzeNew.add(ctbScadOrig);
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static it.integry.ems.rules.completing.QueryRules.getSingleValue;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class LoadColliService {
|
||||
@@ -262,6 +264,16 @@ public class LoadColliService {
|
||||
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));
|
||||
|
||||
//AGGIUNGERE CAMPI CHE PASSIAMO DA FUORI
|
||||
@@ -585,7 +597,8 @@ public class LoadColliService {
|
||||
" dtb_ordr.cod_promo as 'cod_promo', " +
|
||||
" dtb_ordr.cod_art_for as 'cod_art_for', " +
|
||||
" 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_ord3, mtb_aart.unt_mis3) as 'unt_doc3', " +
|
||||
" mtb_aart.tara_kg as 'tara_kg', " +
|
||||
@@ -652,7 +665,8 @@ public class LoadColliService {
|
||||
" mtb_aart.flag_stato, " +
|
||||
" dtb_ordr.cod_art_for, " +
|
||||
" 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_ord3, mtb_aart.unt_mis3), " +
|
||||
" mtb_aart.tara_kg, " +
|
||||
|
||||
@@ -18,4 +18,8 @@ public enum TipoPartita {
|
||||
}
|
||||
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 java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -67,19 +68,23 @@ public class AccountingRules extends QueryRules {
|
||||
Integer numIreg = entity.getNumIreg();
|
||||
Integer numProt = entity.getNumProt();
|
||||
|
||||
if (numIreg == 0) {
|
||||
numIreg = 1;
|
||||
entity.setNumIreg(numIreg);
|
||||
}
|
||||
|
||||
if (numProt == null) numProt = 0;
|
||||
String sql =
|
||||
"SELECT num_prot "
|
||||
"SELECT Cast(count(*) as bit)"
|
||||
+ "FROM ctb_inum "
|
||||
+ "WHERE cod_ireg = " + UtilityDB.valueToString(codIreg) + " AND "
|
||||
+ " num_ireg = " + UtilityDB.valueToString(numIreg) + " AND "
|
||||
+ " anno = " + UtilityDB.valueToString(annoComp);
|
||||
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
CallableStatement cs = connection.prepareCall("{call dbo.NextNumProt(?, ?, ?, ?)}");
|
||||
boolean existReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
|
||||
if (existReg) {
|
||||
CallableStatement cs = connection.prepareCall("{call dbo.NextNumProt(?, ?, ?, ?)}");
|
||||
cs.setShort(1, annoComp.shortValue());
|
||||
cs.setString(2, codIreg);
|
||||
cs.setShort(3, numIreg.shortValue());
|
||||
@@ -89,12 +94,13 @@ public class AccountingRules extends QueryRules {
|
||||
numProt = cs.getInt(4);
|
||||
cs.close();
|
||||
} else {
|
||||
numProt = 1;
|
||||
CtbInum ctbInum = new CtbInum();
|
||||
ctbInum.setAnno(annoComp);
|
||||
ctbInum.setCodIreg(codIreg);
|
||||
ctbInum.setNumIreg(numIreg);
|
||||
ctbInum.setNumProt(numProt);
|
||||
if (numProt == 0) numProt = 1;
|
||||
CtbInum ctbInum =
|
||||
new CtbInum()
|
||||
.setAnno(annoComp)
|
||||
.setCodIreg(codIreg)
|
||||
.setNumIreg(numIreg)
|
||||
.setNumProt(numProt);
|
||||
entity.setCtbInum(ctbInum);
|
||||
}
|
||||
|
||||
@@ -446,6 +452,7 @@ public class AccountingRules extends QueryRules {
|
||||
List<CtbScad> elencoScadenzeNew = new ArrayList<>();
|
||||
String finalDesAgg = desAgg;
|
||||
for (CtbScad scad : ctbMovr.getCtbScad()) {
|
||||
|
||||
CtbScad ctbScad = (CtbScad) scad.clone();
|
||||
|
||||
com.annimon.stream.Optional<CtbParr> ctbParrFirst = Stream.of(elencoPartite)
|
||||
@@ -461,24 +468,29 @@ public class AccountingRules extends QueryRules {
|
||||
if (ctbParrFirst.isPresent()) {
|
||||
elencoPartite.remove(ctbParrFirst.get());
|
||||
ctbParr = ctbParrFirst.get();
|
||||
if (ctbParr.getTipoPartitaEnum() == TipoPartita.PASSIVA) {
|
||||
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare()));
|
||||
if (UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO)) {
|
||||
ctbParr.setImpDare(ctbParr.getImpDare().add(ctbScad.getImpDare().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||
} else {
|
||||
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere()));
|
||||
ctbParr.setImpAvere(ctbParr.getImpAvere().add(ctbScad.getImpAvere().divide(ctbParr.getCambioDiviScad()).setScale(5, RoundingMode.HALF_UP)));
|
||||
}
|
||||
} else {
|
||||
Integer tipoPartita = ctbMovr.getTipoPartita();
|
||||
if (tipoPartita == null) {
|
||||
String sql =
|
||||
"SELECT Cast(tipo_partita as integer) as tipo_partita " +
|
||||
" FROM ctb_part " +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
||||
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
||||
"anno_part = " + UtilityDB.valueToString(ctbScad.getAnnoPart()) + " AND " +
|
||||
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
||||
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
||||
|
||||
tipoPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
BigDecimal cambioScad = BigDecimal.ONE;
|
||||
Integer tipoPartita = ctbMovr.getTipoPartita();
|
||||
|
||||
String sql =
|
||||
"SELECT Cast(tipo_partita as integer) as tipo_partita, cambio " +
|
||||
" FROM ctb_part " +
|
||||
" WHERE cod_anag = " + UtilityDB.valueToString(ctbScad.getCodAnag()) + " AND " +
|
||||
"tipo_anag = " + UtilityDB.valueToString(ctbScad.getTipoAnag()) + " AND " +
|
||||
"anno_part = " + UtilityDB.valueToString(ctbScad.getAnnoPart()) + " AND " +
|
||||
"ser_doc = " + UtilityDB.valueToString(ctbScad.getSerDoc()) + " AND " +
|
||||
"num_doc = " + UtilityDB.valueToString(ctbScad.getNumDoc());
|
||||
|
||||
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())
|
||||
@@ -487,7 +499,6 @@ public class AccountingRules extends QueryRules {
|
||||
.setSerDoc(UtilityString.isNullOrEmpty(ctbScad.getSerDoc()) ? ctbMovr.getSerDoc() : ctbScad.getSerDoc())
|
||||
.setNumDoc(UtilityString.isNullOrEmpty(ctbScad.getNumDoc()) ? ctbMovr.getNumDoc() : ctbScad.getNumDoc());
|
||||
|
||||
|
||||
ctbParr =
|
||||
new CtbParr()
|
||||
.setCodCcon(ctbMovr.getCodCcon())
|
||||
@@ -498,12 +509,13 @@ public class AccountingRules extends QueryRules {
|
||||
.setNumDoc(ctbScad.getNumDoc())
|
||||
.setDataCmov(ctbMovr.getDataCmov())
|
||||
.setIdRiga(ctbMovr.getIdRiga())
|
||||
.setImpDare(TipoPartita.fromValue(tipoPartita) == TipoPartita.PASSIVA ? ctbScad.getImpDare() : BigDecimal.ZERO)
|
||||
.setImpAvere(TipoPartita.fromValue(tipoPartita) == TipoPartita.ATTIVA ? ctbScad.getImpAvere() : BigDecimal.ZERO)
|
||||
.setImpDare(UtilityBigDecimal.greaterThan(ctbMovr.getImpDare(), BigDecimal.ZERO) ? ctbScad.getImpDare().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||
.setImpAvere(UtilityBigDecimal.greaterThan(ctbMovr.getImpAvere(), BigDecimal.ZERO) ? ctbScad.getImpAvere().divide(cambioScad).setScale(5, RoundingMode.HALF_UP) : BigDecimal.ZERO)
|
||||
.setCodCcau(ctbMovr.getCodCcau())
|
||||
.setDesAgg(finalDesAgg)
|
||||
.setTipoPartita(tipoPartita)
|
||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
||||
.setChiudiScad(ctbMovr.getChiudiScad())
|
||||
.setCambioDiviScad(cambioScad);
|
||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
}
|
||||
|
||||
@@ -528,23 +540,39 @@ public class AccountingRules extends QueryRules {
|
||||
}
|
||||
ctbMovr.setCtbScad(elencoScadenzeNew);
|
||||
} else {
|
||||
CtbParr ctbParr =
|
||||
new CtbParr()
|
||||
.setCodCcon(ctbMovr.getCodCcon())
|
||||
.setTipoAnag(ctbMovr.getTipoAnag())
|
||||
.setCodAnag(ctbMovr.getCodAnag())
|
||||
.setAnnoPart(ctbMovr.getAnnoPart())
|
||||
.setSerDoc(ctbMovr.getSerDoc())
|
||||
.setNumDoc(ctbMovr.getNumDoc())
|
||||
.setDataCmov(ctbMovr.getDataCmov())
|
||||
.setIdRiga(ctbMovr.getIdRiga())
|
||||
.setImpDare(ctbMovr.getImpDare())
|
||||
.setImpAvere(ctbMovr.getImpAvere())
|
||||
.setCodCcau(ctbMovr.getCodCcau())
|
||||
.setDesAgg(desAgg)
|
||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
elencoPartite.add(ctbParr);
|
||||
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 =
|
||||
new CtbParr()
|
||||
.setCodCcon(ctbMovr.getCodCcon())
|
||||
.setTipoAnag(ctbMovr.getTipoAnag())
|
||||
.setCodAnag(ctbMovr.getCodAnag())
|
||||
.setAnnoPart(ctbMovr.getAnnoPart())
|
||||
.setSerDoc(ctbMovr.getSerDoc())
|
||||
.setNumDoc(ctbMovr.getNumDoc())
|
||||
.setDataCmov(ctbMovr.getDataCmov())
|
||||
.setIdRiga(ctbMovr.getIdRiga())
|
||||
.setImpDare(ctbMovr.getImpDare())
|
||||
.setImpAvere(ctbMovr.getImpAvere())
|
||||
.setCodCcau(ctbMovr.getCodCcau())
|
||||
.setDesAgg(desAgg)
|
||||
.setChiudiScad(ctbMovr.getChiudiScad());
|
||||
ctbParr.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
elencoPartite.add(ctbParr);
|
||||
}
|
||||
}
|
||||
return elencoPartite;
|
||||
}
|
||||
@@ -886,7 +914,7 @@ public class AccountingRules extends QueryRules {
|
||||
ResultSetMapper resultSetMapper = new ResultSetMapper();
|
||||
List<CtbScad> ctbScad = resultSetMapper.mapQuerySetToList(conn, sql, CtbScad.class);
|
||||
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);
|
||||
CrlScadParr crlScadParr =
|
||||
new CrlScadParr()
|
||||
@@ -900,8 +928,9 @@ public class AccountingRules extends QueryRules {
|
||||
.setNumCmov(ctbMovr.getNumCmov())
|
||||
.setId(x.getPkRelazione());
|
||||
crlScadParr.setOperation(OperationType.DELETE);
|
||||
if (x.getCrlScadParr() == null ) x.setCrlScadParr(new ArrayList<>());
|
||||
x.getCrlScadParr().add(crlScadParr);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
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_model.entity.*;
|
||||
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.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
@@ -120,7 +121,7 @@ public class AnagRules extends QueryRules {
|
||||
|
||||
public static String completeCodVdes(Connection connection, String codAnag, String placeholder) throws Exception {
|
||||
String sql = "SELECT DBO.f_suggestCodeCodVdes(" + UtilityDB.valueToString(codAnag) + ", " + UtilityDB.valueToString(placeholder) + ") as 'max' ";
|
||||
String codVdes = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
String codVdes = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
||||
return codVdes;
|
||||
}
|
||||
|
||||
@@ -230,9 +231,15 @@ public class AnagRules extends QueryRules {
|
||||
gtbAnagNote.getGrlAnagNoteFiles().add(grlAnagNoteFiles);
|
||||
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.Stream;
|
||||
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.config.EmsRestConstants;
|
||||
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.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
@@ -179,7 +179,7 @@ public class CommonRules extends QueryRules {
|
||||
Object object = field.get(testata);
|
||||
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<EntityBase> list = null;
|
||||
List<? extends EntityBase> list = null;
|
||||
if (testata.getOperation() != OperationType.DELETE_THEN_INSERT &&
|
||||
testata.getOperation() != OperationType.INSERT) {
|
||||
list = UtilityDB.reloadOnlyDbRow(conn, testata, rows, field);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ConfigActivityRules extends QueryRules {
|
||||
}
|
||||
} else {
|
||||
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());
|
||||
|
||||
for (Date data : dataDaControllare) {
|
||||
|
||||
@@ -824,7 +824,7 @@ public class DocOrdRules extends QueryRules {
|
||||
.setGestione(ordine.getGestione())
|
||||
.setDataOrd(ordine.getDataOrd())
|
||||
.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));
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.rules.completing;
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
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.entity.MtbColr;
|
||||
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.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
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.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -77,9 +77,9 @@ public class PackagesRules extends QueryRules {
|
||||
|
||||
String sql =
|
||||
"SELECT Cast(count(*) as bit) " +
|
||||
" FROM mtb_partita_mag " +
|
||||
" WHERE mtb_partita_mag.cod_mart = " + UtilityDB.valueToString(mtbColr.getCodMart()) + " AND " +
|
||||
"mtb_partita_mag.partita_mag = "+ UtilityDB.valueToString(mtbColr.getPartitaMag());
|
||||
" FROM mtb_partita_mag " +
|
||||
" WHERE mtb_partita_mag.cod_mart = " + UtilityDB.valueToString(mtbColr.getCodMart()) + " AND " +
|
||||
"mtb_partita_mag.partita_mag = " + UtilityDB.valueToString(mtbColr.getPartitaMag());
|
||||
|
||||
boolean existPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
@@ -88,14 +88,14 @@ public class PackagesRules extends QueryRules {
|
||||
operation = OperationType.INSERT;
|
||||
sql =
|
||||
"SELECT CASE\n" +
|
||||
" WHEN dbo.getgestsetup('MTB_PARTITA_MAG', 'SETUP', 'DESCRIZIONE_PARTITA_FORNITORE') = 'S' THEN\n" +
|
||||
" gtb_anag.rag_soc\n" +
|
||||
" ELSE NULL END\n" +
|
||||
"FROM dtb_ordt \n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
"WHERE dtb_ordt.gestione = " + UtilityDB.valueToString(mtbColr.getGestione()) + "\n" +
|
||||
" AND dtb_ordt.data_ord = " + UtilityDB.valueDateToString(mtbColr.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
||||
" AND dtb_ordt.num_ord = " + UtilityDB.valueToString(mtbColr.getNumOrd());
|
||||
" WHEN dbo.getgestsetup('MTB_PARTITA_MAG', 'SETUP', 'DESCRIZIONE_PARTITA_FORNITORE') = 'S' THEN\n" +
|
||||
" gtb_anag.rag_soc\n" +
|
||||
" ELSE NULL END\n" +
|
||||
"FROM dtb_ordt \n" +
|
||||
" INNER JOIN gtb_anag ON dtb_ordt.cod_anag = gtb_anag.cod_anag\n" +
|
||||
"WHERE dtb_ordt.gestione = " + UtilityDB.valueToString(mtbColr.getGestione()) + "\n" +
|
||||
" AND dtb_ordt.data_ord = " + UtilityDB.valueDateToString(mtbColr.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + "\n" +
|
||||
" AND dtb_ordt.num_ord = " + UtilityDB.valueToString(mtbColr.getNumOrd());
|
||||
|
||||
String descrPartita = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
partita.setDescrizione(descrPartita);
|
||||
@@ -142,7 +142,7 @@ public class PackagesRules extends QueryRules {
|
||||
return codVlis;
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> completeDimensioniCollo(Connection connection, String codTcol) throws Exception{
|
||||
public static HashMap<String, Object> completeDimensioniCollo(Connection connection, String codTcol) throws Exception {
|
||||
String sql =
|
||||
Query.format("select lunghezza_cm, larghezza_cm, altezza_cm from mtb_tcol where cod_tcol = %s ", codTcol);
|
||||
|
||||
@@ -174,7 +174,7 @@ public class PackagesRules extends QueryRules {
|
||||
"GROUP BY posizione, cod_mdep";
|
||||
|
||||
final HashMap<String, Object> result = UtilityDB.executeSimpleQueryOnlyFirstRow(connection, sql);
|
||||
if(result == null) return false;
|
||||
if (result == null) return false;
|
||||
|
||||
boolean colloExists = UtilityHashMap.getValueIfExists(result, "exist");
|
||||
String prevPosizione = UtilityHashMap.getValueIfExists(result, "posizione");
|
||||
@@ -188,14 +188,14 @@ public class PackagesRules extends QueryRules {
|
||||
public static void insertMtbCols(MtbColt mtbColt, MtbCols.Causale causale) {
|
||||
//if(mtbColt.getMtbCols().isEmpty()) {
|
||||
|
||||
MtbCols mtbCols = new MtbCols()
|
||||
.setCausale(causale)
|
||||
.setCodMdep(mtbColt.getCodMdep())
|
||||
.setDataMove(new Date())
|
||||
.setPosizione(mtbColt.getPosizione())
|
||||
.setModificatoDa(mtbColt.getPreparatoDa());
|
||||
mtbCols.setOperation(OperationType.INSERT);
|
||||
mtbColt.getMtbCols().add(mtbCols);
|
||||
MtbCols mtbCols = new MtbCols()
|
||||
.setCausale(causale)
|
||||
.setCodMdep(mtbColt.getCodMdep())
|
||||
.setDataMove(new Date())
|
||||
.setPosizione(mtbColt.getPosizione())
|
||||
.setModificatoDa(mtbColt.getPreparatoDa());
|
||||
mtbCols.setOperation(OperationType.INSERT);
|
||||
mtbColt.getMtbCols().add(mtbCols);
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -295,8 +295,8 @@ public class PackagesRules extends QueryRules {
|
||||
"SELECT dtb_ordt.cod_anag, " +
|
||||
" dtb_ordt.cod_vdes, " +
|
||||
" dtb_ordt.rif_ord " +
|
||||
" FROM dtb_ordt " +
|
||||
" WHERE gestione = " + UtilityDB.valueToString(mtbColt.getGestione()) + " AND " +
|
||||
" FROM dtb_ordt " +
|
||||
" WHERE gestione = " + UtilityDB.valueToString(mtbColt.getGestione()) + " AND " +
|
||||
" data_ord = " + UtilityDB.valueDateToString(mtbColt.getDataOrd(), CommonConstants.DATE_FORMAT_YMD) + " AND " +
|
||||
" num_ord = " + UtilityDB.valueToString(mtbColt.getNumOrd());
|
||||
|
||||
@@ -355,10 +355,10 @@ public class PackagesRules extends QueryRules {
|
||||
}
|
||||
|
||||
public static void completeFlagColloAnonimo(MtbColt mtbColt) {
|
||||
if (mtbColt.getDataDoc() == null || mtbColt.getOperation() == OperationType.DELETE){
|
||||
if ( UtilityString.isNullOrEmpty(mtbColt.getCodAnag()) &&
|
||||
if (mtbColt.getDataDoc() == null || mtbColt.getOperation() == OperationType.DELETE) {
|
||||
if (UtilityString.isNullOrEmpty(mtbColt.getCodAnag()) &&
|
||||
UtilityString.isNullOrEmpty(mtbColt.getCodVdes()) &&
|
||||
mtbColt.getDataOrd() == null && mtbColt.getNumOrd() == null){
|
||||
mtbColt.getDataOrd() == null && mtbColt.getNumOrd() == null) {
|
||||
mtbColt.setFlagColloAnonimo("S");
|
||||
} else {
|
||||
mtbColt.setFlagColloAnonimo("N");
|
||||
@@ -381,8 +381,8 @@ public class PackagesRules extends QueryRules {
|
||||
if (mtbColt.getCalcPeso()) {
|
||||
mtbColt.setPesoKg(pesoLordo);
|
||||
mtbColt.setPesoNettoKg(pesoNetto);
|
||||
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
if (mtbColt.getOperation() != OperationType.SUBSTITUTE)
|
||||
mtbColt.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
} 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 countNewRows = Stream.of(righe)
|
||||
@@ -440,26 +440,27 @@ public class PackagesRules extends QueryRules {
|
||||
|
||||
if (UtilityHashMap.isPresent(datiOrdine))
|
||||
mtbcolt
|
||||
.setCodAnag(mtbcolt.getCodAnag()==null?UtilityHashMap.getValueIfExists(datiOrdine, "cod_anag"):mtbcolt.getCodAnag())
|
||||
.setCodVdes(mtbcolt.getCodVdes()== null?UtilityHashMap.getValueIfExists(datiOrdine, "cod_vdes"):mtbcolt.getCodVdes())
|
||||
.setCodAnag(mtbcolt.getCodAnag() == null ? UtilityHashMap.getValueIfExists(datiOrdine, "cod_anag") : mtbcolt.getCodAnag())
|
||||
.setCodVdes(mtbcolt.getCodVdes() == null ? UtilityHashMap.getValueIfExists(datiOrdine, "cod_vdes") : mtbcolt.getCodVdes())
|
||||
.setRifOrd(UtilityHashMap.getValueIfExists(datiOrdine, "rif_ord"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSerCollo(Connection conn, String codMdep) throws Exception {
|
||||
String sql =
|
||||
"SELECT dbo.f_getSerCollo(" + UtilityDB.valueToString(codMdep) + ")";
|
||||
|
||||
String serDoc = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
if (serDoc == null){
|
||||
if (serDoc == null) {
|
||||
serDoc = (String) CommonRules.completeWithDefault(MtbColt.class, "serCollo");
|
||||
}
|
||||
return serDoc;
|
||||
}
|
||||
|
||||
public static boolean checkForAnyColloRif(Connection conn, String gestione, String serCollo, int numCollo, Date dataCollo) throws Exception{
|
||||
public static boolean checkForAnyColloRif(Connection conn, String gestione, String serCollo, int numCollo, Date dataCollo) throws Exception {
|
||||
String sql = "SELECT count(*) " +
|
||||
"FROM mtb_colr " +
|
||||
"WHERE gestione_rif = " + UtilityDB.valueToString(gestione) +
|
||||
@@ -469,7 +470,7 @@ public class PackagesRules extends QueryRules {
|
||||
|
||||
int countColliRif = (int) getSingleValue(conn, sql);
|
||||
|
||||
if ( countColliRif > 0){
|
||||
if (countColliRif > 0) {
|
||||
throw new Exception("Impossibile cancellare il collo, ci sono altri colli che hanno un riferimento a questo.");
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -159,6 +159,31 @@ public class SalesRules extends QueryRules {
|
||||
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) {
|
||||
if (vtbListData.getVtbPromo() != null) {
|
||||
VtbPromo vtbPromo = vtbListData.getVtbPromo().setCodPromo(vtbListData.getCodPromo());
|
||||
@@ -486,6 +511,8 @@ public class SalesRules extends QueryRules {
|
||||
valUntIva != null) {
|
||||
|
||||
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);
|
||||
entity.setValUnt(valUnt);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ForeignKeyDTO {
|
||||
put(CtbIreg.ENTITY, "Codice registro documenti inesistente");
|
||||
put(WtbJrept.ENTITY, "Report inesistente");
|
||||
put(StbDevice.ENTITY, "Dispositivo inesistente");
|
||||
put(StbPublications.ENTITY, "Pubblicazione inesistente");
|
||||
}};
|
||||
|
||||
String tableName;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.annimon.stream.Stream;
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
import it.integry.annotations.PostWebServerConstruct;
|
||||
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.base_classes.BaseAutomatedOperationDTO;
|
||||
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.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
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;
|
||||
@@ -43,7 +45,6 @@ public class DefaultAutomatedOperationHandlerComponent {
|
||||
|
||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||
deleteJobFileDeleter(multiDBTransactionManager);
|
||||
//initFileDeleterJob(multiDBTransactionManager);
|
||||
initServerInfoCheckJob();
|
||||
initRemoveFpxInvioFilesJob();
|
||||
initChkAutofatture();
|
||||
@@ -51,6 +52,7 @@ public class DefaultAutomatedOperationHandlerComponent {
|
||||
initMinioOrphanFileCleaner(multiDBTransactionManager);
|
||||
initPassaggioAnno(multiDBTransactionManager);
|
||||
}
|
||||
|
||||
} 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) {
|
||||
try {
|
||||
List<AdvancedDataSource> activeConnections = data.getActiveConnections();
|
||||
|
||||
@@ -993,7 +993,7 @@ public class EmsServices {
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityMapping() {
|
||||
return entityPropertyHolder.getEntityMapping();
|
||||
return entityPropertyHolder.getEntityHierarchyMap();
|
||||
}
|
||||
|
||||
public List<EntityFieldDTO> getEntityDetails(String entityName) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.annotation.EntityChild;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityInterface;
|
||||
import it.integry.ems_model.entity.StbLogEntitySetup;
|
||||
import it.integry.ems_model.resolver.SqlFieldHolder;
|
||||
@@ -58,7 +57,7 @@ public class EntityLoggerNewService {
|
||||
public void init() {
|
||||
initSetup();
|
||||
|
||||
if (!UtilityDebug.isDebugExecution()) {
|
||||
if (!UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) {
|
||||
looperService.add(() -> {
|
||||
try {
|
||||
consumeQueue();
|
||||
@@ -154,7 +153,7 @@ public class EntityLoggerNewService {
|
||||
|
||||
String columns = StringUtils.join(entityMap.keySet(), ", ");
|
||||
String values = StringUtils.join(Stream.of(entityMap.values())
|
||||
.map(SqlFieldHolder::getSqlValueField).toList(), ", ");
|
||||
.map(SqlFieldHolder::getSqlValueFieldAsString).toList(), ", ");
|
||||
|
||||
String sql = "INSERT INTO " + entityToLog.getEntity().getTableName() +
|
||||
"(" + columns + ") VALUES (" + values + ")";
|
||||
|
||||
@@ -9,11 +9,9 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.dto.EntityPermissionsDTO;
|
||||
import it.integry.ems.exception.InvalidPermissionsException;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.json.JSONObjectMapper;
|
||||
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.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
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.EntityInterface;
|
||||
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.rulescompleting.DroolsDataCompleting;
|
||||
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.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -97,7 +90,7 @@ public class EntityProcessor {
|
||||
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 {
|
||||
@@ -108,13 +101,20 @@ public class EntityProcessor {
|
||||
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,
|
||||
boolean skipCommit, String username,
|
||||
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,7 +132,7 @@ public class EntityProcessor {
|
||||
public Object processEntity(EntityInterface entity, Boolean isSync,
|
||||
boolean skipCommit, String username,
|
||||
MultiDBTransactionManager mdb,
|
||||
boolean completeEntity) throws Exception {
|
||||
boolean completeEntity, boolean overrideEntityChildCheck) throws Exception {
|
||||
|
||||
try {
|
||||
entity.setEntityHolder(entityPropertyHolder);
|
||||
@@ -144,7 +144,7 @@ public class EntityProcessor {
|
||||
entity.setOperation(OperationType.NO_OP);
|
||||
}
|
||||
|
||||
this.checkEntityChildsUsage(entity, mdb);
|
||||
if (!overrideEntityChildCheck) this.checkEntityChildsUsage(entity, mdb);
|
||||
|
||||
if (settingsModel.isEnablePermissionCheck() && !checkUserPermissions(entity))
|
||||
throw new InvalidPermissionsException();
|
||||
@@ -155,23 +155,10 @@ public class EntityProcessor {
|
||||
return entity.selectAndMergeEntity(mdb.getPrimaryConnection(), (EntityBase) entity);
|
||||
//return entity;
|
||||
} 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 {
|
||||
processInternal(entity, isSync, mdb, completeEntity);
|
||||
}
|
||||
@@ -472,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 {
|
||||
return processEntityList(null, true, singleTransaction, false, entities);
|
||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean singleTransaction) throws Exception {
|
||||
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 {
|
||||
return processEntityList(null, true, singleTransaction, false, entities, multiDBTransactionManager);
|
||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, MultiDBTransactionManager multiDBTransactionManager, boolean singleTransaction) throws Exception {
|
||||
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 {
|
||||
return processEntityList(null, isSync, singleTransaction, ordinaSuPriorita, entities);
|
||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||
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 {
|
||||
return processEntityList(username, isSync, singleTransaction, ordinaSuPriorita, entities);
|
||||
public List<EntityBase> processEntityList(List<? extends EntityBase> entities, String username, boolean isSync, boolean singleTransaction, boolean ordinaSuPriorita) throws Exception {
|
||||
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
|
||||
*
|
||||
@@ -505,7 +487,12 @@ public class EntityProcessor {
|
||||
* @return
|
||||
* @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()) {
|
||||
username = requestDataDTO.getUsername();
|
||||
@@ -518,13 +505,13 @@ public class EntityProcessor {
|
||||
entities = entityPropertyHolder.getEntityChain(entities, multiDBTransactionManager.getPrimaryDatasource().getConnection());
|
||||
}
|
||||
|
||||
Integer prevTransactionGroupId = null;
|
||||
Long prevTransactionGroupId = null;
|
||||
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
EntityBase entity = entities.get(i);
|
||||
entity.setTransactionGroupId(prevTransactionGroupId);
|
||||
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();
|
||||
if (entityResult != null) {
|
||||
entityList.add(entityResult);
|
||||
|
||||
@@ -46,6 +46,7 @@ import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -552,13 +553,13 @@ public class MailService {
|
||||
|
||||
public byte[] createEmlFile(StbActivityEmailObject emailObject) throws MessagingException, IOException {
|
||||
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());
|
||||
|
||||
List<InternetAddress> toList = Stream.of(emailObject.getTo())
|
||||
.map(x -> {
|
||||
try {
|
||||
return new InternetAddress(x.getDisplayName() + "<" + x.getEmailAddress() + ">");
|
||||
return new InternetAddress(x.getDisplayName().replaceAll(",", "") + "<" + x.getEmailAddress().replaceAll(",", "") + ">");
|
||||
} catch (AddressException e) {
|
||||
logger.error(e);
|
||||
return null;
|
||||
@@ -572,6 +573,9 @@ public class MailService {
|
||||
|
||||
String body = emailObject.getBody();
|
||||
|
||||
if(body != null && emailObject.isBodyInBase64())
|
||||
body = new String(Base64.decodeBase64(body), StandardCharsets.UTF_8);
|
||||
|
||||
body = body.replaceAll("@.{8}\\..{8}", "");
|
||||
|
||||
message.setSubject(emailObject.getSubject());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package it.integry.ems.sync;
|
||||
|
||||
import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.json.JSONObjectMapper;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
@@ -11,7 +11,10 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.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 it.integry.ems_model.utility.UtilityString;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -21,11 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@@ -45,11 +46,13 @@ public class AsyncManager {
|
||||
|
||||
private final static HashMap<String, List<StbPublicationsDetail>> cachedSetup = new HashMap<>();
|
||||
|
||||
private final static ConcurrentLinkedQueue<Map.Entry<String, StbTransactionLog>> toBeSavedQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@PostContextConstruct
|
||||
public void init() {
|
||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||
looperService.add(this::internalCachePublicationsSetup, 5 * 60 * 1000, AsyncManager.class.getName());
|
||||
looperService.add(this::internalCachePublicationsSetup, 5 * 60 * 1000, "sync-setup-cache");
|
||||
looperService.add(this::consumeToBeSavedQueue, 20 * 1000, "sync-flush-data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +87,7 @@ public class AsyncManager {
|
||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
||||
|
||||
try {
|
||||
String sql = "SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE syncronize = 'R'";
|
||||
String sql = "SELECT * FROM " + StbPublicationsDetail.ENTITY + " WHERE active = 1";
|
||||
List<StbPublicationsDetail> publications = UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbPublicationsDetail.class);
|
||||
|
||||
cachedSetup.putIfAbsent(dbName, publications);
|
||||
@@ -93,9 +96,9 @@ public class AsyncManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPublicationIdIfExists(String dbName, EntityBase entityBase) throws Exception {
|
||||
public static long getPublicationIdIfExists(String dbName, EntityBase entityBase) throws Exception {
|
||||
if (!cachedSetup.containsKey(dbName) || cachedSetup.get(dbName) == null || cachedSetup.get(dbName).isEmpty())
|
||||
return null;
|
||||
return 0;
|
||||
|
||||
String tableName = entityBase.getTableName().toUpperCase();
|
||||
StbPublicationsDetail activePublication = cachedSetup.get(dbName).stream()
|
||||
@@ -104,16 +107,16 @@ public class AsyncManager {
|
||||
.orElse(null);
|
||||
|
||||
if (activePublication == null)
|
||||
return null;
|
||||
return 0;
|
||||
|
||||
logger.debug("SYNC OFFLINE ABILITATA SU " + tableName);
|
||||
//logger.debug("SYNC OFFLINE ABILITATA SU " + tableName);
|
||||
|
||||
List<EntityBase> myObjs = new ArrayList<>();
|
||||
myObjs.add(entityBase);
|
||||
|
||||
String selectSql = "SELECT * FROM " + entityBase.getClass().getCanonicalName();
|
||||
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondSql())) {
|
||||
selectSql = selectSql + " WHERE " + activePublication.getWhereCondSql();
|
||||
if (!UtilityString.isNullOrEmpty(activePublication.getWhereCondField())) {
|
||||
selectSql = selectSql + " WHERE " + activePublication.getWhereCondField();
|
||||
}
|
||||
|
||||
// Create a new Query.
|
||||
@@ -124,55 +127,97 @@ public class AsyncManager {
|
||||
List<?> res = qr.getResults();
|
||||
|
||||
if (res == null || res.isEmpty())
|
||||
return null;
|
||||
return 0;
|
||||
|
||||
return activePublication.getPublicationId();
|
||||
return activePublication.getStbPublicationId();
|
||||
}
|
||||
|
||||
|
||||
public static void saveNewTransaction(Connection connection, EntityBase entityBase, int transactionGroupId) throws Exception {
|
||||
|
||||
String transactionDate = new SimpleDateFormat(CommonConstants.DATETIME_FORMAT_YMD).format(new Date());
|
||||
int transactionId = 0;
|
||||
|
||||
Integer tmpTransactionId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
||||
connection, "SELECT max(transaction_id) as max_id from stb_transaction_log_db");
|
||||
|
||||
if (tmpTransactionId != null) transactionId = tmpTransactionId;
|
||||
transactionId++; //Incremento l'ID
|
||||
public static Long saveNewTransaction(Connection connection, String dbName, EntityBase entityBase, long publicationId, Long transactionGroupId) throws Exception {
|
||||
//TODO: Calc transaction group ID here
|
||||
if (transactionGroupId == null) transactionGroupId = getNextTransactionGroupId(connection, dbName);
|
||||
|
||||
JSONObjectMapper jsonObjectMapper = ContextLoader.getCurrentWebApplicationContext().getBean(JSONObjectMapper.class);
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
jsonObjectMapper.writeValue(writer, entityBase);
|
||||
|
||||
String entityName = entityBase.getTableName().toUpperCase();
|
||||
|
||||
String sql =
|
||||
"INSERT INTO stb_transaction_log_db(transaction_id, transaction_group_id, transaction_date, user_name, transaction_json, entity_name_list) " +
|
||||
"VALUES (" + transactionId + "," + transactionGroupId + ",'" + transactionDate + "', null, '%s', " + UtilityDB.valueToString(entityName) + ")";
|
||||
|
||||
String jsonString = writer.toString().replace("'", "''");
|
||||
|
||||
sql = String.format(sql, jsonString);
|
||||
|
||||
PreparedStatement psExec = connection.prepareStatement(sql);
|
||||
psExec.executeUpdate();
|
||||
psExec.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static int getNextTransactionGroupId(Connection connection) throws Exception {
|
||||
int transactionGroupId = 0;
|
||||
|
||||
Integer tmpTransactionGroupId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
||||
connection, "SELECT MAX(transaction_group_id) AS max_id from stb_transaction_log_db");
|
||||
|
||||
if (tmpTransactionGroupId != null) transactionGroupId = tmpTransactionGroupId;
|
||||
transactionGroupId++; //Incremento l'ID
|
||||
StbTransactionLog stbTransactionLog = new StbTransactionLog()
|
||||
.setCreatedAt(UtilityLocalDate.getNowTime())
|
||||
.setEntities(entityBase.getTableName().toUpperCase())
|
||||
.setEntitiesJson(jsonObjectMapper.writeValueAsString(entityBase))
|
||||
.setPublicationGroupId(publicationId)
|
||||
.setUserName(entityBase.getUsername())
|
||||
.setGroupId(transactionGroupId);
|
||||
stbTransactionLog.setOperation(OperationType.INSERT);
|
||||
|
||||
toBeSavedQueue.add(new AbstractMap.SimpleEntry<>(dbName, stbTransactionLog));
|
||||
return transactionGroupId;
|
||||
}
|
||||
|
||||
|
||||
public static long getNextTransactionGroupId(Connection connection, String dbName) throws Exception {
|
||||
|
||||
final long maxToBeProcessed = toBeSavedQueue.stream().filter(x -> x.getKey().equalsIgnoreCase(dbName))
|
||||
.map(x -> x.getValue().getGroupId())
|
||||
.max(Long::compare)
|
||||
.orElse(0L);
|
||||
|
||||
long transactionGroupId = 0;
|
||||
|
||||
if (maxToBeProcessed <= 0) {
|
||||
Long tmpTransactionGroupId = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(
|
||||
connection, "SELECT MAX(group_id) AS max_id FROM " + StbTransactionLog.ENTITY);
|
||||
|
||||
tmpTransactionGroupId = tmpTransactionGroupId != 0 ? tmpTransactionGroupId : 0L;
|
||||
|
||||
transactionGroupId = Math.max(maxToBeProcessed, tmpTransactionGroupId);
|
||||
} else {
|
||||
transactionGroupId = maxToBeProcessed;
|
||||
}
|
||||
|
||||
transactionGroupId++; //Incremento l'ID
|
||||
return transactionGroupId;
|
||||
}
|
||||
|
||||
|
||||
private void consumeToBeSavedQueue() {
|
||||
if (cachedSetup.entrySet().stream().anyMatch(x -> x.getValue() != null && x.getValue().stream().anyMatch(y -> !y.isReadyToTransmit())))
|
||||
return;
|
||||
|
||||
List<String> dbNamesToConnect = toBeSavedQueue.stream().map(Map.Entry::getKey).distinct().collect(Collectors.toList());
|
||||
|
||||
final List<AvailableConnectionsModel> databaseConnections = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> dbNamesToConnect.stream().anyMatch(y -> x.getDbName().equalsIgnoreCase(y)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
String insertSQL = "INSERT INTO " + StbTransactionLog.ENTITY + " (publication_group_id, created_at, user_name, entities, entities_json, group_id)" +
|
||||
" VALUES (?, ?, ?, ?, ?, ?)";
|
||||
|
||||
Map.Entry<String, StbTransactionLog> itemToSave = null;
|
||||
while ((itemToSave = toBeSavedQueue.poll()) != null) {
|
||||
final Map.Entry<String, StbTransactionLog> finalItemToSave = itemToSave;
|
||||
final StbTransactionLog stbTransactionLog = finalItemToSave.getValue();
|
||||
|
||||
AvailableConnectionsModel connectionModel = databaseConnections.stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(finalItemToSave.getKey()))
|
||||
.findFirst()
|
||||
.get();
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(connectionModel);
|
||||
SQLServerPreparedStatement insertBulkPs = (SQLServerPreparedStatement) multiDBTransactionManager.prepareStatement(insertSQL)) {
|
||||
|
||||
insertBulkPs.setLong(1, stbTransactionLog.getPublicationGroupId());
|
||||
insertBulkPs.setObject(2, stbTransactionLog.getCreatedAt());
|
||||
insertBulkPs.setString(3, stbTransactionLog.getUserName());
|
||||
insertBulkPs.setString(4, stbTransactionLog.getEntities());
|
||||
insertBulkPs.setString(5, stbTransactionLog.getEntitiesJson());
|
||||
insertBulkPs.setLong(6, stbTransactionLog.getGroupId());
|
||||
|
||||
|
||||
insertBulkPs.executeLargeUpdate();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class MultiDBTransactionManager {
|
||||
public class MultiDBTransactionManager implements AutoCloseable{
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
@@ -46,6 +46,10 @@ public class MultiDBTransactionManager {
|
||||
public MultiDBTransactionManager() {
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(AvailableConnectionsModel connectionsModel) throws Exception {
|
||||
this(connectionsModel.getProfileName(), true);
|
||||
}
|
||||
|
||||
public MultiDBTransactionManager(String profileDb) throws Exception {
|
||||
this(profileDb, true);
|
||||
}
|
||||
@@ -79,6 +83,10 @@ public class MultiDBTransactionManager {
|
||||
this.dbPrimary = null;
|
||||
}
|
||||
|
||||
public void addConnection(AvailableConnectionsModel availableConnectionsModel) throws Exception {
|
||||
this.addConnection(availableConnectionsModel.getProfileName());
|
||||
}
|
||||
|
||||
public void addConnection(String profileName) throws Exception {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(profileName);
|
||||
@@ -234,6 +242,11 @@ public class MultiDBTransactionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
closeAll();
|
||||
}
|
||||
|
||||
public void closeAll() throws Exception {
|
||||
for (AdvancedDataSource advancedDataSource : dbDatasources) {
|
||||
if (!advancedDataSource.isClosed()) {
|
||||
@@ -244,6 +257,7 @@ public class MultiDBTransactionManager {
|
||||
} else if (enableLog) {
|
||||
logger.debug("Closing manually: " + advancedDataSource.getDataSource().getProfile() + " (#" + advancedDataSource.getDataSource().getSessionID() + ")");
|
||||
}
|
||||
advancedDataSource.commit();
|
||||
advancedDataSource.close();
|
||||
}
|
||||
}
|
||||
@@ -333,4 +347,5 @@ public class MultiDBTransactionManager {
|
||||
!uri.contains("getOpenedSteps") &&
|
||||
!uri.contains("getCurrentPrintQueue");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package it.integry.ems.sync.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.service.RemoteSynchronizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("system/remote-sync")
|
||||
public class RemoteSynchronizationController {
|
||||
|
||||
@Autowired
|
||||
private RemoteSynchronizationService remoteSynchronizationService;
|
||||
|
||||
@RequestMapping(value = "publications/{groupId}/start", method = RequestMethod.GET)
|
||||
public ServiceRestResponse startPublication(@PathVariable long groupId) throws Exception {
|
||||
remoteSynchronizationService.startPublication(groupId);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "publications/status", method = RequestMethod.GET)
|
||||
public ServiceRestResponse statusPublication() {
|
||||
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationService.getPublicationStatus());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "subscription/{subscriptionId}/run", method = RequestMethod.GET)
|
||||
public ServiceRestResponse runSubscription(@PathVariable long subscriptionId) throws Exception {
|
||||
remoteSynchronizationService.runSubscription(subscriptionId);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package it.integry.ems.sync.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.dto.*;
|
||||
import it.integry.ems.sync.service.RemoteSynchronizationSetupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("system/remote-sync/setup")
|
||||
public class RemoteSynchronizationSetupController {
|
||||
|
||||
@Autowired
|
||||
private RemoteSynchronizationSetupService remoteSynchronizationSetupService;
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/retrieve", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrievePublications() throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationSetupService.retrievePublications());
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/insert-group", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertPublicationGroup(@RequestBody InsertPublicationGroupRequestDTO request) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(remoteSynchronizationSetupService.addPublicationGroup(request.getDescription()));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/{groupId}/insert", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertPublications(@PathVariable long groupId, @RequestBody PublicationDTO publicationToInsert) throws Exception {
|
||||
InsertPublicationItemResponseDTO response = new InsertPublicationItemResponseDTO()
|
||||
.setId(remoteSynchronizationSetupService.addPublicationItem(groupId, publicationToInsert));
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(response);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/{groupId}/delete-group", method = RequestMethod.POST)
|
||||
public ServiceRestResponse deletePublicationGroup(@PathVariable long groupId) throws Exception {
|
||||
remoteSynchronizationSetupService.deletePublicationsGroup(groupId);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/{publicationId}/delete", method = RequestMethod.POST)
|
||||
public ServiceRestResponse deletePublication(@PathVariable long publicationId) throws Exception {
|
||||
remoteSynchronizationSetupService.deletePublications(Collections.singletonList(publicationId));
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/{publicationId}/edit", method = RequestMethod.POST)
|
||||
public ServiceRestResponse editPublication(@PathVariable long publicationId, @RequestBody PublicationDTO publicationToEdit) throws Exception {
|
||||
remoteSynchronizationSetupService.editPublication(publicationId, publicationToEdit);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "subscriptions/insert", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertSubscription(@RequestBody SubscriptionDTO subscriptionToInsert) throws Exception {
|
||||
InsertSubscriptionResponseDTO response = new InsertSubscriptionResponseDTO()
|
||||
.setId(remoteSynchronizationSetupService.addSubscription(subscriptionToInsert));
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package it.integry.ems.sync.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.service.RemoteSynchronizationTransactionsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("system/remote-transaction")
|
||||
public class RemoteSynchronizationTransactionsController {
|
||||
|
||||
@Autowired
|
||||
private RemoteSynchronizationTransactionsService remoteSynchronizationTransactionsService;
|
||||
|
||||
|
||||
@RequestMapping(value = "{publicationId}/retrieve", method = RequestMethod.GET)
|
||||
public ServiceRestResponse retrieve(@PathVariable long publicationId,
|
||||
@RequestParam(required = false) Long lastRetrievedTransactionId,
|
||||
@RequestParam(required = false, defaultValue = "-1") int limit) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(
|
||||
remoteSynchronizationTransactionsService.retrieveTransactions(publicationId, lastRetrievedTransactionId, limit));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class ExportHistoryGroupDTO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private long groupId;
|
||||
private LocalDateTime startTime;
|
||||
private LocalDateTime endTime;
|
||||
private boolean completedRead;
|
||||
private long totalItemCount;
|
||||
private long processedItemCount;
|
||||
private long syncronizedItemCount;
|
||||
private List<ExportHistoryItemDTO> items = new ArrayList<>();
|
||||
|
||||
private final Queue<Map.Entry<String, String>> toProcessQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setGroupId(long groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ExportHistoryItemDTO> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setItems(List<ExportHistoryItemDTO> items) {
|
||||
this.items = items;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Queue<Map.Entry<String, String>> getToProcessQueue() {
|
||||
return toProcessQueue;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setDataSource(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotalItemCount() {
|
||||
return totalItemCount;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setTotalItemCount(long totalItemCount) {
|
||||
this.totalItemCount = totalItemCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getProcessedItemCount() {
|
||||
return processedItemCount;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setProcessedItemCount(long processedItemCount) {
|
||||
this.processedItemCount = processedItemCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getSyncronizedItemCount() {
|
||||
return syncronizedItemCount;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setSyncronizedItemCount(long syncronizedItemCount) {
|
||||
this.syncronizedItemCount = syncronizedItemCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCompletedRead() {
|
||||
return completedRead;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setCompletedRead(boolean completedRead) {
|
||||
this.completedRead = completedRead;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ExportHistoryItemDTO {
|
||||
|
||||
private PublicationDTO publication;
|
||||
private LocalDateTime startDate;
|
||||
|
||||
|
||||
public PublicationDTO getPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setPublication(PublicationDTO publication) {
|
||||
this.publication = publication;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setStartDate(LocalDateTime startDate) {
|
||||
this.startDate = startDate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ExportHistoryStatusDTO {
|
||||
|
||||
private long publicationGroupId;
|
||||
private long processedCount;
|
||||
private long totalCount;
|
||||
private LocalDateTime startedAt;
|
||||
private LocalDateTime estimatedEnd;
|
||||
private int speedPerMinute;
|
||||
|
||||
|
||||
public long getPublicationGroupId() {
|
||||
return publicationGroupId;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setPublicationGroupId(long publicationGroupId) {
|
||||
this.publicationGroupId = publicationGroupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getProcessedCount() {
|
||||
return processedCount;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setProcessedCount(long processedCount) {
|
||||
this.processedCount = processedCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setTotalCount(long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartedAt() {
|
||||
return startedAt;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setStartedAt(LocalDateTime startedAt) {
|
||||
this.startedAt = startedAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getEstimatedEnd() {
|
||||
return estimatedEnd;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setEstimatedEnd(LocalDateTime estimatedEnd) {
|
||||
this.estimatedEnd = estimatedEnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getSpeedPerMinute() {
|
||||
return speedPerMinute;
|
||||
}
|
||||
|
||||
public ExportHistoryStatusDTO setSpeedPerMinute(int speedPerMinute) {
|
||||
this.speedPerMinute = speedPerMinute;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
public class InsertPublicationGroupRequestDTO {
|
||||
|
||||
private String description;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public InsertPublicationGroupRequestDTO setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
public class InsertPublicationGroupResponseDTO {
|
||||
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public InsertPublicationGroupResponseDTO setId(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user