Merge branch 'develop' into feature/Syncronizations

This commit is contained in:
2024-01-29 09:34:03 +01:00
18 changed files with 125 additions and 66 deletions

View File

@@ -2,10 +2,14 @@ package it.integry.ems.schedule.new_cron_job.dto.operations;
import com.fasterxml.jackson.annotation.JsonInclude;
import it.integry.ems.schedule.new_cron_job.dto.operations.base_classes.BaseScheduledOperationDTO;
import org.springframework.web.bind.annotation.RequestMethod;
@JsonInclude
public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO {
@OperationField()
private RequestMethod methodType;
@OperationField(required = true)
private String methodName;
@@ -25,6 +29,15 @@ public class ServiceCallAutomatedOperationDTO extends BaseScheduledOperationDTO
private String password;
public RequestMethod getMethodType() {
return methodType;
}
public ServiceCallAutomatedOperationDTO setMethodType(RequestMethod methodType) {
this.methodType = methodType;
return this;
}
public String getMethodName() {
return methodName;
}

View File

@@ -9,6 +9,7 @@ import it.integry.ems.service.HttpRestWrapper;
import it.integry.ems_model.utility.UtilityServer;
import it.integry.ems_model.utility.UtilityString;
import org.apache.http.entity.ContentType;
import org.springframework.web.bind.annotation.RequestMethod;
public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationRunner<ServiceCallAutomatedOperationDTO> {
@@ -21,13 +22,52 @@ public class ServiceCallScheduledOperationRunner extends BaseScheduledOperationR
+ (getDtoInstance().getQueryParams() != null ? ("&" + getDtoInstance().getQueryParams()) : "");
StringBuilder responseBody = new StringBuilder();
int status = HttpRestWrapper.callGeneric(
baseUrl,
getDtoInstance().getUsername(),
getDtoInstance().getPassword(),
getDtoInstance().getBody(),
ContentType.APPLICATION_JSON,
responseBody);
int status;
RequestMethod methodType = getDtoInstance().getMethodType();
if (methodType == null) {
methodType = RequestMethod.POST;
}
switch (methodType) {
case GET:
status = HttpRestWrapper.callGenericGet(
baseUrl,
getDtoInstance().getUsername(),
getDtoInstance().getPassword(),
responseBody,
null
);
break;
default:
case POST:
status = HttpRestWrapper.callGeneric(
baseUrl,
getDtoInstance().getUsername(),
getDtoInstance().getPassword(),
getDtoInstance().getBody(),
ContentType.APPLICATION_JSON,
responseBody
);
break;
case PUT:
status = HttpRestWrapper.callGeneric(
baseUrl,
getDtoInstance().getUsername(),
getDtoInstance().getPassword(),
getDtoInstance().getBody(),
ContentType.APPLICATION_JSON,
responseBody,
null,
RequestMethod.PUT
);
break;
}
String responseJson = responseBody.toString();

View File

@@ -53,10 +53,16 @@ public class AutomatedOperationService {
operationFieldDTO.setDefaultValues(profiles);
}
String type = x.getType().getName();
if (x.getType().isEnum()) {
operationFieldDTO
.setType("Enum")
.setDefaultValues(Stream.of(x.getType().getEnumConstants()).map(Object::toString).toList());
} else {
String type = x.getType().getName();
String[] explodedType = type.split("\\.");
operationFieldDTO.setType(explodedType[explodedType.length - 1]);
String[] explodedType = type.split("\\.");
operationFieldDTO.setType(explodedType[explodedType.length - 1]);
}
if (x.isAnnotationPresent(OperationField.class)) {
OperationField operationField = x.getAnnotation(OperationField.class);

View File

@@ -44,6 +44,7 @@ import it.integry.ems_model.annotation.SqlField;
import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.base.EntityPropertyHolder;
import it.integry.ems_model.config.EmsRestConstants;
import it.integry.ems_model.entity.Azienda;
import it.integry.ems_model.entity.MrlPartitaMagAttached;
import it.integry.ems_model.entity.StbFilesAttached;
import it.integry.ems_model.entity.WtbUsersInfo;
@@ -720,10 +721,13 @@ public class EmsServices {
Gson gson = new Gson();
if (arguments.containsKey("nomeAzienda")) arguments.remove("nomeAzienda");
final Azienda defaultAzienda = Azienda.getDefaultAzienda(multiDBTransactionManager.getPrimaryConnection());
if (arguments.containsKey("nomeAzienda")) arguments.remove("nomeAzienda");
arguments.put("nomeAzienda", settingsModel.getDefaultProfile());
arguments.put("partitaIva", defaultAzienda.getPartIva());
String jsonBody = gson.toJson(arguments);
StringBuilder srb = new StringBuilder();

View File

@@ -11,6 +11,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
@@ -53,10 +54,6 @@ public class HttpRestWrapper {
}
}
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse) throws NoSuchAlgorithmException, KeyManagementException {
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, null);
}
public static int callGenericGet(String url, String username, String password, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
final Client client = makeDefaultConfig();
WebTarget webTarget = client.target(url);
@@ -80,42 +77,15 @@ public class HttpRestWrapper {
return status;
}
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
Entity entity = null;
if (!UtilityString.isNullOrEmpty(jsonBody)) {
if (contentType == APPLICATION_JSON) {
entity = Entity.json(jsonBody);
} else if (contentType == TEXT_PLAIN) {
entity = Entity.text(jsonBody);
}
}
final Client client = makeDefaultConfig();
WebTarget webTarget = client.target(url);
if (queryParams != null) {
for (String key : queryParams.keySet()) {
webTarget = webTarget.queryParam(key, queryParams.get(key));
}
}
Invocation.Builder request = addBaseHeader(webTarget.request(), username, password);
if (contentType == APPLICATION_JSON) request = request.header("Content-Type", "application/json");
Response response = request.post(entity);
// boolean status = response.getStatus() == 200;
int status = response.getStatus();
bodyResponse.append(response.readEntity(String.class));
response.close();
client.close();
return status;
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse) throws NoSuchAlgorithmException, KeyManagementException {
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, null);
}
public static int callPutGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams) throws NoSuchAlgorithmException, KeyManagementException {
return callGeneric(url, username, password, jsonBody, contentType, bodyResponse, queryParams, RequestMethod.POST);
}
public static int callGeneric(String url, String username, String password, String jsonBody, ContentType contentType, StringBuilder bodyResponse, HashMap<String, String> queryParams, RequestMethod requestMethod) throws NoSuchAlgorithmException, KeyManagementException {
Entity entity = null;
@@ -138,7 +108,17 @@ public class HttpRestWrapper {
Invocation.Builder request = addBaseHeader(webTarget.request(), username, password);
if (contentType == APPLICATION_JSON) request = request.header("Content-Type", "application/json");
Response response = request.put(entity);
Response response;
switch (requestMethod) {
default:
case POST:
response = request.post(entity);
break;
case PUT:
response = request.put(entity);
break;
}
// boolean status = response.getStatus() == 200;
int status = response.getStatus();

View File

@@ -33,6 +33,7 @@ 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 org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.io.StringWriter;
@@ -282,7 +283,7 @@ public class BrtService {
StringBuilder stringBuilder = new StringBuilder();
int status;
if (rootDTO instanceof BrtRootDeleteDTO){
status = HttpRestWrapper.callPutGeneric(url, null, null, contentBody, ContentType.APPLICATION_JSON, stringBuilder, null);
status = HttpRestWrapper.callGeneric(url, null, null, contentBody, ContentType.APPLICATION_JSON, stringBuilder, null, RequestMethod.PUT);
} else {
status = HttpRestWrapper.callGeneric(url, null, null, contentBody, ContentType.APPLICATION_JSON, stringBuilder);
}

View File

@@ -24,10 +24,7 @@ import it.integry.ems_model.exception.EntityException;
import it.integry.ems_model.service.SetupGest;
import it.integry.ems_model.types.ApplicationName;
import it.integry.ems_model.types.OperationType;
import it.integry.ems_model.utility.UtilityDB;
import it.integry.ems_model.utility.UtilityHashMap;
import it.integry.ems_model.utility.UtilityStream;
import it.integry.ems_model.utility.UtilityString;
import it.integry.ems_model.utility.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -723,6 +720,24 @@ public class OrdiniWebImportService {
}
if (countRow == 1) {
String sql = "select gg_cons\n" +
"from vtb_dest\n" +
"where cod_anag = " + UtilityDB.valueToString(codAnag) +
" and cod_vdes = " + UtilityDB.valueToString(codVdes);
String calcDataCons = importSetupSection.get("CALC_DATA_CONS");
String setDecorrenza = importSetupSection.get("SET_DECORRENZA");
int ggCons = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
if (dataConsRich == null && calcDataCons != null && calcDataCons.equalsIgnoreCase("S")) {
dataConsRich = UtilityDate.dateAdd(dataCons, ggCons);
}
if (dataConsRich != null && setDecorrenza != null && setDecorrenza.equalsIgnoreCase("S")){
dtbOrdt.setDataRifScad(dataConsRich);
}
dtbOrdt.setGestione("V");
dtbOrdt.setFlagAnnulla(flagAnnulla);
dtbOrdt.setEanFidelity(eanFidelity);

View File

@@ -1 +1 @@
import{_ as b,d as C,q as v,X as w,u as k,c as n,w as L,b as h,e as s,g as y,h as g,A as _,r as d,o as l,B as f,a as S,i as B}from"./index.bdcde0cd.js";import{D}from"./DynamicForm.40aeb4d3.js";const N=C({name:"SchedulerCreate",components:{DynamicForm:D},setup(){const e=v(),m=w(),t=k(),o=n(()=>e.params.type);L(o,()=>r());function r(){t.dispatch("scheduler/setCurrentCategory",o.value)}r();const p=n(()=>t.getters["scheduler/getCurrentCategory"]),i=n(()=>t.getters["main/isLoading"]),a=n(()=>t.getters["scheduler/getError"]);async function c(u){await t.dispatch("scheduler/saveAutomation",{category:o.value,...u}),a.value||await m.push({name:"scheduler.show",params:{type:o.value}})}return{type:o,currentCategory:p,onSubmit:c,isLoading:i,error:a}}}),R={class:"intro-y flex items-center mt-8"},V={class:"text-lg font-medium mr-auto"},$={key:0,class:"alert alert-danger show my-2",role:"alert"},A={class:"text-right mt-5"},F=["disabled","onClick"],E=["disabled"],I=B(" Salva ");function q(e,m,t,o,r,p){const i=d("RouterLink"),a=d("LoadingIcon"),c=d("DynamicForm");return l(),h("div",null,[s("div",R,[s("h2",V," Nuova Pianificata "+y(e.type),1)]),g(c,{fields:e.currentCategory,onSubmit:e.onSubmit,class:"intro-y"},{default:_(()=>[e.error?(l(),h("div",$,y(e.error.message),1)):f("",!0),s("div",A,[g(i,{to:{name:"scheduler.show",params:{type:e.type}},custom:""},{default:_(({navigate:u})=>[s("button",{type:"button",class:"btn btn-outline-secondary w-24 mr-1",disabled:e.isLoading,onClick:u}," Annulla ",8,F)]),_:1},8,["to"]),s("button",{type:"submit",class:"btn btn-primary w-24",disabled:e.isLoading},[I,e.isLoading?(l(),S(a,{key:0,icon:"oval",color:"white",class:"w-4 h-4 ml-2"})):f("",!0)],8,E)])]),_:1},8,["fields","onSubmit"])])}const X=b(N,[["render",q]]);export{X as default};
import{_ as b,d as C,q as v,X as w,u as k,c as n,w as L,b as h,e as s,g as y,h as g,A as _,r as d,o as l,B as f,a as S,i as B}from"./index.e3ffa8b5.js";import{D}from"./DynamicForm.3e07ffe1.js";const N=C({name:"SchedulerCreate",components:{DynamicForm:D},setup(){const e=v(),m=w(),t=k(),o=n(()=>e.params.type);L(o,()=>r());function r(){t.dispatch("scheduler/setCurrentCategory",o.value)}r();const p=n(()=>t.getters["scheduler/getCurrentCategory"]),i=n(()=>t.getters["main/isLoading"]),a=n(()=>t.getters["scheduler/getError"]);async function c(u){await t.dispatch("scheduler/saveAutomation",{category:o.value,...u}),a.value||await m.push({name:"scheduler.show",params:{type:o.value}})}return{type:o,currentCategory:p,onSubmit:c,isLoading:i,error:a}}}),R={class:"intro-y flex items-center mt-8"},V={class:"text-lg font-medium mr-auto"},$={key:0,class:"alert alert-danger show my-2",role:"alert"},A={class:"text-right mt-5"},F=["disabled","onClick"],E=["disabled"],I=B(" Salva ");function q(e,m,t,o,r,p){const i=d("RouterLink"),a=d("LoadingIcon"),c=d("DynamicForm");return l(),h("div",null,[s("div",R,[s("h2",V," Nuova Pianificata "+y(e.type),1)]),g(c,{fields:e.currentCategory,onSubmit:e.onSubmit,class:"intro-y"},{default:_(()=>[e.error?(l(),h("div",$,y(e.error.message),1)):f("",!0),s("div",A,[g(i,{to:{name:"scheduler.show",params:{type:e.type}},custom:""},{default:_(({navigate:u})=>[s("button",{type:"button",class:"btn btn-outline-secondary w-24 mr-1",disabled:e.isLoading,onClick:u}," Annulla ",8,F)]),_:1},8,["to"]),s("button",{type:"submit",class:"btn btn-primary w-24",disabled:e.isLoading},[I,e.isLoading?(l(),S(a,{key:0,icon:"oval",color:"white",class:"w-4 h-4 ml-2"})):f("",!0)],8,E)])]),_:1},8,["fields","onSubmit"])])}const X=b(N,[["render",q]]);export{X as default};

View File

@@ -1 +1 @@
import{_ as S,d as B,q as D,X as N,u as E,c as a,w as g,v as R,b as y,e as n,g as v,h as _,A as b,r as l,o as m,B as C,a as V,i as $}from"./index.bdcde0cd.js";import{D as F}from"./DynamicForm.40aeb4d3.js";const I=B({name:"SchedulerEdit",components:{DynamicForm:F},setup(){const e=D(),h=N(),t=E(),o=a(()=>e.params.type);g(o,()=>i()),i();async function p(){await t.dispatch("scheduler/fetchAutomations",o.value)}p();function i(){t.dispatch("scheduler/setCurrentCategory",o.value)}const c=a(()=>t.getters["scheduler/getCurrentCategory"]),s=a(()=>e.params.id);g(s,()=>r());const u=a(()=>e.name);function r(){t.dispatch("scheduler/setCurrentAutomation",s.value)}r();const w=a(()=>t.getters["scheduler/getCurrentAutomation"]),d=R(w.value);d.value&&u.value==="scheduler.duplicate"&&(d.value.id=void 0);const A=a(()=>t.getters["main/isLoading"]),f=a(()=>t.getters["scheduler/getError"]);async function k(L){await t.dispatch("scheduler/saveAutomation",{category:o.value,...L}),f.value||await h.push({name:"scheduler.show",params:{type:o.value}})}return{type:o,id:s,currentCategory:c,currentAutomation:d,onSubmit:k,isLoading:A,error:f}}}),q={class:"intro-y flex items-center mt-8"},M={class:"text-lg font-medium mr-auto"},P={key:0,class:"alert alert-danger show my-2",role:"alert"},T={class:"text-right mt-5"},X=["disabled","onClick"],j=["disabled"],z=$(" Salva ");function G(e,h,t,o,p,i){const c=l("RouterLink"),s=l("LoadingIcon"),u=l("DynamicForm");return m(),y("div",null,[n("div",q,[n("h2",M," Modifica Pianificata "+v(e.currentAutomation.name),1)]),_(u,{fields:e.currentCategory,"initial-values":e.currentAutomation,onSubmit:e.onSubmit,class:"intro-y"},{default:b(()=>[e.error?(m(),y("div",P,v(e.error.message),1)):C("",!0),n("div",T,[_(c,{to:{name:"scheduler.show",params:{type:e.type}},custom:""},{default:b(({navigate:r})=>[n("button",{type:"button",class:"btn btn-outline-secondary w-24 mr-1",disabled:e.isLoading,onClick:r}," Annulla ",8,X)]),_:1},8,["to"]),n("button",{type:"submit",class:"btn btn-primary w-24",disabled:e.isLoading},[z,e.isLoading?(m(),V(s,{key:0,icon:"oval",color:"white",class:"w-4 h-4 ml-2"})):C("",!0)],8,j)])]),_:1},8,["fields","initial-values","onSubmit"])])}const K=S(I,[["render",G]]);export{K as default};
import{_ as S,d as B,q as D,X as N,u as E,c as a,w as g,v as R,b as y,e as n,g as v,h as _,A as b,r as l,o as m,B as C,a as V,i as $}from"./index.e3ffa8b5.js";import{D as F}from"./DynamicForm.3e07ffe1.js";const I=B({name:"SchedulerEdit",components:{DynamicForm:F},setup(){const e=D(),h=N(),t=E(),o=a(()=>e.params.type);g(o,()=>i()),i();async function p(){await t.dispatch("scheduler/fetchAutomations",o.value)}p();function i(){t.dispatch("scheduler/setCurrentCategory",o.value)}const c=a(()=>t.getters["scheduler/getCurrentCategory"]),s=a(()=>e.params.id);g(s,()=>r());const u=a(()=>e.name);function r(){t.dispatch("scheduler/setCurrentAutomation",s.value)}r();const w=a(()=>t.getters["scheduler/getCurrentAutomation"]),d=R(w.value);d.value&&u.value==="scheduler.duplicate"&&(d.value.id=void 0);const A=a(()=>t.getters["main/isLoading"]),f=a(()=>t.getters["scheduler/getError"]);async function k(L){await t.dispatch("scheduler/saveAutomation",{category:o.value,...L}),f.value||await h.push({name:"scheduler.show",params:{type:o.value}})}return{type:o,id:s,currentCategory:c,currentAutomation:d,onSubmit:k,isLoading:A,error:f}}}),q={class:"intro-y flex items-center mt-8"},M={class:"text-lg font-medium mr-auto"},P={key:0,class:"alert alert-danger show my-2",role:"alert"},T={class:"text-right mt-5"},X=["disabled","onClick"],j=["disabled"],z=$(" Salva ");function G(e,h,t,o,p,i){const c=l("RouterLink"),s=l("LoadingIcon"),u=l("DynamicForm");return m(),y("div",null,[n("div",q,[n("h2",M," Modifica Pianificata "+v(e.currentAutomation.name),1)]),_(u,{fields:e.currentCategory,"initial-values":e.currentAutomation,onSubmit:e.onSubmit,class:"intro-y"},{default:b(()=>[e.error?(m(),y("div",P,v(e.error.message),1)):C("",!0),n("div",T,[_(c,{to:{name:"scheduler.show",params:{type:e.type}},custom:""},{default:b(({navigate:r})=>[n("button",{type:"button",class:"btn btn-outline-secondary w-24 mr-1",disabled:e.isLoading,onClick:r}," Annulla ",8,X)]),_:1},8,["to"]),n("button",{type:"submit",class:"btn btn-primary w-24",disabled:e.isLoading},[z,e.isLoading?(m(),V(s,{key:0,icon:"oval",color:"white",class:"w-4 h-4 ml-2"})):C("",!0)],8,j)])]),_:1},8,["fields","initial-values","onSubmit"])])}const K=S(I,[["render",G]]);export{K as default};

View File

@@ -1 +1 @@
import{_ as s,d as n,u as r,c as i,w as u,a as d,o as p,r as l}from"./index.bdcde0cd.js";const h=n({name:"SchedulerIndex",setup(){const e=r(),o=i(()=>e.getters["scheduler/getAutomationCategories"]);e.dispatch("scheduler/initStore"),u(()=>o.value,()=>{e.dispatch("main/clearMenuButton",{button:"Pianificate",child:!0}),Object.keys(o.value).forEach(t=>{e.dispatch("main/addMenuButton",{child:"Pianificate",button:{title:t,icon:"ActivityIcon",routeName:"scheduler.show",params:{type:t},child:[{routeName:"scheduler.create",params:{type:t}}]}})})})}});function m(e,o,a,t,_,f){const c=l("router-view");return p(),d(c)}const w=s(h,[["render",m]]);export{w as default};
import{_ as s,d as n,u as r,c as i,w as u,a as d,o as p,r as l}from"./index.e3ffa8b5.js";const h=n({name:"SchedulerIndex",setup(){const e=r(),o=i(()=>e.getters["scheduler/getAutomationCategories"]);e.dispatch("scheduler/initStore"),u(()=>o.value,()=>{e.dispatch("main/clearMenuButton",{button:"Pianificate",child:!0}),Object.keys(o.value).forEach(t=>{e.dispatch("main/addMenuButton",{child:"Pianificate",button:{title:t,icon:"ActivityIcon",routeName:"scheduler.show",params:{type:t},child:[{routeName:"scheduler.create",params:{type:t}}]}})})})}});function m(e,o,a,t,_,f){const c=l("router-view");return p(),d(c)}const w=s(h,[["render",m]]);export{w as default};

View File

@@ -0,0 +1 @@
import{a7 as a,a8 as r}from"./index.e3ffa8b5.js";import{a7 as o}from"./index.e3ffa8b5.js";a.register(...r);export{o as default};

View File

@@ -1 +0,0 @@
import{a7 as a,a8 as r}from"./index.bdcde0cd.js";import{a7 as o}from"./index.bdcde0cd.js";a.register(...r);export{o as default};

View File

@@ -17,7 +17,7 @@
/>
<!-- <link rel="preload" href="/font/Inter-italic.var.woff2" as="font" type="font/woff2" crossorigin="anonymous"> -->
<link rel="stylesheet" href="./font/inter.css"/>
<script type="module" crossorigin src="./assets/index.bdcde0cd.js"></script>
<script type="module" crossorigin src="./assets/index.e3ffa8b5.js"></script>
<link rel="stylesheet" href="./assets/index.9a08ebf5.css">
</head>