diff --git a/pom.xml b/pom.xml index 5223ec25..a5a65600 100644 --- a/pom.xml +++ b/pom.xml @@ -1,168 +1,164 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.1.5.RELEASE - .. - + + org.springframework.boot + spring-boot-starter-parent + 2.1.5.RELEASE + .. + - it.istat.rservice - rService - 0.0.1-SNAPSHOT - ${packaging.type} - IS2 - Istat Statistical Service + it.istat.rservice + rService + 0.9 + ${packaging.type} + IS2 + Statistical Service Workbench - - 1.8 - + + 1.8 + - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity5 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity5 + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-test + test + + + org.json + json + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + runtime + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j + 1.2.8.RELEASE + + + mysql + mysql-connector-java + + + org.rosuda.REngine + Rserve + 1.8.1 + + + commons-fileupload + commons-fileupload + 1.3.1 + + + org.apache.commons + commons-io + 1.3.2 + + + org.apache.commons + commons-csv + 1.5 + + + org.projectlombok + lombok + + + org.json + json + 20180130 + + - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-test - test - - - org.json - json - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-devtools - runtime - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j - 1.2.8.RELEASE - - - mysql - mysql-connector-java + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + false + true + + + + is2 + + + src/main/resources + + + - - - org.rosuda.REngine - Rserve - 1.8.1 - - - commons-fileupload - commons-fileupload - 1.3.1 - - - org.apache.commons - commons-io - 1.3.2 - - - org.apache.commons - commons-csv - 1.5 - - - org.projectlombok - lombok - - - - org.json - json - 20180130 - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - false - true - - - - is2 - - - src/main/resources - - - - - - - is2Dev - - true - - - jar - - - - is2War - - war - - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - - \ No newline at end of file + + + is2Dev + + true + + + jar + + + + is2War + + war + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + + diff --git a/src/main/java/it/istat/rservice/AppConfiguration.java b/src/main/java/it/istat/rservice/AppConfiguration.java index dd0e6ad0..898af9ba 100644 --- a/src/main/java/it/istat/rservice/AppConfiguration.java +++ b/src/main/java/it/istat/rservice/AppConfiguration.java @@ -21,15 +21,10 @@ * @author Stefano Macone * @version 1.0 */ - package it.istat.rservice; import java.util.Locale; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ResourceBundleMessageSource; @@ -37,121 +32,85 @@ import org.springframework.web.multipart.support.StandardServletMultipartResolver; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.SessionLocaleResolver; -import org.thymeleaf.TemplateEngine; import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect; -import org.thymeleaf.spring5.ISpringTemplateEngine; import org.thymeleaf.spring5.SpringTemplateEngine; -import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; import org.thymeleaf.spring5.view.ThymeleafViewResolver; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; -import org.thymeleaf.templateresolver.ITemplateResolver; @Configuration - public class AppConfiguration implements WebMvcConfigurer { - - - @Bean - public LocaleChangeInterceptor localeChangeInterceptor() { - LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); - lci.setParamName("language"); - return lci; - } - - @Bean - public LocaleResolver localeResolver() { - SessionLocaleResolver slr = new SessionLocaleResolver(); - slr.setDefaultLocale(new Locale("it", "IT")); - return slr; - } - - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(localeChangeInterceptor()); - } - - @Bean - public ResourceBundleMessageSource messageSource() { - ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename("i18n/messages"); - return messageSource; - } - - @Bean(name = "multipartResolver") - public MultipartResolver multipartResolver() { - return new StandardServletMultipartResolver(); - } - - @Bean - public SpringSecurityDialect securityDialect() { - return new SpringSecurityDialect(); - } - - - - @Bean public ClassLoaderTemplateResolver templateResolver() { - - ClassLoaderTemplateResolver templateResolver = new - ClassLoaderTemplateResolver(); - - templateResolver.setPrefix("templates/"); - templateResolver.setCacheable(false); templateResolver.setSuffix(".html"); - templateResolver.setTemplateMode("HTML5"); - templateResolver.setCharacterEncoding("UTF-8"); - - return templateResolver; } - - @Bean public SpringTemplateEngine templateEngine() { - - SpringTemplateEngine templateEngine = new SpringTemplateEngine(); - templateEngine.setTemplateResolver(templateResolver()); - templateEngine.addDialect(securityDialect()); return templateEngine; } - - @Bean public ViewResolver viewResolver() { - - ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); - - viewResolver.setTemplateEngine(templateEngine()); - viewResolver.setCharacterEncoding("UTF-8"); - - return viewResolver; } - - - /* - * STEP 1 - Create SpringResourceTemplateResolver - * - * @Bean public SpringResourceTemplateResolver templateResolver() { - * SpringResourceTemplateResolver templateResolver = new - * SpringResourceTemplateResolver(); - * templateResolver.setApplicationContext(applicationContext); - * templateResolver.setPrefix("templates/"); - * templateResolver.setSuffix(".html"); return templateResolver; } - * - * - * STEP 2 - Create SpringTemplateEngine - * - * @Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine - * templateEngine = new SpringTemplateEngine(); - * templateEngine.setTemplateResolver(templateResolver()); - * templateEngine.setEnableSpringELCompiler(true); return templateEngine; } - * - * - * STEP 3 - Register ThymeleafViewResolver - * - * @Bean public ThymeleafViewResolver viewResolver() { ThymeleafViewResolver - * resolver = new ThymeleafViewResolver(); - * resolver.setTemplateEngine(templateEngine()); return resolver; - * - * } - * - * - */ -} \ No newline at end of file + @Bean + public LocaleChangeInterceptor localeChangeInterceptor() { + LocaleChangeInterceptor lci = new LocaleChangeInterceptor(); + lci.setParamName("language"); + return lci; + } + + @Bean + public LocaleResolver localeResolver() { + SessionLocaleResolver slr = new SessionLocaleResolver(); + slr.setDefaultLocale(new Locale("it", "IT")); + return slr; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(localeChangeInterceptor()); + } + + @Bean + public ResourceBundleMessageSource messageSource() { + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("i18n/messages"); + return messageSource; + } + + @Bean(name = "multipartResolver") + public MultipartResolver multipartResolver() { + return new StandardServletMultipartResolver(); + } + + @Bean + public SpringSecurityDialect securityDialect() { + return new SpringSecurityDialect(); + } + + @Bean + public ClassLoaderTemplateResolver templateResolver() { + + ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); + + templateResolver.setPrefix("templates/"); + templateResolver.setCacheable(false); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML5"); + templateResolver.setCharacterEncoding("UTF-8"); + + return templateResolver; + } + + @Bean + public SpringTemplateEngine templateEngine() { + + SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + templateEngine.addDialect(securityDialect()); + return templateEngine; + } + + @Bean + public ViewResolver viewResolver() { + + ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); + + viewResolver.setTemplateEngine(templateEngine()); + viewResolver.setCharacterEncoding("UTF-8"); + + return viewResolver; + } +} diff --git a/src/main/java/it/istat/rservice/RServiceApplication.java b/src/main/java/it/istat/rservice/RServiceApplication.java index 05514bb0..b5348043 100644 --- a/src/main/java/it/istat/rservice/RServiceApplication.java +++ b/src/main/java/it/istat/rservice/RServiceApplication.java @@ -21,7 +21,6 @@ * @author Stefano Macone * @version 1.0 */ - package it.istat.rservice; import org.springframework.boot.SpringApplication; @@ -31,18 +30,16 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.PropertySource; -@PropertySource(value = { "classpath:application.properties" }) @SpringBootApplication +@PropertySource(value = {"classpath:application.properties"}) public class RServiceApplication extends SpringBootServletInitializer { - public static void main(String[] args) { - - SpringApplication.run(RServiceApplication.class, args); - } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + public static void main(String[] args) { + SpringApplication.run(RServiceApplication.class, args); + } - return application.sources(RServiceApplication.class); - } + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(RServiceApplication.class); + } } diff --git a/src/main/java/it/istat/rservice/WebSecurityConfig.java b/src/main/java/it/istat/rservice/WebSecurityConfig.java index 2de7f3b9..516131d4 100644 --- a/src/main/java/it/istat/rservice/WebSecurityConfig.java +++ b/src/main/java/it/istat/rservice/WebSecurityConfig.java @@ -36,7 +36,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; - @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) @@ -45,17 +44,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private UserDetailsService userDetailsService; - @Override @Bean + @Override public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } - + @Override public void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(passwordencoder()); } - @Override protected void configure(HttpSecurity http) throws Exception { diff --git a/src/main/java/it/istat/rservice/app/controller/SessioneLavoroController.java b/src/main/java/it/istat/rservice/app/controller/SessioneLavoroController.java index 09efc1ca..96268b9c 100644 --- a/src/main/java/it/istat/rservice/app/controller/SessioneLavoroController.java +++ b/src/main/java/it/istat/rservice/app/controller/SessioneLavoroController.java @@ -67,6 +67,8 @@ public class SessioneLavoroController { @GetMapping(value = "/sessione/mostraSessioni") public String mostraSessioni(HttpSession session, Model model, @AuthenticationPrincipal User user) { + notificationService.removeAllMessages(); + List listasessioni = sessioneLavoroService.getSessioneList(user); model.addAttribute("listasessioni", listasessioni); diff --git a/src/main/java/it/istat/rservice/app/dao/ElaborazioneDao.java b/src/main/java/it/istat/rservice/app/dao/ElaborazioneDao.java index f446ff4c..db494f1d 100644 --- a/src/main/java/it/istat/rservice/app/dao/ElaborazioneDao.java +++ b/src/main/java/it/istat/rservice/app/dao/ElaborazioneDao.java @@ -22,6 +22,7 @@ * @version 1.0 */ package it.istat.rservice.app.dao; + import java.util.List; import java.util.Optional; @@ -33,9 +34,9 @@ import it.istat.rservice.app.domain.SessioneLavoro; @Repository -public interface ElaborazioneDao extends CrudRepository { +public interface ElaborazioneDao extends CrudRepository { + + List findBySessioneLavoroOrderByIdDesc(@Param("ses_elaborazione") SessioneLavoro sessioneLavoro); - List findBySessioneLavoroOrderByIdDesc(@Param("ses_elaborazione")SessioneLavoro sessioneLavoro); - - Optional findById(@Param("idelaborazione")Long idelaborazione); + Optional findById(@Param("idelaborazione") Long idelaborazione); } diff --git a/src/main/java/it/istat/rservice/app/dao/SessioneDao.java b/src/main/java/it/istat/rservice/app/dao/SessioneDao.java index fa7f8240..1cdae46a 100644 --- a/src/main/java/it/istat/rservice/app/dao/SessioneDao.java +++ b/src/main/java/it/istat/rservice/app/dao/SessioneDao.java @@ -36,7 +36,7 @@ @Repository public interface SessioneDao extends CrudRepository { - List findByUserOrderByDataCreazioneDesc(@Param("user") User user); + List findByUserOrderByDataCreazioneDesc(@Param("user") User user); - Optional findById(@Param("id") Long id); + Optional findById(@Param("id") Long id); } diff --git a/src/main/java/it/istat/rservice/app/dao/SqlGenericDao.java b/src/main/java/it/istat/rservice/app/dao/SqlGenericDao.java index 31d24959..7c0d7ddf 100644 --- a/src/main/java/it/istat/rservice/app/dao/SqlGenericDao.java +++ b/src/main/java/it/istat/rservice/app/dao/SqlGenericDao.java @@ -1,159 +1,156 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.app.dao; - -import java.util.HashMap; -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.Query; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import it.istat.rservice.dataset.domain.DatasetColonna; -import it.istat.rservice.dataset.domain.DatasetFile; -import it.istat.rservice.workflow.domain.SxWorkset; - -@Repository -public class SqlGenericDao { - @Autowired - private EntityManager em; - - public List findGenericDatasetFileAll() { - - Query q = em.createNativeQuery("select * from SX_DATASET_FILE", DatasetFile.class); - - @SuppressWarnings("unchecked") - List resultList = (List) q.getResultList(); - return resultList; - } - - public DatasetFile findGenericDatasetFileOne(Long id) { - - Query q = em.createNativeQuery("select * from SX_DATASET_FILE df where df.id=?", DatasetFile.class); - q.setParameter(1, id); - DatasetFile result = (DatasetFile) q.getSingleResult(); - return result; - } - - - - public List findWorkSetDatasetColonnaByElaborazioneQuery(Long idelaborazione,Integer tipoCampo, Integer riga_inf, - Integer riga_sup, HashMap paramsFilter) { - - String query = " SELECT rs1.id as id,rs1.nome as nome, rs1.ORDINE as ordine, rs1.tipo_var as tipo_var, rs1.paginationTotalRows as valori_size, " - + " concat('{\"valori\":', concat('[', group_concat( concat('{\"r\":\"',rs1.r,'\",\"v\":\"',rs1.v,'\"}') ORDER BY rs1.r ASC ) , ']' ) , '}' ) " + - " " - + " AS valori from " - + " ( select rs.*, max(rs.adx) OVER( PARTITION BY rs.id) as paginationTotalRows from " - + " (select ss.id as id,ss.nome as nome, ss.ordine, ss.tipo_var as tipo_var, ss.valori_size,t.r,t.v," - + " DENSE_RANK() OVER(ORDER BY t.idx) as adx from " + " SX_WORKSET ss, SX_STEP_VARIABLE sv, " - + " json_table( CONVERT( ss.valori USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v')" - + " ) t" + " where sv.elaborazione=:idelaborazione and sv.tipo_campo=:tipoCampo and sv.var=ss.id and ss.TIPO_VAR=1 "; - if (paramsFilter != null) { - for (String key : paramsFilter.keySet()) { - - query += " and t.r in( select f.r from SX_WORKSET si, SX_STEP_VARIABLE ssv,json_table( CONVERT( si.valori USING utf8), '$.valori[*]' columns " - + "( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') ) f " - + " where ssv.elaborazione=:idelaborazione and sv.tipo_campo=:tipoCampo and ssv.var=si.id and si.nome=:n_" + key - + " and f.v=:v_" + key + " ) "; - } - } - query += " order by t.idx asc " + " ) rs " + " ) rs1 " - + " where rs1.adx >:riga_inf and rs1.adx <= :riga_sup" - + " group by rs1.id,rs1.nome, rs1.ORDINE , rs1.tipo_var , rs1.paginationTotalRows "; - - Query q = em.createNativeQuery(query, SxWorkset.class); - q.setParameter("idelaborazione", idelaborazione); - q.setParameter("tipoCampo", tipoCampo); - q.setParameter("riga_inf", riga_inf); - q.setParameter("riga_sup", riga_sup); - if (paramsFilter != null) { - for (String key : paramsFilter.keySet()) { - String value = paramsFilter.get(key); - q.setParameter("n_" + key, key); - q.setParameter("v_" + key, value); - } - } - - @SuppressWarnings("unchecked") - List resultList = (List) q.getResultList(); - return resultList; - } - - - - public List findDatasetColonnaParamsbyQuery(@Param("dFile") Long dFile, - @Param("riga_inf") Integer rigaInf, @Param("riga_sup") Integer rigaSup, - HashMap paramsFilter, @Param("nameColumnToOrder") String nameColumnToOrder, - @Param("dirColumnOrder") String dirColumnOrder) { - - String query = "SELECT ss1.idcol AS idcol, " + " ss1.nome AS nome, " + " ss1.ORDINE AS ordine, " - + " ss1.FILTRO AS filtro, " + " ss1.DATASET_FILE AS dataset_file, " - + " ss1.TIPO_VARIABILE AS TIPO_VARIABILE, " + " ss1.paginationTotalRows AS valori_size, " - + " concat('{\"valori\":', concat('[', " + " group_concat( " - + " concat('{\"r\":\"',ss1.r,'\",\"v\":\"',ss1.v,'\"}') " - + " ORDER BY ss1.r ASC ) " + " , ']' ) , '}' ) as daticolonna " + " FROM " - + " ( " + " SELECT rs.*, " + " max(rs.adx) OVER() AS paginationTotalRows " - + " FROM ( " + " SELECT ss.idcol AS idcol, " - + " ss.nome AS nome, ss.ordine, ss.FILTRO AS filtro, " - + " ss.DATASET_FILE AS dataset_file, " - + " ss.TIPO_VARIABILE AS TIPO_VARIABILE, t.r, " + " t.v, " - + " DENSE_RANK () OVER (ORDER BY t.idx) AS adx " - + " FROM SX_DATASET_COLONNA ss, json_table( CONVERT( ss.daticolonna USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') )t " - + " where ss.dataset_file=:dFile"; - - if (paramsFilter != null) { - for (String key : paramsFilter.keySet()) { - - query += " and t.r in( select f.r FROM SX_DATASET_COLONNA si, json_table( CONVERT( si.daticolonna USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') )f " - + " where si.dataset_file=:dFile and si.nome=:n_" + key + " and f.v=:v_" + key - + " )"; - - } - } - - query += " order by adx asc " + " ) rs " + " ) ss1 " - + " where ss1.adx >:riga_inf and ss1.adx <= :riga_sup" - + " group by ss1.idcol,ss1.nome, ss1.ORDINE, ss1.FILTRO , ss1.DATASET_FILE, ss1.TIPO_VARIABILE, ss1.paginationTotalRows "; - - Query q = em.createNativeQuery(query, DatasetColonna.class); - q.setParameter("dFile", dFile); - q.setParameter("riga_inf", rigaInf); - q.setParameter("riga_sup", rigaSup); - if (paramsFilter != null) { - for (String key : paramsFilter.keySet()) { - String value = paramsFilter.get(key); - q.setParameter("n_" + key, key); - q.setParameter("v_" + key, value); - } - } - @SuppressWarnings("unchecked") - List resultList = (List) q.getResultList(); - return resultList; - } - -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.app.dao; + +import java.util.HashMap; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import it.istat.rservice.dataset.domain.DatasetColonna; +import it.istat.rservice.dataset.domain.DatasetFile; +import it.istat.rservice.workflow.domain.SxWorkset; + +@Repository +public class SqlGenericDao { + + @Autowired + private EntityManager em; + + public List findGenericDatasetFileAll() { + + Query q = em.createNativeQuery("select * from SX_DATASET_FILE", DatasetFile.class); + + @SuppressWarnings("unchecked") + List resultList = (List) q.getResultList(); + return resultList; + } + + public DatasetFile findGenericDatasetFileOne(Long id) { + + Query q = em.createNativeQuery("select * from SX_DATASET_FILE df where df.id=?", DatasetFile.class); + q.setParameter(1, id); + DatasetFile result = (DatasetFile) q.getSingleResult(); + return result; + } + + public List findWorkSetDatasetColonnaByElaborazioneQuery(Long idelaborazione, Integer tipoCampo, Integer riga_inf, + Integer riga_sup, HashMap paramsFilter) { + + String query = " SELECT rs1.id as id,rs1.nome as nome, rs1.ORDINE as ordine, rs1.tipo_var as tipo_var, rs1.paginationTotalRows as valori_size, " + + " concat('{\"valori\":', concat('[', group_concat( concat('{\"r\":\"',rs1.r,'\",\"v\":\"',rs1.v,'\"}') ORDER BY rs1.r ASC ) , ']' ) , '}' ) " + + " " + + " AS valori from " + + " ( select rs.*, max(rs.adx) OVER( PARTITION BY rs.id) as paginationTotalRows from " + + " (select ss.id as id,ss.nome as nome, ss.ordine, ss.tipo_var as tipo_var, ss.valori_size,t.r,t.v," + + " DENSE_RANK() OVER(ORDER BY t.idx) as adx from " + " SX_WORKSET ss, SX_STEP_VARIABLE sv, " + + " json_table( CONVERT( ss.valori USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v')" + + " ) t" + " where sv.elaborazione=:idelaborazione and sv.tipo_campo=:tipoCampo and sv.var=ss.id and ss.TIPO_VAR=1 "; + if (paramsFilter != null) { + for (String key : paramsFilter.keySet()) { + + query += " and t.r in( select f.r from SX_WORKSET si, SX_STEP_VARIABLE ssv,json_table( CONVERT( si.valori USING utf8), '$.valori[*]' columns " + + "( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') ) f " + + " where ssv.elaborazione=:idelaborazione and sv.tipo_campo=:tipoCampo and ssv.var=si.id and si.nome=:n_" + key + + " and f.v=:v_" + key + " ) "; + } + } + query += " order by t.idx asc " + " ) rs " + " ) rs1 " + + " where rs1.adx >:riga_inf and rs1.adx <= :riga_sup" + + " group by rs1.id,rs1.nome, rs1.ORDINE , rs1.tipo_var , rs1.paginationTotalRows "; + + Query q = em.createNativeQuery(query, SxWorkset.class); + q.setParameter("idelaborazione", idelaborazione); + q.setParameter("tipoCampo", tipoCampo); + q.setParameter("riga_inf", riga_inf); + q.setParameter("riga_sup", riga_sup); + if (paramsFilter != null) { + for (String key : paramsFilter.keySet()) { + String value = paramsFilter.get(key); + q.setParameter("n_" + key, key); + q.setParameter("v_" + key, value); + } + } + + @SuppressWarnings("unchecked") + List resultList = (List) q.getResultList(); + return resultList; + } + + public List findDatasetColonnaParamsbyQuery(@Param("dFile") Long dFile, + @Param("riga_inf") Integer rigaInf, @Param("riga_sup") Integer rigaSup, + HashMap paramsFilter, @Param("nameColumnToOrder") String nameColumnToOrder, + @Param("dirColumnOrder") String dirColumnOrder) { + + String query = "SELECT ss1.idcol AS idcol, " + " ss1.nome AS nome, " + " ss1.ORDINE AS ordine, " + + " ss1.FILTRO AS filtro, " + " ss1.DATASET_FILE AS dataset_file, " + + " ss1.TIPO_VARIABILE AS TIPO_VARIABILE, " + " ss1.paginationTotalRows AS valori_size, " + + " concat('{\"valori\":', concat('[', " + " group_concat( " + + " concat('{\"r\":\"',ss1.r,'\",\"v\":\"',ss1.v,'\"}') " + + " ORDER BY ss1.r ASC ) " + " , ']' ) , '}' ) as daticolonna " + " FROM " + + " ( " + " SELECT rs.*, " + " max(rs.adx) OVER() AS paginationTotalRows " + + " FROM ( " + " SELECT ss.idcol AS idcol, " + + " ss.nome AS nome, ss.ordine, ss.FILTRO AS filtro, " + + " ss.DATASET_FILE AS dataset_file, " + + " ss.TIPO_VARIABILE AS TIPO_VARIABILE, t.r, " + " t.v, " + + " DENSE_RANK () OVER (ORDER BY t.idx) AS adx " + + " FROM SX_DATASET_COLONNA ss, json_table( CONVERT( ss.daticolonna USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') )t " + + " where ss.dataset_file=:dFile"; + + if (paramsFilter != null) { + for (String key : paramsFilter.keySet()) { + + query += " and t.r in( select f.r FROM SX_DATASET_COLONNA si, json_table( CONVERT( si.daticolonna USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') )f " + + " where si.dataset_file=:dFile and si.nome=:n_" + key + " and f.v=:v_" + key + + " )"; + + } + } + + query += " order by adx asc " + " ) rs " + " ) ss1 " + + " where ss1.adx >:riga_inf and ss1.adx <= :riga_sup" + + " group by ss1.idcol,ss1.nome, ss1.ORDINE, ss1.FILTRO , ss1.DATASET_FILE, ss1.TIPO_VARIABILE, ss1.paginationTotalRows "; + + Query q = em.createNativeQuery(query, DatasetColonna.class); + q.setParameter("dFile", dFile); + q.setParameter("riga_inf", rigaInf); + q.setParameter("riga_sup", rigaSup); + if (paramsFilter != null) { + for (String key : paramsFilter.keySet()) { + String value = paramsFilter.get(key); + q.setParameter("n_" + key, key); + q.setParameter("v_" + key, value); + } + } + @SuppressWarnings("unchecked") + List resultList = (List) q.getResultList(); + return resultList; + } + +} diff --git a/src/main/java/it/istat/rservice/app/dao/UserDao.java b/src/main/java/it/istat/rservice/app/dao/UserDao.java index 0eafba2e..1e146adc 100644 --- a/src/main/java/it/istat/rservice/app/dao/UserDao.java +++ b/src/main/java/it/istat/rservice/app/dao/UserDao.java @@ -30,12 +30,11 @@ import it.istat.rservice.app.domain.User; - @Repository public interface UserDao extends CrudRepository { public User findByEmail(String email); - public void save(Optional user); + public void save(Optional user); } diff --git a/src/main/java/it/istat/rservice/app/service/CustomUserDetailsService.java b/src/main/java/it/istat/rservice/app/service/CustomUserDetailsService.java index 11a8643c..679b2d06 100644 --- a/src/main/java/it/istat/rservice/app/service/CustomUserDetailsService.java +++ b/src/main/java/it/istat/rservice/app/service/CustomUserDetailsService.java @@ -1,81 +1,80 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.app.service; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.stereotype.Service; - -import it.istat.rservice.app.dao.UserDao; -import it.istat.rservice.app.dao.UserRolesDao; -import it.istat.rservice.app.domain.User; -import it.istat.rservice.app.security.CustomUserDetails; - -@Service -public class CustomUserDetailsService implements UserDetailsService { - - private final UserDao userDao; - private final UserRolesDao userRolesDao; - - @Autowired - private NotificationService notificationService; - - @Autowired - private AuthenticationManager am; - - @Autowired - public CustomUserDetailsService(UserDao userDao, UserRolesDao userRolesDao) { - this.userDao = userDao; - this.userRolesDao = userRolesDao; - } - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - User user = userDao.findByEmail(email); - CustomUserDetails cud; - if (null == user) { - notificationService.addErrorMessage("Nessun user presente con user: " + email); - throw new UsernameNotFoundException("No user present with user: " + email); - } else { - List userRoles = userRolesDao.findRoleByEmail(email); - cud = new CustomUserDetails(user, userRoles); - return cud; - } - } - - public void authenticate(String name, Object password) { - Authentication request = new UsernamePasswordAuthenticationToken(name, password); - Authentication result = am.authenticate(request); - SecurityContextHolder.getContext().setAuthentication(result); - - } - -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.app.service; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.stereotype.Service; + +import it.istat.rservice.app.dao.UserDao; +import it.istat.rservice.app.dao.UserRolesDao; +import it.istat.rservice.app.domain.User; +import it.istat.rservice.app.security.CustomUserDetails; + +@Service +public class CustomUserDetailsService implements UserDetailsService { + + private final UserDao userDao; + private final UserRolesDao userRolesDao; + + @Autowired + private NotificationService notificationService; + + @Autowired + private AuthenticationManager am; + + @Autowired + public CustomUserDetailsService(UserDao userDao, UserRolesDao userRolesDao) { + this.userDao = userDao; + this.userRolesDao = userRolesDao; + } + + @Override + public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { + User user = userDao.findByEmail(email); + CustomUserDetails cud; + if (null == user) { + notificationService.addErrorMessage("Nessun user presente con user: " + email); + throw new UsernameNotFoundException("No user present with user: " + email); + } else { + List userRoles = userRolesDao.findRoleByEmail(email); + cud = new CustomUserDetails(user, userRoles); + return cud; + } + } + + public void authenticate(String name, Object password) { + Authentication request = new UsernamePasswordAuthenticationToken(name, password); + Authentication result = am.authenticate(request); + SecurityContextHolder.getContext().setAuthentication(result); + } + +} diff --git a/src/main/java/it/istat/rservice/app/service/ElaborazioneService.java b/src/main/java/it/istat/rservice/app/service/ElaborazioneService.java index d32c7bd9..1734d8b0 100644 --- a/src/main/java/it/istat/rservice/app/service/ElaborazioneService.java +++ b/src/main/java/it/istat/rservice/app/service/ElaborazioneService.java @@ -47,7 +47,7 @@ public Elaborazione salvaElaborazione(Elaborazione elaborazione) { return elaborazioneDao.save(elaborazione); } - public Optional findElaborazione(Long idelaborazione) { - return elaborazioneDao.findById(idelaborazione); + public Elaborazione findElaborazione(Long idelaborazione) { + return elaborazioneDao.findById(idelaborazione).orElse(null); } } diff --git a/src/main/java/it/istat/rservice/app/service/NotificationService.java b/src/main/java/it/istat/rservice/app/service/NotificationService.java index 1b3cdc06..9ee5079c 100644 --- a/src/main/java/it/istat/rservice/app/service/NotificationService.java +++ b/src/main/java/it/istat/rservice/app/service/NotificationService.java @@ -1,120 +1,118 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.app.service; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpSession; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class NotificationService { - - public static final String NOTIFY_MSG_SESSION_KEY = "siteNotificationMessages"; - - @Autowired - private HttpSession httpSession; - - public void addInfoMessage(String msg) { - addNotificationMessage(NotificationMessageType.SUCCESS, msg, ""); - } - - public void addInfoMessage(String msg, String details) { - addNotificationMessage(NotificationMessageType.SUCCESS, msg, details); - } - - public void addErrorMessage(String msg) { - addNotificationMessage(NotificationMessageType.DANGER, msg, ""); - } - - public void addErrorMessage(String msg, String details) { - addNotificationMessage(NotificationMessageType.DANGER, msg, details); - } - - public void removeAllMessages() { - if (httpSession != null) { - httpSession.removeAttribute(NOTIFY_MSG_SESSION_KEY); - } - } - - @SuppressWarnings("unchecked") - private void addNotificationMessage(NotificationMessageType type, String msg, String details) { - List notifyMessages = (List) httpSession - .getAttribute(NOTIFY_MSG_SESSION_KEY); - if (notifyMessages == null) { - notifyMessages = new ArrayList(); - } - notifyMessages.add(new NotificationMessage(type, msg, details)); - httpSession.setAttribute(NOTIFY_MSG_SESSION_KEY, notifyMessages); - } - - @SuppressWarnings("unchecked") - public List getNotificationMessages() { - List notifyMessages = (List) httpSession - .getAttribute(NOTIFY_MSG_SESSION_KEY); - if (notifyMessages == null) { - notifyMessages = new ArrayList(); - } - return notifyMessages; - } - - public enum NotificationMessageType { - SUCCESS, DANGER - } - - public class NotificationMessage { - - NotificationMessageType type; - String text; - String details; - - public NotificationMessage(NotificationMessageType type, String text) { - this.type = type; - this.text = text; - this.details = ""; - } - - public NotificationMessage(NotificationMessageType type, String text, String details) { - this.type = type; - this.text = text; - this.details = details; - - } - - public NotificationMessageType getType() { - return type; - } - - public String getText() { - return text; - } - - public String getDetails() { - return details; - } - } -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.app.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class NotificationService { + + public static final String NOTIFY_MSG_SESSION_KEY = "siteNotificationMessages"; + + @Autowired + private HttpSession httpSession; + + public void addInfoMessage(String msg) { + addNotificationMessage(NotificationMessageType.SUCCESS, msg, ""); + } + + public void addInfoMessage(String msg, String details) { + addNotificationMessage(NotificationMessageType.SUCCESS, msg, details); + } + + public void addErrorMessage(String msg) { + addNotificationMessage(NotificationMessageType.DANGER, msg, ""); + } + + public void addErrorMessage(String msg, String details) { + addNotificationMessage(NotificationMessageType.DANGER, msg, details); + } + + public void removeAllMessages() { + if (httpSession != null) { + httpSession.removeAttribute(NOTIFY_MSG_SESSION_KEY); + } + } + + @SuppressWarnings("unchecked") + private void addNotificationMessage(NotificationMessageType type, String msg, String details) { + List notifyMessages = (List) httpSession.getAttribute(NOTIFY_MSG_SESSION_KEY); + if (notifyMessages == null) { + notifyMessages = new ArrayList(); + } + notifyMessages.add(new NotificationMessage(type, msg, details)); + httpSession.setAttribute(NOTIFY_MSG_SESSION_KEY, notifyMessages); + } + + @SuppressWarnings("unchecked") + public List getNotificationMessages() { + List notifyMessages = (List) httpSession.getAttribute(NOTIFY_MSG_SESSION_KEY); + if (notifyMessages == null) { + notifyMessages = new ArrayList(); + } + return notifyMessages; + } + + public enum NotificationMessageType { + SUCCESS, DANGER + } + + public class NotificationMessage { + + NotificationMessageType type; + String text; + String details; + + public NotificationMessage(NotificationMessageType type, String text) { + this.type = type; + this.text = text; + this.details = ""; + } + + public NotificationMessage(NotificationMessageType type, String text, String details) { + this.type = type; + this.text = text; + this.details = details; + + } + + public NotificationMessageType getType() { + return type; + } + + public String getText() { + return text; + } + + public String getDetails() { + return details; + } + } +} diff --git a/src/main/java/it/istat/rservice/app/service/SessioneLavoroService.java b/src/main/java/it/istat/rservice/app/service/SessioneLavoroService.java index cd771825..1708d273 100644 --- a/src/main/java/it/istat/rservice/app/service/SessioneLavoroService.java +++ b/src/main/java/it/istat/rservice/app/service/SessioneLavoroService.java @@ -55,8 +55,8 @@ public Optional getSessione(Long id) { } public SessioneLavoro getSessioneByIdFile(Long id) { - Optional dataset = datasetService.findDataSetFile(id); - return dataset.get().getSessioneLavoro(); + DatasetFile dataset = datasetService.findDataSetFile(id); + return dataset.getSessioneLavoro(); } public List getSessioneList(User user) { diff --git a/src/main/java/it/istat/rservice/app/util/IS2Const.java b/src/main/java/it/istat/rservice/app/util/IS2Const.java index 33e65fcd..4a5c183c 100644 --- a/src/main/java/it/istat/rservice/app/util/IS2Const.java +++ b/src/main/java/it/istat/rservice/app/util/IS2Const.java @@ -1,41 +1,42 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.app.util; - -public interface IS2Const { - - public static final String SESSION_LV = "sessionelv"; - public static final String SESSION_ELABORAZIONE = "elaborazione"; - public static final String WORKINGSET = "workingset"; - public static final int WORKSET_TIPO_VARIABILE = 1; - public static final int WORKSET_TIPO_PARAMETRO = 2; - public static final int WORKSET_TIPO_MODELLO = 3; - public static final int CODICE_APP_SERVICE_R = 100; - public static final int VARIABILE_TIPO_INPUT = 1; - public static final int VARIABILE_TIPO_OUTPUT = 2; - public static final String LISTA_BUSINESS_PROCESS = "listaBP"; - public static final String SESSION_DATASET = "sessionelavdataset"; - public static final int TIPO_CAMPO_INPUT = 1; - public static final int TIPO_CAMPO_ELABORATO = 2; -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.app.util; + +public interface IS2Const { + + public static final String SESSION_LV = "sessionelv"; + public static final String SESSION_ELABORAZIONE = "elaborazione"; + public static final String WORKINGSET = "workingset"; + public static final int WORKSET_TIPO_VARIABILE = 1; + public static final int WORKSET_TIPO_PARAMETRO = 2; + public static final int WORKSET_TIPO_MODELLO = 3; + public static final int CODICE_APP_SERVICE_R = 100; + public static final int VARIABILE_TIPO_INPUT = 1; + public static final int VARIABILE_TIPO_OUTPUT = 2; + public static final String LISTA_BUSINESS_PROCESS = "listaBP"; + public static final String SESSION_DATASET = "sessionelavdataset"; + public static final int TIPO_CAMPO_INPUT = 1; + public static final int TIPO_CAMPO_ELABORATO = 2; + +} diff --git a/src/main/java/it/istat/rservice/app/util/Utility.java b/src/main/java/it/istat/rservice/app/util/Utility.java index 240611ed..458c8c45 100644 --- a/src/main/java/it/istat/rservice/app/util/Utility.java +++ b/src/main/java/it/istat/rservice/app/util/Utility.java @@ -1,460 +1,446 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.app.util; - -import java.io.IOException; -import java.io.PrintWriter; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.TimeZone; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVPrinter; -import org.apache.log4j.Logger; -import it.istat.rservice.app.bean.InputFormBean; -import it.istat.rservice.workflow.domain.SxBusinessProcess; -import it.istat.rservice.workflow.domain.SxRuoli; -import it.istat.rservice.workflow.domain.SxStepVariable; -import it.istat.rservice.workflow.domain.SxTipoVar; - -public class Utility { - - public static String getLocalDate() { - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Europe/Rome"), Locale.ITALY); - Date today = calendar.getTime(); - String dataOutput = null; - try { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss"); - dataOutput = simpleDateFormat.format(today); - } catch (Exception e) { - e.printStackTrace(); - } - return dataOutput; - } - - public static String buildQueryFilter(Long idelaborazione, HashMap paramsFilter) { - - String paramQuery = " "; - - if (paramsFilter != null) { - for (String key : paramsFilter.keySet()) { - String value = paramsFilter.get(key); - paramQuery += " and t.r in( select f.r from SX_WORKSET si, SX_STEP_VARIABLE ssv,json_table(si.valori, '$.valori[*]' columns " - + "( idx FOR ORDINALITY,r integer path '$.r', v varchar2 path '$.v') ) f " - + " where ssv.elaborazione=" + idelaborazione + " and ssv.var=si.id and si.nome='" + key - + "' and f.v='" + value + "') "; - } - } - return paramQuery; - } - - public static HashMap recuperaParametri(HashMap params, - Map parameterMap) { - // HashMap per l'invio in procedura - HashMap paramsToUse = new HashMap(); - String param = ""; - - for (String key : params.keySet()) { - - if (parameterMap.get("param_" + key) != null) { - param = parameterMap.get("param_" + key)[0]; - paramsToUse.put(key, param); - } - } - return paramsToUse; - } - - // Ritorna un HashMap che mappa in modo dinamico i tipi dell'header provenienti - // dal form con gli indici dell'header che abbiamo dal file - public static HashMap> mappaHeaderValues(Map parameterMap, - ArrayList valoriHeader, int size) { - // Mappa in modo dinamico i tipi dell'header provenienti dal form con gli indici - // dell'header che abbiamo dal file - HashMap> headerValues = new HashMap>(); - List> colonne = new ArrayList>(); - - for (int i = 0; i < size; i++) { - List list = new ArrayList<>(); - colonne.add(list); - } - // Ogni valore iesimo per noi è una colonna dell'intestazione - for (int i = 0; i < valoriHeader.size(); i++) { - - String value = parameterMap.get("sel_" + i)[0]; - int intValue = Integer.parseInt(value); - // Controlla i tipi e riempie l'hashmap con la relativa etichetta (ad es. chiave - // "variabile core" -> lista variabili core) - // TODO: I tipi vanno presi da un file di configurazione dei metadati, - // attualmente sono in calce lato javascript e lato java: Skip:0, Id:1, Y:2, - // X:3, Pred:4 - switch (intValue) { - case 0: - colonne.get(0).add(i); - break; - case 1: - colonne.get(1).add(i); - break; - case 2: - colonne.get(2).add(i); - break; - case 3: - colonne.get(3).add(i); - break; - case 4: - colonne.get(4).add(i); - break; - } - - } - // Vado a riempire l'hashmap con gli array di interi in modo posizionale - // rispetto all'header - // Le chiavi saranno sempre quelle del file di configurazione dei tipi, per ora: - // Skip:0, Id:1, Y:2, X:3, Pred:4 - for (int i = 0; i < size; i++) { - headerValues.put(i, colonne.get(i)); - } - return headerValues; - } - - public static void stampaValoriHeader(HashMap> headerValues, int size) { - for (int i = 0; i < size; i++) { - switch (i) { - case 0: - Logger.getRootLogger().info("Colonne skippate: " + headerValues.get(0)); - break; - case 1: - Logger.getRootLogger().info("Colonne Id: " + headerValues.get(1)); - break; - case 2: - Logger.getRootLogger().info("Colonne Y: " + headerValues.get(2)); - break; - case 3: - Logger.getRootLogger().info("Colonne X: " + headerValues.get(3)); - break; - case 4: - Logger.getRootLogger().info("Colonne Pred: " + headerValues.get(4)); - break; - } - } - } - - public static HashMap createParamsMap() { - // TODO: da integrare con la gestione parametri da file e sintesi - HashMap params = new HashMap(); - params.put("model", "LN"); - params.put("lambda", "3"); - params.put("w", "0.0479"); - params.put("lambda.fix", "TRUE"); - params.put("w.fix", "TRUE"); - params.put("eps", "1e-7"); - params.put("max.iter", "500"); - params.put("t.outl", "0.5"); - params.put("graph", "TRUE"); - params.put("beta", "-0.152 1.215"); - params.put("sigma", "1.25"); - params.put("n.outlier", "0"); - params.put("is.conv", ""); - params.put("n.iter", "0"); - params.put("sing", ""); - params.put("bic.aic", ""); - params.put("wgt", ""); - params.put("tot", ""); - params.put("t.sel", ""); - return params; - } - - public static HashMap> creaListaTipi() { - // HashMap tipi: TODO: da integrare con la gestione parametri da file e sintesi - HashMap> tipoDato = new HashMap>(); - ArrayList skip = new ArrayList(); - skip.add(0, "Z"); - skip.add(1, "skip"); - - List identificativo = new ArrayList(); - identificativo.add(0, "Id"); - identificativo.add(1, "identificativo"); - - List target = new ArrayList(); - target.add(0, "Y"); - target.add(1, "target"); - - List covariata = new ArrayList(); - covariata.add(0, "X"); - covariata.add(1, "covariata"); - - List predizione = new ArrayList(); - predizione.add(0, "P"); - predizione.add(1, "predizione"); - - List outlier = new ArrayList(); - outlier.add(0, "O"); - outlier.add(1, "outlier"); - - List peso = new ArrayList(); - peso.add(0, "W"); - peso.add(1, "peso"); - - List errore = new ArrayList(); - errore.add(0, "E"); - errore.add(1, "errore"); - - List ranking = new ArrayList(); - ranking.add(0, "R"); - ranking.add(1, "ranking"); - - List output = new ArrayList(); - output.add(0, "Out"); - output.add(1, "output"); - - List strato = new ArrayList(); - strato.add(0, "S"); - strato.add(1, "strato"); - - tipoDato.put(0, skip); - tipoDato.put(1, identificativo); - tipoDato.put(2, target); - tipoDato.put(3, covariata); - tipoDato.put(4, predizione); - tipoDato.put(5, outlier); - tipoDato.put(6, peso); - tipoDato.put(7, errore); - tipoDato.put(8, ranking); - tipoDato.put(9, output); - tipoDato.put(10, strato); - return tipoDato; - } - - public static HashMap> recuperaVariabiliForm(InputFormBean form, - HashMap> headerValuesSelected) { - headerValuesSelected = new HashMap>(); - String identificativo = form.getIdentificativo(); - if (!identificativo.equals("")) { - identificativo = identificativo.substring(0, identificativo.length() - 1); - } - String target = form.getTarget(); - if (!target.equals("")) { - target = target.substring(0, target.length() - 1); - } - String covariata = form.getCovariata(); - if (!covariata.equals("")) { - covariata = covariata.substring(0, covariata.length() - 1); - } - String predizione = form.getPredizioni(); - if (!predizione.equals("")) { - predizione = predizione.substring(0, predizione.length() - 1); - } - String outlier = form.getOutlier(); - if (outlier == null) { - outlier = ""; - } - if (outlier != null && !outlier.equals("")) { - outlier = outlier.substring(0, outlier.length() - 1); - } - String delim = ","; - - StringTokenizer st = new StringTokenizer(identificativo, delim); - String chiaveId = "identificativo"; - - ArrayList valoriId = new ArrayList(); - while (st.hasMoreTokens()) { - String value = st.nextToken(); - valoriId.add(value); - } - headerValuesSelected.put(chiaveId, valoriId); - - StringTokenizer st2 = new StringTokenizer(target, delim); - String chiaveCorr = "target"; - ArrayList valoriCorr = new ArrayList(); - while (st2.hasMoreTokens()) { - String value = st2.nextToken(); - valoriCorr.add(value); - } - headerValuesSelected.put(chiaveCorr, valoriCorr); - - StringTokenizer st3 = new StringTokenizer(covariata, delim); - String chiaveCov = "covariata"; - ArrayList valoriCov = new ArrayList(); - while (st3.hasMoreTokens()) { - String value = st3.nextToken(); - valoriCov.add(value); - } - headerValuesSelected.put(chiaveCov, valoriCov); - - StringTokenizer st4 = new StringTokenizer(predizione, delim); - String chiavePred = "predizione"; - ArrayList valoriPred = new ArrayList(); - while (st4.hasMoreTokens()) { - String value = st4.nextToken(); - valoriPred.add(value); - } - headerValuesSelected.put(chiavePred, valoriPred); - - StringTokenizer st5 = new StringTokenizer(outlier, delim); - String chiaveOutl = "outlier"; - ArrayList valoriOutl = new ArrayList(); - while (st5.hasMoreTokens()) { - String value = st5.nextToken(); - valoriOutl.add(value); - } - headerValuesSelected.put(chiaveOutl, valoriOutl); - - return headerValuesSelected; - } - - /** - * @param sxTipoVar - * @param dataList - * @return - */ - public static HashMap> getMapWorkSetValues(Map dataMap, - SxTipoVar sxTipoVar) { - - HashMap> ret = new HashMap<>(); - - for (Map.Entry entry : dataMap.entrySet()) { - String nomeW = entry.getKey(); - SxStepVariable sxStepVariable = entry.getValue(); - if (sxStepVariable.getSxWorkset().getSxTipoVar().getId().equals(sxTipoVar.getId())) { - ret.put(nomeW, (ArrayList) sxStepVariable.getSxWorkset().getValori()); - } - } - return ret; - } - - public static Map> getMapCodiceRuoloStepVariabili(List dataList) { - - HashMap> ret = new HashMap<>(); - for (SxStepVariable stepV : dataList) { - String codR = stepV.getSxRuoli().getCod(); - ArrayList lista = ret.get(codR); - if (lista == null) { - lista = new ArrayList(); - } - lista.add(stepV); - ret.put(codR, lista); - } - return ret; - } - - public static Map getMapNameWorkSetStep(List dataList) { - - HashMap ret = new HashMap<>(); - for (SxStepVariable sxStepVariable : dataList) { - - ret.put(sxStepVariable.getSxWorkset().getNome(), sxStepVariable); - } - return ret; - } - - /** - * @param ruoliAll - * @return - */ - public static Map getMapRuoliByCod(List ruoliAll) { - - HashMap ret = new HashMap<>(); - for (SxRuoli sxRuoli : ruoliAll) { - - ret.put(sxRuoli.getCod(), sxRuoli); - } - return ret; - } - - public static String combineList2String4R(List lista) { - String c = ""; - if (lista != null && !lista.isEmpty()) { - c = "c("; - for (String s : lista) { - c += "'" + s + "',"; - } - c = c.substring(0, c.length() - 1) + ")"; - } - Logger.getRootLogger().debug("c4R: <" + c + ">"); - return c; - } - - public static Map getMapRuoliById(List ruoliAll) { - HashMap ret = new HashMap<>(); - for (SxRuoli sxRuoli : ruoliAll) { - - ret.put(sxRuoli.getId(), sxRuoli); - } - return ret; - } - - /** - * @param listaBp - * @return - */ - public static SxBusinessProcess getSxBusinessProcess(List listaBp, Long idprocesso) { - - for (SxBusinessProcess bP : listaBp) { - if (bP.getId().equals(idprocesso)) { - return bP; - } - } - return null; - - } - - public static void writeObjectToCSV(PrintWriter writer, Map> dataMap) throws IOException { - ArrayList header = new ArrayList(); - CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.EXCEL); - try { - String wi = ""; - for (Iterator iterator = dataMap.keySet().iterator(); iterator.hasNext();) { - wi = (String) iterator.next(); - header.add(wi); - } - - csvPrinter.printRecord(header); - - int size = dataMap.get(wi).size(); - - for (int i = 0; i < size; i++) { - List data = new ArrayList<>(); - for (Iterator iterator = dataMap.keySet().iterator(); iterator.hasNext();) { - wi = (String) iterator.next(); - data.add(dataMap.get(wi).get(i)); - - } - - csvPrinter.printRecord(data); - } - csvPrinter.flush(); - csvPrinter.close(); - } catch (Exception e) { - csvPrinter.flush(); - csvPrinter.close(); - - } - } -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.app.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.TimeZone; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVPrinter; +import org.apache.log4j.Logger; +import it.istat.rservice.app.bean.InputFormBean; +import it.istat.rservice.workflow.domain.SxBusinessProcess; +import it.istat.rservice.workflow.domain.SxRuoli; +import it.istat.rservice.workflow.domain.SxStepVariable; +import it.istat.rservice.workflow.domain.SxTipoVar; + +public class Utility { + + public static String getLocalDate() { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Europe/Rome"), Locale.ITALY); + Date today = calendar.getTime(); + String dataOutput = null; + try { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss"); + dataOutput = simpleDateFormat.format(today); + } catch (Exception e) { + e.printStackTrace(); + } + return dataOutput; + } + + public static String buildQueryFilter(Long idelaborazione, HashMap paramsFilter) { + + String paramQuery = " "; + + if (paramsFilter != null) { + for (String key : paramsFilter.keySet()) { + String value = paramsFilter.get(key); + paramQuery += " and t.r in( select f.r from SX_WORKSET si, SX_STEP_VARIABLE ssv,json_table(si.valori, '$.valori[*]' columns " + + "( idx FOR ORDINALITY,r integer path '$.r', v varchar2 path '$.v') ) f " + + " where ssv.elaborazione=" + idelaborazione + " and ssv.var=si.id and si.nome='" + key + + "' and f.v='" + value + "') "; + } + } + return paramQuery; + } + + public static HashMap recuperaParametri(HashMap params, + Map parameterMap) { + // HashMap per l'invio in procedura + HashMap paramsToUse = new HashMap(); + String param = ""; + + for (String key : params.keySet()) { + + if (parameterMap.get("param_" + key) != null) { + param = parameterMap.get("param_" + key)[0]; + paramsToUse.put(key, param); + } + } + return paramsToUse; + } + + // Ritorna un HashMap che mappa in modo dinamico i tipi dell'header provenienti + // dal form con gli indici dell'header che abbiamo dal file + public static HashMap> mappaHeaderValues(Map parameterMap, + ArrayList valoriHeader, int size) { + // Mappa in modo dinamico i tipi dell'header provenienti dal form con gli indici + // dell'header che abbiamo dal file + HashMap> headerValues = new HashMap>(); + List> colonne = new ArrayList>(); + + for (int i = 0; i < size; i++) { + List list = new ArrayList<>(); + colonne.add(list); + } + // Ogni valore iesimo per noi è una colonna dell'intestazione + for (int i = 0; i < valoriHeader.size(); i++) { + + String value = parameterMap.get("sel_" + i)[0]; + int intValue = Integer.parseInt(value); + // Controlla i tipi e riempie l'hashmap con la relativa etichetta (ad es. chiave + // "variabile core" -> lista variabili core) + // TODO: I tipi vanno presi da un file di configurazione dei metadati, + // attualmente sono in calce lato javascript e lato java: Skip:0, Id:1, Y:2, + // X:3, Pred:4 + switch (intValue) { + case 0: + colonne.get(0).add(i); + break; + case 1: + colonne.get(1).add(i); + break; + case 2: + colonne.get(2).add(i); + break; + case 3: + colonne.get(3).add(i); + break; + case 4: + colonne.get(4).add(i); + break; + } + + } + // Vado a riempire l'hashmap con gli array di interi in modo posizionale + // rispetto all'header + // Le chiavi saranno sempre quelle del file di configurazione dei tipi, per ora: + // Skip:0, Id:1, Y:2, X:3, Pred:4 + for (int i = 0; i < size; i++) { + headerValues.put(i, colonne.get(i)); + } + return headerValues; + } + + public static void stampaValoriHeader(HashMap> headerValues, int size) { + for (int i = 0; i < size; i++) { + switch (i) { + case 0: + Logger.getRootLogger().info("Colonne skippate: " + headerValues.get(0)); + break; + case 1: + Logger.getRootLogger().info("Colonne Id: " + headerValues.get(1)); + break; + case 2: + Logger.getRootLogger().info("Colonne Y: " + headerValues.get(2)); + break; + case 3: + Logger.getRootLogger().info("Colonne X: " + headerValues.get(3)); + break; + case 4: + Logger.getRootLogger().info("Colonne Pred: " + headerValues.get(4)); + break; + } + } + } + + public static HashMap createParamsMap() { + // TODO: da integrare con la gestione parametri da file e sintesi + HashMap params = new HashMap(); + params.put("model", "LN"); + params.put("lambda", "3"); + params.put("w", "0.0479"); + params.put("lambda.fix", "TRUE"); + params.put("w.fix", "TRUE"); + params.put("eps", "1e-7"); + params.put("max.iter", "500"); + params.put("t.outl", "0.5"); + params.put("graph", "TRUE"); + params.put("beta", "-0.152 1.215"); + params.put("sigma", "1.25"); + params.put("n.outlier", "0"); + params.put("is.conv", ""); + params.put("n.iter", "0"); + params.put("sing", ""); + params.put("bic.aic", ""); + params.put("wgt", ""); + params.put("tot", ""); + params.put("t.sel", ""); + return params; + } + + public static HashMap> creaListaTipi() { + // HashMap tipi: TODO: da integrare con la gestione parametri da file e sintesi + HashMap> tipoDato = new HashMap>(); + ArrayList skip = new ArrayList(); + skip.add(0, "Z"); + skip.add(1, "skip"); + + List identificativo = new ArrayList(); + identificativo.add(0, "Id"); + identificativo.add(1, "identificativo"); + + List target = new ArrayList(); + target.add(0, "Y"); + target.add(1, "target"); + + List covariata = new ArrayList(); + covariata.add(0, "X"); + covariata.add(1, "covariata"); + + List predizione = new ArrayList(); + predizione.add(0, "P"); + predizione.add(1, "predizione"); + + List outlier = new ArrayList(); + outlier.add(0, "O"); + outlier.add(1, "outlier"); + + List peso = new ArrayList(); + peso.add(0, "W"); + peso.add(1, "peso"); + + List errore = new ArrayList(); + errore.add(0, "E"); + errore.add(1, "errore"); + + List ranking = new ArrayList(); + ranking.add(0, "R"); + ranking.add(1, "ranking"); + + List output = new ArrayList(); + output.add(0, "Out"); + output.add(1, "output"); + + List strato = new ArrayList(); + strato.add(0, "S"); + strato.add(1, "strato"); + + tipoDato.put(0, skip); + tipoDato.put(1, identificativo); + tipoDato.put(2, target); + tipoDato.put(3, covariata); + tipoDato.put(4, predizione); + tipoDato.put(5, outlier); + tipoDato.put(6, peso); + tipoDato.put(7, errore); + tipoDato.put(8, ranking); + tipoDato.put(9, output); + tipoDato.put(10, strato); + return tipoDato; + } + + public static HashMap> recuperaVariabiliForm(InputFormBean form, + HashMap> headerValuesSelected) { + headerValuesSelected = new HashMap>(); + String identificativo = form.getIdentificativo(); + if (!identificativo.equals("")) { + identificativo = identificativo.substring(0, identificativo.length() - 1); + } + String target = form.getTarget(); + if (!target.equals("")) { + target = target.substring(0, target.length() - 1); + } + String covariata = form.getCovariata(); + if (!covariata.equals("")) { + covariata = covariata.substring(0, covariata.length() - 1); + } + String predizione = form.getPredizioni(); + if (!predizione.equals("")) { + predizione = predizione.substring(0, predizione.length() - 1); + } + String outlier = form.getOutlier(); + if (outlier == null) { + outlier = ""; + } + if (outlier != null && !outlier.equals("")) { + outlier = outlier.substring(0, outlier.length() - 1); + } + String delim = ","; + + StringTokenizer st = new StringTokenizer(identificativo, delim); + String chiaveId = "identificativo"; + + ArrayList valoriId = new ArrayList(); + while (st.hasMoreTokens()) { + String value = st.nextToken(); + valoriId.add(value); + } + headerValuesSelected.put(chiaveId, valoriId); + + StringTokenizer st2 = new StringTokenizer(target, delim); + String chiaveCorr = "target"; + ArrayList valoriCorr = new ArrayList(); + while (st2.hasMoreTokens()) { + String value = st2.nextToken(); + valoriCorr.add(value); + } + headerValuesSelected.put(chiaveCorr, valoriCorr); + + StringTokenizer st3 = new StringTokenizer(covariata, delim); + String chiaveCov = "covariata"; + ArrayList valoriCov = new ArrayList(); + while (st3.hasMoreTokens()) { + String value = st3.nextToken(); + valoriCov.add(value); + } + headerValuesSelected.put(chiaveCov, valoriCov); + + StringTokenizer st4 = new StringTokenizer(predizione, delim); + String chiavePred = "predizione"; + ArrayList valoriPred = new ArrayList(); + while (st4.hasMoreTokens()) { + String value = st4.nextToken(); + valoriPred.add(value); + } + headerValuesSelected.put(chiavePred, valoriPred); + + StringTokenizer st5 = new StringTokenizer(outlier, delim); + String chiaveOutl = "outlier"; + ArrayList valoriOutl = new ArrayList(); + while (st5.hasMoreTokens()) { + String value = st5.nextToken(); + valoriOutl.add(value); + } + headerValuesSelected.put(chiaveOutl, valoriOutl); + + return headerValuesSelected; + } + + public static HashMap> getMapWorkSetValues(Map dataMap, + SxTipoVar sxTipoVar) { + + HashMap> ret = new HashMap<>(); + + for (Map.Entry entry : dataMap.entrySet()) { + String nomeW = entry.getKey(); + SxStepVariable sxStepVariable = entry.getValue(); + if (sxStepVariable.getSxWorkset().getSxTipoVar().getId().equals(sxTipoVar.getId())) { + ret.put(nomeW, (ArrayList) sxStepVariable.getSxWorkset().getValori()); + } + } + return ret; + } + + public static Map> getMapCodiceRuoloStepVariabili(List dataList) { + + HashMap> ret = new HashMap<>(); + for (SxStepVariable stepV : dataList) { + String codR = stepV.getSxRuoli().getCod(); + ArrayList lista = ret.get(codR); + if (lista == null) { + lista = new ArrayList(); + } + lista.add(stepV); + ret.put(codR, lista); + } + return ret; + } + + public static Map getMapNameWorkSetStep(List dataList) { + + HashMap ret = new HashMap<>(); + for (SxStepVariable sxStepVariable : dataList) { + + ret.put(sxStepVariable.getSxWorkset().getNome(), sxStepVariable); + } + return ret; + } + + public static Map getMapRuoliByCod(List ruoliAll) { + + HashMap ret = new HashMap<>(); + for (SxRuoli sxRuoli : ruoliAll) { + + ret.put(sxRuoli.getCod(), sxRuoli); + } + return ret; + } + + public static String combineList2String4R(List lista) { + String c = ""; + if (lista != null && !lista.isEmpty()) { + c = "c("; + for (String s : lista) { + c += "'" + s + "',"; + } + c = c.substring(0, c.length() - 1) + ")"; + } + Logger.getRootLogger().debug("c4R: <" + c + ">"); + return c; + } + + public static Map getMapRuoliById(List ruoliAll) { + HashMap ret = new HashMap<>(); + for (SxRuoli sxRuoli : ruoliAll) { + ret.put(sxRuoli.getId(), sxRuoli); + } + return ret; + } + + public static SxBusinessProcess getSxBusinessProcess(List listaBp, Long idprocesso) { + + for (SxBusinessProcess bP : listaBp) { + if (bP.getId().equals(idprocesso)) { + return bP; + } + } + return null; + + } + + public static void writeObjectToCSV(PrintWriter writer, Map> dataMap) throws IOException { + ArrayList header = new ArrayList(); + CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.EXCEL); + try { + String wi = ""; + for (Iterator iterator = dataMap.keySet().iterator(); iterator.hasNext();) { + wi = (String) iterator.next(); + header.add(wi); + } + + csvPrinter.printRecord(header); + + int size = dataMap.get(wi).size(); + + for (int i = 0; i < size; i++) { + List data = new ArrayList<>(); + for (Iterator iterator = dataMap.keySet().iterator(); iterator.hasNext();) { + wi = (String) iterator.next(); + data.add(dataMap.get(wi).get(i)); + + } + + csvPrinter.printRecord(data); + } + csvPrinter.flush(); + csvPrinter.close(); + } catch (Exception e) { + csvPrinter.flush(); + csvPrinter.close(); + + } + } +} diff --git a/src/main/java/it/istat/rservice/dataset/controller/DatasetController.java b/src/main/java/it/istat/rservice/dataset/controller/DatasetController.java index 5d691fcc..f95face4 100644 --- a/src/main/java/it/istat/rservice/dataset/controller/DatasetController.java +++ b/src/main/java/it/istat/rservice/dataset/controller/DatasetController.java @@ -49,8 +49,6 @@ import it.istat.rservice.app.service.NotificationService; import it.istat.rservice.app.service.SessioneLavoroService; import it.istat.rservice.app.util.FileHandler; -import it.istat.rservice.dataset.dao.DatasetColonnaDao; -import it.istat.rservice.dataset.dao.DatasetFileDao; import it.istat.rservice.dataset.domain.DatasetColonna; import it.istat.rservice.dataset.domain.DatasetFile; import it.istat.rservice.dataset.domain.TipoVariabileSum; @@ -59,20 +57,15 @@ @Controller public class DatasetController { - @Autowired - private DatasetFileDao datasetFileDao; @Autowired private DatasetService datasetService; - - @Autowired - private DatasetColonnaDao datasetColonna; @Autowired ServletContext context; @Autowired private NotificationService notificationService; - + @Autowired private MessageSource messages; @@ -88,6 +81,8 @@ public String carica(Model model, @PathVariable("idsessione") Long idsessione) { @RequestMapping("/viewDataset/{idfile}") public String caricafile(Model model, @PathVariable("idfile") Long idfile) { + notificationService.removeAllMessages(); + DatasetFile dfile = datasetService.findDataSetFile(idfile); List colonne = datasetService.findAllNomeColonne(idfile); @@ -142,54 +137,15 @@ public String caricaMetadati(Model model, String idfile, String idvar, String fi return "dataset/edit_dataset"; } -/* - @RequestMapping("/viewDatasetMenu/{idsessione}") - public String viewDatasetMenu(Model model, @PathVariable Long idsessione) { - - DatasetFile dfile = datasetService.findDatasetFileByIdSessioneLavoro(idsessione); - if (dfile != null) { - List colonne = datasetService.findAllNomeColonne(dfile.getId()); - List variabiliSum = datasetService.findAllVariabiliSum(); - - model.addAttribute("colonne", colonne); - model.addAttribute("idfile", dfile.getId()); - model.addAttribute("variabili", variabiliSum); - model.addAttribute("dfile", dfile); - - return "dataset/datasetpreview"; - } else { - model.addAttribute("idsessione", idsessione); - return "dataset/loadFile"; - - } - } - - @RequestMapping("/viewDatasetMenu/{idsessione}/{idelaborazione}") - public String viewDatasetMenuElaborazione(Model model, @PathVariable("idsessione") Long idsessione, @PathVariable("idelaborazione") Long idelaborazione) { - - DatasetFile dfile = datasetService.findDatasetFileByIdSessioneLavoro(idsessione); - if (dfile != null) { - List colonne = datasetService.findAllNomeColonne(dfile.getId()); - List variabiliSum = datasetService.findAllVariabiliSum(); - model.addAttribute("idelaborazione", idelaborazione); - model.addAttribute("colonne", colonne); - model.addAttribute("idfile", dfile.getId()); - model.addAttribute("variabili", variabiliSum); - - return "dataset/datasetpreview"; - } else { - model.addAttribute("idsessione", idsessione); - return "dataset/loadFile"; - - } - } -*/ @RequestMapping(value = "/loadInputData", method = RequestMethod.POST) - public String loadInputData(HttpSession session, HttpServletRequest request, Model model, @ModelAttribute("inputFormBean") InputFormBean form) throws IOException { + public String loadInputData(HttpSession session, HttpServletRequest request, + Model model, @ModelAttribute("inputFormBean") InputFormBean form) throws IOException { + + notificationService.removeAllMessages(); - String labelFile = form.getLabelFile(); - Integer tipoDato = form.getTipoDato(); + String labelFile = form.getLabelFile(); + Integer tipoDato = form.getTipoDato(); String separatore = form.getDelimiter(); String idsessione = form.getIdsessione(); @@ -200,7 +156,7 @@ public String loadInputData(HttpSession session, HttpServletRequest request, Mod try { valoriHeaderNum = FileHandler.getCampiHeaderNumIndex(pathTmpFile, separatore.toCharArray()[0]); } catch (Exception e) { - notificationService.addErrorMessage(messages.getMessage("file.read.error", null, LocaleContextHolder.getLocale()), e.getMessage()); + notificationService.addErrorMessage(messages.getMessage("file.read.error", null, LocaleContextHolder.getLocale()), e.getMessage()); return "redirect:/sessione/mostradataset/" + idsessione; } @@ -210,12 +166,12 @@ public String loadInputData(HttpSession session, HttpServletRequest request, Mod } catch (Exception e) { notificationService.addErrorMessage(messages.getMessage("file.read.error", null, LocaleContextHolder.getLocale()), e.getMessage()); } - + try { datasetService.salva(campiL, valoriHeaderNum, labelFile, tipoDato, separatore, form.getDescrizione(), idsessione); notificationService.addInfoMessage("Salvataggio avvenuto con successo."); } catch (Exception e) { - notificationService.addErrorMessage("Errore nel salvataggio del file."); + notificationService.addErrorMessage("Errore nel salvataggio del file."); return "redirect:/sessione/mostradataset/" + idsessione; } @@ -223,13 +179,13 @@ public String loadInputData(HttpSession session, HttpServletRequest request, Mod } @RequestMapping("/createField/{idfile}/{idColonna}/{commandField}/{charOrString}/{upperLower}/{newField}/{columnOrder}") - public String createField(Model model, @PathVariable("idfile") String idfile, @PathVariable("idColonna") String idColonna, @PathVariable("commandField") String commandField, @PathVariable("charOrString") String charOrString, @PathVariable("upperLower") String upperLower, @PathVariable("newField") String newField, @PathVariable("columnOrder") String columnOrder ) { - + public String createField(Model model, @PathVariable("idfile") String idfile, @PathVariable("idColonna") String idColonna, + @PathVariable("commandField") String commandField, @PathVariable("charOrString") String charOrString, + @PathVariable("upperLower") String upperLower, @PathVariable("newField") String newField, + @PathVariable("columnOrder") String columnOrder) { - - DatasetFile dFile = datasetService.createField(idfile, idColonna, commandField, charOrString, upperLower, newField, columnOrder); + DatasetFile dFile = datasetService.createField(idfile, idColonna, commandField, charOrString, upperLower, newField, columnOrder); - List colonne = datasetService.findAllNomeColonne(Long.parseLong(idfile)); List variabiliSum = datasetService.findAllVariabiliSum(); @@ -244,10 +200,12 @@ public String createField(Model model, @PathVariable("idfile") String idfile, @P @RequestMapping(value = "/deleteDataset", method = RequestMethod.POST) public String deleteDataset(Model model, @RequestParam("idDataset") Long idDataset) { - SessioneLavoro sessionelv = sessioneLavoroService.getSessioneByIdFile(idDataset); - datasetService.deleteDataset(idDataset); + notificationService.removeAllMessages(); + + SessioneLavoro sessionelv = sessioneLavoroService.getSessioneByIdFile(idDataset); + datasetService.deleteDataset(idDataset); notificationService.addInfoMessage("Eliminazione avvenuta con successo"); - - return "redirect:/sessione/mostradataset/" + sessionelv.getId(); + + return "redirect:/sessione/mostradataset/" + sessionelv.getId(); } } diff --git a/src/main/java/it/istat/rservice/dataset/controller/rest/DatasetControllerRest.java b/src/main/java/it/istat/rservice/dataset/controller/rest/DatasetControllerRest.java index 63659f1e..c10d5263 100644 --- a/src/main/java/it/istat/rservice/dataset/controller/rest/DatasetControllerRest.java +++ b/src/main/java/it/istat/rservice/dataset/controller/rest/DatasetControllerRest.java @@ -60,8 +60,8 @@ public class DatasetControllerRest { @GetMapping("/datasetfile/{id}") @ResponseBody - public Optional loadDataSetFile(@PathVariable("id") Long id) throws IOException { - Optional df = datasetService.findDataSetFile(id); + public DatasetFile loadDataSetFile(@PathVariable("id") Long id) throws IOException { + DatasetFile df = datasetService.findDataSetFile(id); return df; } diff --git a/src/main/java/it/istat/rservice/dataset/dao/DatasetColonnaDao.java b/src/main/java/it/istat/rservice/dataset/dao/DatasetColonnaDao.java index d2d035fc..541cd59e 100644 --- a/src/main/java/it/istat/rservice/dataset/dao/DatasetColonnaDao.java +++ b/src/main/java/it/istat/rservice/dataset/dao/DatasetColonnaDao.java @@ -76,10 +76,7 @@ List findDatasetColonnabyQueryFilter(@Param("dFile") Long dFile, + " where ss.dataset_file=:dFile " + " group by ss.idcol,ss.nome, ss.ORDINE , ss.DATASET_FILE, ss.TIPO_VARIABILE ", nativeQuery = true) List findDatasetColonnabyQueryAll(@Param("dFile") Long dFile); - - /** - * @param datasetFile - */ + @Transactional @Modifying @Query(value = "delete from DatasetColonna dc where dc.datasetFile=:dFile ") diff --git a/src/main/java/it/istat/rservice/dataset/dao/DatasetFileDao.java b/src/main/java/it/istat/rservice/dataset/dao/DatasetFileDao.java index 5e1a56b7..a12113d6 100644 --- a/src/main/java/it/istat/rservice/dataset/dao/DatasetFileDao.java +++ b/src/main/java/it/istat/rservice/dataset/dao/DatasetFileDao.java @@ -1,56 +1,56 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.dataset.dao; - - -import java.util.List; - -import javax.transaction.Transactional; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; - -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import it.istat.rservice.app.domain.SessioneLavoro; -import it.istat.rservice.dataset.domain.DatasetFile; - -@Repository -public interface DatasetFileDao extends JpaRepository { - - @Query(value="SELECT u FROM DatasetFile u.id = 1", nativeQuery = true) - DatasetFile findQuiery(); - - @Query(value="SELECT df.numerorighe from DatasetFile df where df.id =:dFile") - Integer findNumeroRighe(@Param("dFile") Long dFile); - - List findDatasetFilesBySessioneLavoro(SessioneLavoro sessioneLavoro); - - @Transactional - @Modifying - @Query(value="delete from DatasetFile df where df.id=:dFile ") - void deleteDatasetFile(@Param("dFile")Long dFile); -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.dataset.dao; + + +import java.util.List; + +import javax.transaction.Transactional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; + +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import it.istat.rservice.app.domain.SessioneLavoro; +import it.istat.rservice.dataset.domain.DatasetFile; + +@Repository +public interface DatasetFileDao extends JpaRepository { + + @Query(value="SELECT u FROM DatasetFile u.id = 1", nativeQuery = true) + DatasetFile findQuery(); + + @Query(value="SELECT df.numerorighe from DatasetFile df where df.id =:dFile") + Integer findNumeroRighe(@Param("dFile") Long dFile); + + List findDatasetFilesBySessioneLavoro(SessioneLavoro sessioneLavoro); + + @Transactional + @Modifying + @Query(value="delete from DatasetFile df where df.id=:dFile ") + void deleteDatasetFile(@Param("dFile")Long dFile); +} diff --git a/src/main/java/it/istat/rservice/dataset/service/DatasetService.java b/src/main/java/it/istat/rservice/dataset/service/DatasetService.java index cc65af5a..704b9ca7 100644 --- a/src/main/java/it/istat/rservice/dataset/service/DatasetService.java +++ b/src/main/java/it/istat/rservice/dataset/service/DatasetService.java @@ -40,7 +40,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; import it.istat.rservice.app.bean.DataTableBean; import it.istat.rservice.app.dao.SessioneDao; @@ -56,7 +55,7 @@ @Service public class DatasetService { - + @Autowired private DatasetFileDao datasetFileDao; @Autowired @@ -126,7 +125,7 @@ public DatasetFile findDataSetFile(Long id) { return datasetFileDao.findById(id).get(); } - public List findDatasetFilesByIdSessioneLavoro(Long id) { + public List findDatasetFilesByIdSessioneLavoro(Long id) { return datasetFileDao.findDatasetFilesBySessioneLavoro(new SessioneLavoro(id)); } @@ -209,7 +208,7 @@ public String loadDatasetValori1(Long dfile, Integer length, Integer start, Inte } public List findAllDatasetColonnaQueryFilter(Long dFile, Integer rigaInf, Integer rigaSup, String filterFieldName, String filterFieldValue, List fieldSelect) { - List dataList = datasetColonnaDao.findDatasetColonnabyQueryFilter(dFile, rigaInf, rigaSup,filterFieldName, filterFieldValue, fieldSelect); + List dataList = datasetColonnaDao.findDatasetColonnabyQueryFilter(dFile, rigaInf, rigaSup, filterFieldName, filterFieldValue, fieldSelect); return dataList; } @@ -227,158 +226,134 @@ public Map> loadDatasetValori(Long idfile) { DatasetFile datasetFile = findDataSetFile(idfile); Map> ret = new LinkedHashMap<>(); - for (Iterator iterator = datasetFile.getColonne().iterator(); iterator.hasNext();) { + for (Iterator iterator = datasetFile.getColonne().iterator(); iterator.hasNext();) { DatasetColonna dc = (DatasetColonna) iterator.next(); ret.put(dc.getNome(), dc.getDatiColonna()); } return ret; } - - public DatasetFile createField(String idfile, String idColonna, String commandField, String charOrString, String upperLower, String newField, String columnOrder) { - - - - DatasetColonna nuovaColonna = new DatasetColonna(); - Optional colonna = findOneColonna(Long.parseLong(idColonna)); - List datiColonna = colonna.get().getDatiColonna(); - //cambia i valori della colonna - List datiColonnaTemp = new ArrayList(); - //cambia i valori della colonna - switch (commandField) - { - case "0001": - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toLowerCase())); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toUpperCase())); - } - - - - break; - case "0010": - if(!charOrString.equals("")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, ""))); - } - break; - case "0100": - - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll("[^a-zA-Z0-9]", ""))); - - break; - case "1000": - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(" ",""))); - break; - case "0011": - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase())); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase())); - } - - break; - case "0101": - - - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toLowerCase().replaceAll("[^a-zA-Z0-9]", ""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toUpperCase().replaceAll("[^a-zA-Z0-9]", ""))); - } - - - break; - case "1001": - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toLowerCase().replaceAll(" ",""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toUpperCase().replaceAll(" ",""))); - } - - break; - case "0111": - if(!charOrString.equals("")){ - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll("[^a-zA-Z0-9]", ""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(charOrString, ""))); - } - - } - break; - case "1011": - if(!charOrString.equals("")){ - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll(" ",""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(" ",""))); - } - - } - break; - case "0110": - if(!charOrString.equals("")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll("[^a-zA-Z0-9]", ""))); - } - break; - case "1010": - if(!charOrString.equals("")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll(" ",""))); - } - break; - case "1100": - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - break; - case "1101": - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toLowerCase().replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.toUpperCase().replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - } - break; - case "1111": - if(!charOrString.equals("")){ - if(upperLower.equals("low")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - }else{ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - } - } - break; - case "1110": - if(!charOrString.equals("")){ - datiColonna.forEach((item)->datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll(" ","").replaceAll("[^a-zA-Z0-9]", ""))); - } - break; - case "0000": - datiColonna.forEach((item)->datiColonnaTemp.add(item)); - - break; - - - default: - datiColonna.forEach((item)->datiColonnaTemp.add(item)); - }; - - //DatasetFile dFile = datasetService.findDataSetFile(idfile); - DatasetFile dFile = new DatasetFile(); - dFile.setId(Long.parseLong(idfile)); - nuovaColonna.setDatasetFile(dFile); - nuovaColonna.setNome(newField); - nuovaColonna.setOrdine( (short) Integer.parseInt(columnOrder) ); - nuovaColonna.setValoriSize(datiColonna.size()); - - nuovaColonna.setDatiColonna(datiColonnaTemp); - datasetColonna.save(nuovaColonna); - + + public DatasetFile createField(String idfile, String idColonna, String commandField, String charOrString, String upperLower, String newField, String columnOrder) { + + DatasetColonna nuovaColonna = new DatasetColonna(); + Optional colonna = findOneColonna(Long.parseLong(idColonna)); + List datiColonna = colonna.get().getDatiColonna(); + //cambia i valori della colonna + List datiColonnaTemp = new ArrayList(); + //cambia i valori della colonna + switch (commandField) { + case "0001": + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toLowerCase())); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toUpperCase())); + } + break; + case "0010": + if (!charOrString.equals("")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, ""))); + } + break; + case "0100": + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll("[^a-zA-Z0-9]", ""))); + break; + case "1000": + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(" ", ""))); + break; + case "0011": + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase())); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase())); + } + break; + case "0101": + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toLowerCase().replaceAll("[^a-zA-Z0-9]", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toUpperCase().replaceAll("[^a-zA-Z0-9]", ""))); + } + break; + case "1001": + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toLowerCase().replaceAll(" ", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toUpperCase().replaceAll(" ", ""))); + } + break; + case "0111": + if (!charOrString.equals("")) { + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll("[^a-zA-Z0-9]", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(charOrString, ""))); + } + } + break; + case "1011": + if (!charOrString.equals("")) { + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll(" ", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(" ", ""))); + } + } + break; + case "0110": + if (!charOrString.equals("")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll("[^a-zA-Z0-9]", ""))); + } + break; + case "1010": + if (!charOrString.equals("")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll(" ", ""))); + } + break; + case "1100": + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + break; + case "1101": + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toLowerCase().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.toUpperCase().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + } + break; + case "1111": + if (!charOrString.equals("")) { + if (upperLower.equals("low")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toLowerCase().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + } else { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").toUpperCase().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + } + } + break; + case "1110": + if (!charOrString.equals("")) { + datiColonna.forEach((item) -> datiColonnaTemp.add(item.replaceAll(charOrString, "").replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", ""))); + } + break; + case "0000": + datiColonna.forEach((item) -> datiColonnaTemp.add(item)); + break; + default: + datiColonna.forEach((item) -> datiColonnaTemp.add(item)); + }; + + //DatasetFile dFile = datasetService.findDataSetFile(idfile); + DatasetFile dFile = new DatasetFile(); + dFile.setId(Long.parseLong(idfile)); + nuovaColonna.setDatasetFile(dFile); + nuovaColonna.setNome(newField); + nuovaColonna.setOrdine((short) Integer.parseInt(columnOrder)); + nuovaColonna.setValoriSize(datiColonna.size()); + + nuovaColonna.setDatiColonna(datiColonnaTemp); + datasetColonna.save(nuovaColonna); + return dFile; } - - - - - - + @Transactional public Boolean deleteDataset(Long idFile) { DatasetFile datasetFile = findDataSetFile(idFile); diff --git a/src/main/java/it/istat/rservice/relais/dao/RelaisGenericDao.java b/src/main/java/it/istat/rservice/relais/dao/RelaisGenericDao.java index df6dba3a..27bbd8c8 100644 --- a/src/main/java/it/istat/rservice/relais/dao/RelaisGenericDao.java +++ b/src/main/java/it/istat/rservice/relais/dao/RelaisGenericDao.java @@ -1,129 +1,126 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @author Paolo Francescangeli - * @author Renzo Iannacone - * @author Stefano Macone - * @version 1.0 - */ -package it.istat.rservice.relais.dao; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.persistence.EntityManager; -import javax.persistence.Query; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - -@Repository -public class RelaisGenericDao { - - @Autowired - private EntityManager em; - - // Return a Map Values - public Map crossTable(Long idelaborazione, LinkedHashMap> ruoliVariabileNome) - throws Exception { - - Map> worksetOut = new LinkedHashMap>(); - // variabileNomeList = new ArrayList<>(); - - final StringBuilder selectFieldsbuilder = new StringBuilder(); - ruoliVariabileNome.values().forEach((list) -> { - selectFieldsbuilder.append(String.join(",", list)); - selectFieldsbuilder.append(","); - variabileNomeList.addAll(list); - }); - - String selectFields = selectFieldsbuilder.substring(0, selectFieldsbuilder.length()-1); - - // init worksetOut - variabileNomeList.forEach(name -> { - worksetOut.put(name, new ArrayList<>()); - }); - - HashMap paramsQuery = new HashMap<>(); - paramsQuery.put("idelaborazione", idelaborazione); - - String query = " SELECT " + selectFields + " FROM "; - int indexRole = 0; - for (Iterator iterator = ruoliVariabileNome.keySet().iterator(); iterator.hasNext();) { - String codRole = (String) iterator.next(); - indexRole++; - String paramCodRole = "codRole" + indexRole; - paramsQuery.put(paramCodRole, codRole); - - ArrayList variableList = ruoliVariabileNome.get(codRole); - query += " ( SELECT " + String.join(",", variableList) + " FROM "; - int indexVariableName = 0; - for (Iterator iterator2 = variableList.iterator(); iterator2.hasNext();) { - String variableName = (String) iterator2.next(); - indexVariableName++; - String paramVariableName = "variabilename" +indexRole+"_"+ indexVariableName; - paramsQuery.put(paramVariableName, variableName); - query += " ( SELECT t.r, t.v as " + variableName - + " FROM SX_WORKSET ss, SX_STEP_VARIABLE sv,SX_RUOLI sr, json_table(CONVERT( ss.valori USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') ) t " - + " where sv.elaborazione=:idelaborazione and sv.var=ss.id and ss.TIPO_VAR=1 and sv.ruolo=sr.id and sr.cod=:" - + paramCodRole + " and ss.nome=:" + paramVariableName + " ) subqvn" + indexVariableName; - if (variableList.size() > 1 && indexVariableName < variableList.size() ) query += ","; - - } - query += " ) subqr" + indexRole; - if (ruoliVariabileNome.size() > 1 && indexRole < ruoliVariabileNome.size() ) - query += ","; - - } - - - Query q = em.createNativeQuery(query); - - paramsQuery.forEach((key, value) -> { - - q.setParameter(key, value); - - }); - - - List risList = q.getResultList(); - - for (Iterator iterator = risList.iterator(); iterator.hasNext();) { - Object[] ris = (Object[]) iterator.next(); - int indexValues = 0; - for (Iterator iterator2 = variabileNomeList.iterator(); iterator2.hasNext();) { - String name = (String) iterator2.next(); - ArrayList valueList = worksetOut.get(name); - valueList.add(ris[indexValues].toString()); - indexValues++; - worksetOut.put(name, valueList); - } - - } - - return worksetOut; - } - - -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @author Paolo Francescangeli + * @author Renzo Iannacone + * @author Stefano Macone + * @version 1.0 + */ +package it.istat.rservice.relais.dao; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class RelaisGenericDao { + + @Autowired + private EntityManager em; + + // Return a Map Values + public Map crossTable(Long idelaborazione, LinkedHashMap> ruoliVariabileNome) throws Exception { + + Map> worksetOut = new LinkedHashMap>(); + // variabileNomeList = new ArrayList<>(); + + final StringBuilder selectFieldsbuilder = new StringBuilder(); + ruoliVariabileNome.values().forEach((list) -> { + selectFieldsbuilder.append(String.join(",", list)); + selectFieldsbuilder.append(","); + variabileNomeList.addAll(list); + }); + + String selectFields = selectFieldsbuilder.substring(0, selectFieldsbuilder.length() - 1); + + // init worksetOut + variabileNomeList.forEach(name -> { + worksetOut.put(name, new ArrayList<>()); + }); + + HashMap paramsQuery = new HashMap<>(); + paramsQuery.put("idelaborazione", idelaborazione); + + String query = " SELECT " + selectFields + " FROM "; + int indexRole = 0; + for (Iterator iterator = ruoliVariabileNome.keySet().iterator(); iterator.hasNext();) { + String codRole = (String) iterator.next(); + indexRole++; + String paramCodRole = "codRole" + indexRole; + paramsQuery.put(paramCodRole, codRole); + + ArrayList variableList = ruoliVariabileNome.get(codRole); + query += " ( SELECT " + String.join(",", variableList) + " FROM "; + int indexVariableName = 0; + for (Iterator iterator2 = variableList.iterator(); iterator2.hasNext();) { + String variableName = (String) iterator2.next(); + indexVariableName++; + String paramVariableName = "variabilename" + indexRole + "_" + indexVariableName; + paramsQuery.put(paramVariableName, variableName); + query += " ( SELECT t.r, t.v as " + variableName + + " FROM SX_WORKSET ss, SX_STEP_VARIABLE sv,SX_RUOLI sr, json_table(CONVERT( ss.valori USING utf8), '$.valori[*]' columns ( idx FOR ORDINALITY,r int path '$.r', v varchar(100) path '$.v') ) t " + + " where sv.elaborazione=:idelaborazione and sv.var=ss.id and ss.TIPO_VAR=1 and sv.ruolo=sr.id and sr.cod=:" + + paramCodRole + " and ss.nome=:" + paramVariableName + " ) subqvn" + indexVariableName; + if (variableList.size() > 1 && indexVariableName < variableList.size()) { + query += ","; + } + + } + query += " ) subqr" + indexRole; + if (ruoliVariabileNome.size() > 1 && indexRole < ruoliVariabileNome.size()) { + query += ","; + } + + } + + Query q = em.createNativeQuery(query); + + paramsQuery.forEach((key, value) -> { + q.setParameter(key, value); + }); + + List risList = q.getResultList(); + + for (Iterator iterator = risList.iterator(); iterator.hasNext();) { + Object[] ris = (Object[]) iterator.next(); + int indexValues = 0; + for (Iterator iterator2 = variabileNomeList.iterator(); iterator2.hasNext();) { + String name = (String) iterator2.next(); + ArrayList valueList = worksetOut.get(name); + valueList.add(ris[indexValues].toString()); + indexValues++; + worksetOut.put(name, valueList); + } + + } + + return worksetOut; + } + +} diff --git a/src/main/java/it/istat/rservice/relais/service/RelaisService.java b/src/main/java/it/istat/rservice/relais/service/RelaisService.java index d86b310d..363cd8ec 100644 --- a/src/main/java/it/istat/rservice/relais/service/RelaisService.java +++ b/src/main/java/it/istat/rservice/relais/service/RelaisService.java @@ -1,51 +1,49 @@ -/** - * Copyright 2019 ISTAT - * - * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. You may - * obtain a copy of the Licence at: - * - * http://ec.europa.eu/idabc/eupl5 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * Licence for the specific language governing permissions and limitations under - * the Licence. - * - * @author Francesco Amato - * @author Mauro Bruno - * @version 0.1.1 - */ -/** - * - */ -package it.istat.rservice.relais.service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import it.istat.rservice.relais.dao.RelaisGenericDao; - -/** - * @author framato - * - */ -@Service -public class RelaisService { - - @Autowired - private RelaisGenericDao relaisGenericDao; - - - public Map crossTable(Long idelaborazione,Map ruoliVariabileNome) throws Exception { - return relaisGenericDao.crossTable(idelaborazione,(LinkedHashMap>) ruoliVariabileNome); - } - -} +/** + * Copyright 2019 ISTAT + * + * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. You may + * obtain a copy of the Licence at: + * + * http://ec.europa.eu/idabc/eupl5 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * Licence for the specific language governing permissions and limitations under + * the Licence. + * + * @author Francesco Amato + * @author Mauro Bruno + * @version 0.1.1 + */ +/** + * + */ +package it.istat.rservice.relais.service; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import it.istat.rservice.relais.dao.RelaisGenericDao; + +/** + * @author framato + * + */ +@Service +public class RelaisService { + + @Autowired + private RelaisGenericDao relaisGenericDao; + + public Map crossTable(Long idelaborazione, Map ruoliVariabileNome) throws Exception { + return relaisGenericDao.crossTable(idelaborazione, (LinkedHashMap>) ruoliVariabileNome); + } + +} diff --git a/src/main/java/it/istat/rservice/workflow/controller/WorkflowController.java b/src/main/java/it/istat/rservice/workflow/controller/WorkflowController.java index f434bf1e..f6e492f8 100644 --- a/src/main/java/it/istat/rservice/workflow/controller/WorkflowController.java +++ b/src/main/java/it/istat/rservice/workflow/controller/WorkflowController.java @@ -71,349 +71,349 @@ @Controller public class WorkflowController { - @Autowired - private WorkflowService workflowService; - @Autowired - private NotificationService notificationService; - @Autowired - private MessageSource messages; - @Autowired - private SessioneLavoroService sessioneLavoroService; - @Autowired - private ElaborazioneService elaborazioneService; - @Autowired - private BusinessFunctionService businessFunctionService; - @Autowired - private DatasetService datasetService; - @Autowired - private StepVariableService stepVariableService; - - @GetMapping(value = "/home/{id}") - public String homeWS(HttpSession session, Model model, @PathVariable("id") Long id) { - notificationService.removeAllMessages(); - - Elaborazione elaborazione = workflowService.findElaborazione(id).get(); - List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); - SxBusinessProcess bProcess = listaBp.get(0); - List listaSV = workflowService.getSxStepVariablesNoValori(elaborazione.getId(), - new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); - model.addAttribute("stepVList", listaSV); - - SessionBean elaSession = new SessionBean(elaborazione.getId().toString(), elaborazione.getNome()); - session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); - - model.addAttribute("bProcess", bProcess); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); - - return "elaborazione/homeelaborazione"; - } - - @GetMapping(value = "/eliminaAssociazione/{idelaborazione}/{idvar}") - public String eliminaAssociazioneVar(HttpSession session, Model model, - @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idvar") Long idvar) { - notificationService.removeAllMessages(); - - SxStepVariable stepVar = stepVariableService.findById(idvar).get(); - List listaVars = stepVar.getSxWorkset().getSxStepVariables(); - - if (listaVars.size() == 1) { - SxWorkset workset = (SxWorkset) listaVars.get(0).getSxWorkset(); - workflowService.deleteWorkset(workset); - } else { - // do nothing - } - - stepVariableService.removeStepVarById(idvar); - notificationService.addInfoMessage("La variabile è stata rimossa"); - - return "redirect:/ws/editworkingset/" + idelaborazione; - } - - @GetMapping(value = "/eliminaParametro/{idelaborazione}/{idparametro}") - public String eliminaParametro(HttpSession session, Model model, - @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idparametro") Long idparametro) { - notificationService.removeAllMessages(); - - SxStepVariable stepVar = stepVariableService.findById(idparametro).get(); - List listaVars = stepVar.getSxWorkset().getSxStepVariables(); - - if (listaVars.size() == 1) { - SxWorkset workset = (SxWorkset) listaVars.get(0).getSxWorkset(); - workflowService.deleteWorkset(workset); - } else { - // do nothing - } - - stepVariableService.removeStepVarById(idparametro); - notificationService.addInfoMessage("Il parametro è stato eliminato"); - - return "redirect:/ws/editworkingset/" + idelaborazione; - } - - @GetMapping(value = "/newworkingset/{idelaborazione}") - public String createWorkingSet(HttpSession session, Model model, - @PathVariable("idelaborazione") Long idElaborazione) { - session.setAttribute(IS2Const.WORKINGSET, "workingset"); - - Optional elaborazione = elaborazioneService.findElaborazione(idElaborazione); - - SessionBean elaSession = new SessionBean(elaborazione.get().getId().toString(), elaborazione.get().getNome()); - session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); - - List datasetfiles = datasetService - .findDatasetFilesByIdSessioneLavoro(elaborazione.get().getSessioneLavoro().getId()); - DatasetFile datasetfile = datasetfiles.get(0); - model.addAttribute("idfile", datasetfile.getId()); - - List colonne = datasetService.findAllNomeColonne(datasetfile); - List listaSV = workflowService.getSxStepVariablesNoValori(idElaborazione, - new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); - List listaSP = workflowService.getSxStepVariablesParametri(idElaborazione); - List listaFunzioni = businessFunctionService.findBFunctions(); - - SxBusinessFunction businessFunction = elaborazione.get().getSxBusinessFunction(); - - // Carica i Ruoli di input - List listaRuoliInput = workflowService.findRuoliByFunction(businessFunction, 0); - // Carica i Ruoli di input e output - List listaRuoliInOut = workflowService.findRuoliByFunction(businessFunction, 1); - List listaParametri = workflowService.findParametriByFunction(businessFunction); - List listaBp = elaborazione.get().getSxBusinessFunction().getSxBusinessProcesses(); - - model.addAttribute("bProcess", listaBp); - model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); - model.addAttribute("stepVList", listaSV); - - ArrayList listaNomiSV = new ArrayList(); - for (int i = 0; i < listaSV.size(); i++) { - String nomeStepVariable = listaSV.get(i).getSxWorkset().getNome(); - listaNomiSV.add(nomeStepVariable); - for (int y = 0; y < colonne.size(); y++) { - String nomeCol = colonne.get(y).getNome(); - if (listaNomiSV.contains(nomeCol)) { - colonne.remove(colonne.get(y)); - } - } - } - - model.addAttribute("stepParamList", listaSP); - model.addAttribute("colonne", colonne); - model.addAttribute("listaRuoliInput", listaRuoliInput); - model.addAttribute("listaRuoliInOut", listaRuoliInOut); - model.addAttribute("listaParametri", listaParametri); - model.addAttribute("listaFunzioni", listaFunzioni); - model.addAttribute("datasetfile", datasetfile); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute("businessFunction", businessFunction); - - return "elaborazione/edit_ws"; - - } - - @GetMapping(value = "/editworkingset/{idelaborazione}") - public String editWorkingSet(HttpSession session, Model model, - @PathVariable("idelaborazione") Long idElaborazione) { - - session.setAttribute(IS2Const.WORKINGSET, "workingset"); - - Optional elaborazione = elaborazioneService.findElaborazione(idElaborazione); - - SessionBean elaSession = new SessionBean(elaborazione.get().getId().toString(), elaborazione.get().getNome()); - session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); - - List datasetfiles = datasetService - .findDatasetFilesByIdSessioneLavoro(elaborazione.get().getSessioneLavoro().getId()); - - datasetfiles.forEach(datasetfile -> { - // retrieve DatasetColonna without data - List colonne = datasetService.findAllNomeColonne(datasetfile); - datasetfile.setColonne(colonne); - - }); - - List listaSV = workflowService.getSxStepVariablesNoValori(idElaborazione, - new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); - List listaSP = workflowService.getSxStepVariablesParametri(idElaborazione); - List listaFunzioni = businessFunctionService.findBFunctions(); - - SxBusinessFunction businessFunction = elaborazione.get().getSxBusinessFunction(); - - // Carica i Ruoli di input - List listaRuoliInput = workflowService.findRuoliByFunction(businessFunction, 0); - // Carica i Ruoli di input e output - List listaRuoliInOut = workflowService.findRuoliByFunction(businessFunction, 1); - List listaParametri = workflowService.findParametriByFunction(businessFunction); - List listaBp = elaborazione.get().getSxBusinessFunction().getSxBusinessProcesses(); - - model.addAttribute("bProcess", listaBp); - model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); - model.addAttribute("stepVList", listaSV); - - model.addAttribute("stepParamList", listaSP); - - model.addAttribute("listaRuoliInput", listaRuoliInput); - model.addAttribute("listaRuoliInOut", listaRuoliInOut); - model.addAttribute("listaParametri", listaParametri); - model.addAttribute("listaFunzioni", listaFunzioni); - model.addAttribute("datasetfiles", datasetfiles); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute("businessFunction", businessFunction); - - return "elaborazione/new_ws"; - - } - - @GetMapping(value = "/dataview/{idelab}/{tipoCampo}") - public String viewDataProc(HttpSession session, Model model, @PathVariable("idelab") Long idelaborazione, - @PathVariable("tipoCampo") Integer tipoCampo) { - notificationService.removeAllMessages(); - - SXTipoCampo sxTipoCampo = workflowService.getTipoCampoById(tipoCampo); - List listaSV = workflowService.getSxStepVariablesTipoCampoNoValori(idelaborazione, - new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE), sxTipoCampo); - Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); - List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); - - model.addAttribute("stepVList", listaSV); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute("tipoCampo", sxTipoCampo); - model.addAttribute("bProcess", listaBp); - model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); - - return "elaborazione/view_data"; - - } - - @GetMapping(value = "/chiudiElab/{id}") - public String chiudiWS(HttpSession session, Model model, @PathVariable("id") Long id) { - notificationService.removeAllMessages(); - - Elaborazione elaborazione = workflowService.findElaborazione(id).get(); - session.removeAttribute(IS2Const.SESSION_ELABORAZIONE); - - return "redirect:/sessione/apri/" + elaborazione.getSessioneLavoro().getId(); - } - - @GetMapping(value = "/elimina/{idelaborazione}/{idsessione}") - public String eliminaWS(HttpSession session, Model model, @AuthenticationPrincipal User user, - @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idsessione") Long idsessione) { - notificationService.removeAllMessages(); - notificationService.addInfoMessage("L'elaborazione è stata rimossa."); - workflowService.eliminaElaborazione(idelaborazione); - List listasessioni = sessioneLavoroService.getSessioneList(user); - model.addAttribute("listasessioni", listasessioni); - - return "redirect:/sessione/apri/" + idsessione; - } - - @GetMapping(value = "/dobproc/{idelaborazione}/{idBProc}") - public String dobproc(Model model, @PathVariable("idelaborazione") Long idelaborazione, - @PathVariable("idBProc") Long idBProc) throws REngineException { - notificationService.removeAllMessages(); - - Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); - try { - elaborazione = workflowService.doBusinessProc(elaborazione, idBProc); - notificationService.addInfoMessage(messages.getMessage("run.ok", null, LocaleContextHolder.getLocale())); - } catch (Exception e) { - notificationService.addErrorMessage("Error: " + e.getMessage()); - } - - SXTipoCampo sxTipoCampo =workflowService.getTipoCampoById(IS2Const.TIPO_CAMPO_ELABORATO); - - List listaSV = workflowService.getSxStepVariablesTipoCampoNoValori(idelaborazione, - new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE), new SXTipoCampo(IS2Const.TIPO_CAMPO_ELABORATO)); - List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); - - SxBusinessProcess bProcess = Utility.getSxBusinessProcess(listaBp, idBProc); - model.addAttribute("stepVList", listaSV); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute("bProcess", bProcess); - model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); - model.addAttribute("elaborazione", elaborazione); - model.addAttribute("tipoCampo",sxTipoCampo); - - return "elaborazione/view_data"; - } - - @RequestMapping(value = "/associavariabile", method = RequestMethod.POST) - public String associavariabileWS(HttpSession session, Model model, - @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { - Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); - workflowService.creaAssociazioni(form, elaborazione); - model.addAttribute("elaborazione", elaborazione); - notificationService.addInfoMessage("L'associazione è stata aggiunta"); - - return "redirect:/ws/editworkingset/" + elaborazione.getId(); - } - - @RequestMapping(value = "/associavariabileSum/{idvar}/{idvarsum}", method = RequestMethod.POST) - public String associavariabileSum(HttpSession session, Model model, @RequestParam("idvar") Long idVar, - @RequestParam("idvarsum") Long idVarSum, - @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { - Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); - workflowService.creaAssociazioni(form, elaborazione); - model.addAttribute("elaborazione", elaborazione); - notificationService.addInfoMessage("L'associazione è stata aggiunta"); - - return "redirect:/ws/editworkingset/" + idVar + "/" + idVarSum; - } - - @RequestMapping(value = "/updateassociavariabile", method = RequestMethod.POST) - public String updateAssociavariabileWS(HttpSession session, Model model, - @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { - Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); - workflowService.updateAssociazione(form, elaborazione); - model.addAttribute("elaborazione", elaborazione); - notificationService.addInfoMessage("L'associazione è stata modificata"); - - return "redirect:/ws/editworkingset/" + elaborazione.getId(); - } - - @RequestMapping(value = "/assegnaparametri", method = RequestMethod.POST) - public String assegnaparametriWS(HttpSession session, Model model, - @RequestParam("idelaborazione") Long idelaborazione, @RequestParam("parametri") String parametri, - @RequestParam("valoreParam") String valoreParam) { - - AssociazioneVarFormBean form2 = new AssociazioneVarFormBean(); - String[] idelaborazioneList = { idelaborazione + "" }; - form2.setElaborazione(idelaborazioneList); - String[] params = { parametri }; - form2.setParametri(params); - String[] valori = { valoreParam }; - form2.setValore(valori); - Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); - workflowService.associaParametri(form2, elaborazione); - notificationService.addInfoMessage("Parametro inserito correttamente"); - - model.addAttribute("elaborazione", elaborazione); - - return "redirect:/ws/editworkingset/" + elaborazione.getId(); - } - - @RequestMapping(value = "modificaparametro", method = RequestMethod.POST) - public String modificaparametro(HttpSession session, Model model, - @RequestParam("idelaborazione") Long idelaborazione, @RequestParam("parametri") String parametri, - @RequestParam("valoreParam") String valoreParam, @RequestParam("idStepvarMod") String idStepvarMod) { - - AssociazioneVarFormBean form2 = new AssociazioneVarFormBean(); - String[] idelaborazioneList = { idelaborazione + "" }; - form2.setElaborazione(idelaborazioneList); - String[] params = { parametri }; - form2.setParametri(params); - form2.setIdStepVar(idStepvarMod); - String[] valori = { valoreParam }; - form2.setValore(valori); - - Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); - - workflowService.updateParametri(form2, elaborazione); - notificationService.addInfoMessage("Parametro modificato"); - - model.addAttribute("elaborazione", elaborazione); - - return "redirect:/ws/editworkingset/" + elaborazione.getId(); - } + @Autowired + private WorkflowService workflowService; + @Autowired + private NotificationService notificationService; + @Autowired + private MessageSource messages; + @Autowired + private SessioneLavoroService sessioneLavoroService; + @Autowired + private ElaborazioneService elaborazioneService; + @Autowired + private BusinessFunctionService businessFunctionService; + @Autowired + private DatasetService datasetService; + @Autowired + private StepVariableService stepVariableService; + + @GetMapping(value = "/home/{id}") + public String homeWS(HttpSession session, Model model, @PathVariable("id") Long id) { + notificationService.removeAllMessages(); + + Elaborazione elaborazione = workflowService.findElaborazione(id).get(); + List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); + SxBusinessProcess bProcess = listaBp.get(0); + List listaSV = workflowService.getSxStepVariablesNoValori(elaborazione.getId(), + new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); + model.addAttribute("stepVList", listaSV); + + SessionBean elaSession = new SessionBean(elaborazione.getId().toString(), elaborazione.getNome()); + session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); + + model.addAttribute("bProcess", bProcess); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); + + return "elaborazione/homeelaborazione"; + } + + @GetMapping(value = "/eliminaAssociazione/{idelaborazione}/{idvar}") + public String eliminaAssociazioneVar(HttpSession session, Model model, + @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idvar") Long idvar) { + notificationService.removeAllMessages(); + + SxStepVariable stepVar = stepVariableService.findById(idvar).get(); + List listaVars = stepVar.getSxWorkset().getSxStepVariables(); + + if (listaVars.size() == 1) { + SxWorkset workset = (SxWorkset) listaVars.get(0).getSxWorkset(); + workflowService.deleteWorkset(workset); + } else { + // do nothing + } + + stepVariableService.removeStepVarById(idvar); + notificationService.addInfoMessage("La variabile è stata rimossa"); + + return "redirect:/ws/editworkingset/" + idelaborazione; + } + + @GetMapping(value = "/eliminaParametro/{idelaborazione}/{idparametro}") + public String eliminaParametro(HttpSession session, Model model, + @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idparametro") Long idparametro) { + notificationService.removeAllMessages(); + + SxStepVariable stepVar = stepVariableService.findById(idparametro).get(); + List listaVars = stepVar.getSxWorkset().getSxStepVariables(); + + if (listaVars.size() == 1) { + SxWorkset workset = (SxWorkset) listaVars.get(0).getSxWorkset(); + workflowService.deleteWorkset(workset); + } else { + // do nothing + } + + stepVariableService.removeStepVarById(idparametro); + notificationService.addInfoMessage("Il parametro è stato eliminato"); + + return "redirect:/ws/editworkingset/" + idelaborazione; + } + + @GetMapping(value = "/newworkingset/{idelaborazione}") + public String createWorkingSet(HttpSession session, Model model, + @PathVariable("idelaborazione") Long idElaborazione) { + session.setAttribute(IS2Const.WORKINGSET, "workingset"); + + Elaborazione elaborazione = elaborazioneService.findElaborazione(idElaborazione); + + SessionBean elaSession = new SessionBean(elaborazione.getId().toString(), elaborazione.getNome()); + session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); + + List datasetfiles = datasetService + .findDatasetFilesByIdSessioneLavoro(elaborazione.getSessioneLavoro().getId()); + DatasetFile datasetfile = datasetfiles.get(0); + model.addAttribute("idfile", datasetfile.getId()); + + List colonne = datasetService.findAllNomeColonne(datasetfile); + List listaSV = workflowService.getSxStepVariablesNoValori(idElaborazione, + new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); + List listaSP = workflowService.getSxStepVariablesParametri(idElaborazione); + List listaFunzioni = businessFunctionService.findBFunctions(); + + SxBusinessFunction businessFunction = elaborazione.getSxBusinessFunction(); + + // Carica i Ruoli di input + List listaRuoliInput = workflowService.findRuoliByFunction(businessFunction, 0); + // Carica i Ruoli di input e output + List listaRuoliInOut = workflowService.findRuoliByFunction(businessFunction, 1); + List listaParametri = workflowService.findParametriByFunction(businessFunction); + List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); + + model.addAttribute("bProcess", listaBp); + model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); + model.addAttribute("stepVList", listaSV); + + ArrayList listaNomiSV = new ArrayList(); + for (int i = 0; i < listaSV.size(); i++) { + String nomeStepVariable = listaSV.get(i).getSxWorkset().getNome(); + listaNomiSV.add(nomeStepVariable); + for (int y = 0; y < colonne.size(); y++) { + String nomeCol = colonne.get(y).getNome(); + if (listaNomiSV.contains(nomeCol)) { + colonne.remove(colonne.get(y)); + } + } + } + + model.addAttribute("stepParamList", listaSP); + model.addAttribute("colonne", colonne); + model.addAttribute("listaRuoliInput", listaRuoliInput); + model.addAttribute("listaRuoliInOut", listaRuoliInOut); + model.addAttribute("listaParametri", listaParametri); + model.addAttribute("listaFunzioni", listaFunzioni); + model.addAttribute("datasetfile", datasetfile); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute("businessFunction", businessFunction); + + return "elaborazione/edit_ws"; + + } + + @GetMapping(value = "/editworkingset/{idelaborazione}") + public String editWorkingSet(HttpSession session, Model model, + @PathVariable("idelaborazione") Long idElaborazione) { + + session.setAttribute(IS2Const.WORKINGSET, "workingset"); + + Elaborazione elaborazione = elaborazioneService.findElaborazione(idElaborazione); + + SessionBean elaSession = new SessionBean(elaborazione.getId().toString(), elaborazione.getNome()); + session.setAttribute(IS2Const.SESSION_ELABORAZIONE, elaSession); + + List datasetfiles = datasetService + .findDatasetFilesByIdSessioneLavoro(elaborazione.getSessioneLavoro().getId()); + + datasetfiles.forEach(datasetfile -> { + // retrieve DatasetColonna without data + List colonne = datasetService.findAllNomeColonne(datasetfile); + datasetfile.setColonne(colonne); + + }); + + List listaSV = workflowService.getSxStepVariablesNoValori(idElaborazione, + new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE)); + List listaSP = workflowService.getSxStepVariablesParametri(idElaborazione); + List listaFunzioni = businessFunctionService.findBFunctions(); + + SxBusinessFunction businessFunction = elaborazione.getSxBusinessFunction(); + + // Carica i Ruoli di input + List listaRuoliInput = workflowService.findRuoliByFunction(businessFunction, 0); + // Carica i Ruoli di input e output + List listaRuoliInOut = workflowService.findRuoliByFunction(businessFunction, 1); + List listaParametri = workflowService.findParametriByFunction(businessFunction); + List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); + + model.addAttribute("bProcess", listaBp); + model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); + model.addAttribute("stepVList", listaSV); + + model.addAttribute("stepParamList", listaSP); + + model.addAttribute("listaRuoliInput", listaRuoliInput); + model.addAttribute("listaRuoliInOut", listaRuoliInOut); + model.addAttribute("listaParametri", listaParametri); + model.addAttribute("listaFunzioni", listaFunzioni); + model.addAttribute("datasetfiles", datasetfiles); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute("businessFunction", businessFunction); + + return "elaborazione/new_ws"; + + } + + @GetMapping(value = "/dataview/{idelab}/{tipoCampo}") + public String viewDataProc(HttpSession session, Model model, @PathVariable("idelab") Long idelaborazione, + @PathVariable("tipoCampo") Integer tipoCampo) { + notificationService.removeAllMessages(); + + SXTipoCampo sxTipoCampo = workflowService.getTipoCampoById(tipoCampo); + List listaSV = workflowService.getSxStepVariablesTipoCampoNoValori(idelaborazione, + new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE), sxTipoCampo); + Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); + List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); + + model.addAttribute("stepVList", listaSV); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute("tipoCampo", sxTipoCampo); + model.addAttribute("bProcess", listaBp); + model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); + + return "elaborazione/view_data"; + + } + + @GetMapping(value = "/chiudiElab/{id}") + public String chiudiWS(HttpSession session, Model model, @PathVariable("id") Long id) { + notificationService.removeAllMessages(); + + Elaborazione elaborazione = workflowService.findElaborazione(id).get(); + session.removeAttribute(IS2Const.SESSION_ELABORAZIONE); + + return "redirect:/sessione/apri/" + elaborazione.getSessioneLavoro().getId(); + } + + @GetMapping(value = "/elimina/{idelaborazione}/{idsessione}") + public String eliminaWS(HttpSession session, Model model, @AuthenticationPrincipal User user, + @PathVariable("idelaborazione") Long idelaborazione, @PathVariable("idsessione") Long idsessione) { + notificationService.removeAllMessages(); + notificationService.addInfoMessage("L'elaborazione è stata rimossa."); + workflowService.eliminaElaborazione(idelaborazione); + List listasessioni = sessioneLavoroService.getSessioneList(user); + model.addAttribute("listasessioni", listasessioni); + + return "redirect:/sessione/apri/" + idsessione; + } + + @GetMapping(value = "/dobproc/{idelaborazione}/{idBProc}") + public String dobproc(Model model, @PathVariable("idelaborazione") Long idelaborazione, + @PathVariable("idBProc") Long idBProc) throws REngineException { + notificationService.removeAllMessages(); + + Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); + try { + elaborazione = workflowService.doBusinessProc(elaborazione, idBProc); + notificationService.addInfoMessage(messages.getMessage("run.ok", null, LocaleContextHolder.getLocale())); + } catch (Exception e) { + notificationService.addErrorMessage("Error: " + e.getMessage()); + } + + SXTipoCampo sxTipoCampo = workflowService.getTipoCampoById(IS2Const.TIPO_CAMPO_ELABORATO); + + List listaSV = workflowService.getSxStepVariablesTipoCampoNoValori(idelaborazione, + new SxTipoVar(IS2Const.WORKSET_TIPO_VARIABILE), new SXTipoCampo(IS2Const.TIPO_CAMPO_ELABORATO)); + List listaBp = elaborazione.getSxBusinessFunction().getSxBusinessProcesses(); + + SxBusinessProcess bProcess = Utility.getSxBusinessProcess(listaBp, idBProc); + model.addAttribute("stepVList", listaSV); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute("bProcess", bProcess); + model.addAttribute(IS2Const.LISTA_BUSINESS_PROCESS, listaBp); + model.addAttribute("elaborazione", elaborazione); + model.addAttribute("tipoCampo", sxTipoCampo); + + return "elaborazione/view_data"; + } + + @RequestMapping(value = "/associavariabile", method = RequestMethod.POST) + public String associavariabileWS(HttpSession session, Model model, + @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { + Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); + workflowService.creaAssociazioni(form, elaborazione); + model.addAttribute("elaborazione", elaborazione); + notificationService.addInfoMessage("L'associazione è stata aggiunta"); + + return "redirect:/ws/editworkingset/" + elaborazione.getId(); + } + + @RequestMapping(value = "/associavariabileSum/{idvar}/{idvarsum}", method = RequestMethod.POST) + public String associavariabileSum(HttpSession session, Model model, @RequestParam("idvar") Long idVar, + @RequestParam("idvarsum") Long idVarSum, + @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { + Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); + workflowService.creaAssociazioni(form, elaborazione); + model.addAttribute("elaborazione", elaborazione); + notificationService.addInfoMessage("L'associazione è stata aggiunta"); + + return "redirect:/ws/editworkingset/" + idVar + "/" + idVarSum; + } + + @RequestMapping(value = "/updateassociavariabile", method = RequestMethod.POST) + public String updateAssociavariabileWS(HttpSession session, Model model, + @ModelAttribute("associazioneVarFormBean") AssociazioneVarFormBean form) { + Elaborazione elaborazione = workflowService.findElaborazione(Long.parseLong(form.getElaborazione()[0])).get(); + workflowService.updateAssociazione(form, elaborazione); + model.addAttribute("elaborazione", elaborazione); + notificationService.addInfoMessage("L'associazione è stata modificata"); + + return "redirect:/ws/editworkingset/" + elaborazione.getId(); + } + + @RequestMapping(value = "/assegnaparametri", method = RequestMethod.POST) + public String assegnaparametriWS(HttpSession session, Model model, + @RequestParam("idelaborazione") Long idelaborazione, @RequestParam("parametri") String parametri, + @RequestParam("valoreParam") String valoreParam) { + + AssociazioneVarFormBean form2 = new AssociazioneVarFormBean(); + String[] idelaborazioneList = {idelaborazione + ""}; + form2.setElaborazione(idelaborazioneList); + String[] params = {parametri}; + form2.setParametri(params); + String[] valori = {valoreParam}; + form2.setValore(valori); + Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); + workflowService.associaParametri(form2, elaborazione); + notificationService.addInfoMessage("Parametro inserito correttamente"); + + model.addAttribute("elaborazione", elaborazione); + + return "redirect:/ws/editworkingset/" + elaborazione.getId(); + } + + @RequestMapping(value = "modificaparametro", method = RequestMethod.POST) + public String modificaparametro(HttpSession session, Model model, + @RequestParam("idelaborazione") Long idelaborazione, @RequestParam("parametri") String parametri, + @RequestParam("valoreParam") String valoreParam, @RequestParam("idStepvarMod") String idStepvarMod) { + + AssociazioneVarFormBean form2 = new AssociazioneVarFormBean(); + String[] idelaborazioneList = {idelaborazione + ""}; + form2.setElaborazione(idelaborazioneList); + String[] params = {parametri}; + form2.setParametri(params); + form2.setIdStepVar(idStepvarMod); + String[] valori = {valoreParam}; + form2.setValore(valori); + + Elaborazione elaborazione = workflowService.findElaborazione(idelaborazione).get(); + + workflowService.updateParametri(form2, elaborazione); + notificationService.addInfoMessage("Parametro modificato"); + + model.addAttribute("elaborazione", elaborazione); + + return "redirect:/ws/editworkingset/" + elaborazione.getId(); + } } diff --git a/src/main/resources/public/css/box.css b/src/main/resources/public/css/box.css index 29732c7f..6d565851 100644 --- a/src/main/resources/public/css/box.css +++ b/src/main/resources/public/css/box.css @@ -23,7 +23,7 @@ */ body { min-height: 100%; - font-family: -apple-system,BlinkMacSystemFont,segoe ui,Roboto,helvetica neue,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol,noto color emoji; + font-family: segoe ui,Roboto,helvetica neue,Arial,sans-serif; color: #333; background-color: transparent !important; /*#f5f7fa;*/ } @@ -419,30 +419,6 @@ section, footer { .shadow-effect { box-shadow: 0 6px 6px -6px #777; } - -/* home page - -.brand { - font-size: 2em; -} - -.brand { - font-family: 'Arial', cursive; -} - -.brand-sub { - font-size: 1.2em; -} - -.div{ - display: table; - content: " "; -} - -.div li { - display: list-item; -} -*/ .stacks { margin: 0 auto; list-style: none; @@ -525,7 +501,7 @@ section, footer { } .well-legend { - font-size: 17px; + font-size: 16px; font-weight: bold; } @@ -604,6 +580,14 @@ fieldset { padding: 6px !important; } +.table-striped > tbody > tr:nth-of-type(odd) { + background-color: white; +} + +.table-striped > tbody > tr:nth-of-type(even) { + background-color: #f9f9f9; +} + .my-row { margin-top: 5px !important; } @@ -744,13 +728,12 @@ fieldset { } .well-app { + font-size: 16px; margin-top: 23px !important; - background-color: #f5f5f5 !important; + background-color: #fafbfc !important; color: #2189b4 !important; - padding-top: 5px !important; - padding-bottom: 25px !important; - font-weight: bold !important; - min-height: 180px !important; + padding: 15px; + border:1px solid #ededed; } .well-note { @@ -795,6 +778,12 @@ fieldset { text-decoration: none; } +.breadcrumb-item a{ + color: #155873!important; + margin-right: 0px; + margin-left: 0px; +} + .navbar-default { border-color: #1c7498; border-bottom: 1px solid #1c7498 !important; @@ -812,6 +801,10 @@ fieldset { margin-bottom: 0px !important; } +table.dataTable{ + font-size: 12px; +} + table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>td:first-child, table.dataTable.dtr-inline.collapsed>tbody>tr[role="row"]>th:first-child { diff --git a/src/main/resources/templates/dataset/datasetpreview.html b/src/main/resources/templates/dataset/datasetpreview.html index 70e0e69d..6932bde6 100644 --- a/src/main/resources/templates/dataset/datasetpreview.html +++ b/src/main/resources/templates/dataset/datasetpreview.html @@ -26,13 +26,13 @@ - + - + @@ -62,43 +62,45 @@ - + - - - - +
- - - - - + + + - +   - +   - -
- +
@@ -167,64 +169,64 @@ - - - + + + +
+
+ Variabile: + +
+
+ + + Rimuovi spazi +
+
+ + Rimuovi caratteri speciali (.,:;\/'") +
+
+ + Rimuovi carattere o stringa: + +
-
- Variabile: - + UPPER/lower case +
+
+ + Maiuscolo + + + Minuscolo +
- +
+
+ + -
-
- - - Rimuovi spazi -
-
- - Rimuovi caratteri speciali (.,:;\/'") -
-
- - Rimuovi carattere o stringa: - -
-
- - UPPER/lower case -
-
- - Maiuscolo - - - Minuscolo -
- -
-
- - - -
- - - + + +
- +
@@ -237,50 +239,50 @@ - - - + + + +
+
+ Variabile: + + +
+
+ Separatore: + + +
+
-
- Variabile: - - +
+
+
+ + - -
-
- Separatore: - - -
- -
-
- Lista dei campi da concatenare: - - -
-
-
- - - -
- - - + + + - + @@ -293,70 +295,70 @@ - - - + + + +
+
+ Variabile: + + +
+
+
+
+ + Separatore: + +
+ +
+ + Lunghezza: + +
+
+ +
+
+
+ + Inizio + + + Fine +
+ +
+
-
- Variabile: - - +
+
+ + - -
-
-
-
- - Separatore: - -
- -
- - Lunghezza: - -
-
- -
-
-
- - Inizio - - - Fine -
- -
- -
-
- - - -
-
- - - -
- - - + + + - + @@ -369,55 +371,46 @@ - - - + + +
-
- Variabile: - - + + + - -
-
-
-
- File csv: - -
- Separatore: - -
-
-
-
- - - -
- - - - -
- - - - - +
+
+
+ File csv: + +
+ Separatore: + +
+
+
+
+ + + +
+ +
- diff --git a/src/main/resources/templates/sessionilavoro/homesessione.html b/src/main/resources/templates/sessionilavoro/homesessione.html index 66027108..0d8da48c 100644 --- a/src/main/resources/templates/sessionilavoro/homesessione.html +++ b/src/main/resources/templates/sessionilavoro/homesessione.html @@ -1,260 +1,262 @@ - - - - - - - - - - - -
-
- - -
-
- - - - -
-
-
-
- - Dettaglio sessione di lavoro - -
    -
  • - - Nome: - nome - -
  • -
  • - - Descrizione: - Descrizione - -
  • -
  • - - Data creazione: - data creazione - -
  • -
-
-
-
- -
-
-
- - Lista elaborazioni - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
codicenomeFunzionedescrizionedata creazione
- - - - - - - -
-
-
-
- -
-
-
- -
-
- - - - - - - - - + + + + + + + + + + + +
+
+ + +
+
+ + + + +
+
+
+
+ + Dettaglio sessione di lavoro + +
    +
  • + + Nome: + nome + +
  • +
  • + + Descrizione: + Descrizione + +
  • +
  • + + Data creazione: + data creazione + +
  • +
+
+
+
+ +
+
+
+ + Lista elaborazioni + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
codicenomeFunzionedescrizionedata creazione
+ + + + + + + +
+
+
+
+ +
+
+
+ +
+
+ + + + + + + + + diff --git a/src/main/resources/templates/sessionilavoro/listadataset.html b/src/main/resources/templates/sessionilavoro/listadataset.html index c13ea31f..3e9faf35 100644 --- a/src/main/resources/templates/sessionilavoro/listadataset.html +++ b/src/main/resources/templates/sessionilavoro/listadataset.html @@ -45,14 +45,16 @@