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