diff --git a/RScripts/selemix/IS2_selemix.R b/RScripts/selemix/IS2_selemix.R index 49502b29..c1f99b8c 100644 --- a/RScripts/selemix/IS2_selemix.R +++ b/RScripts/selemix/IS2_selemix.R @@ -93,7 +93,7 @@ library("SeleMix") #stima completa is2_mlest <- function(workset,params, s=S,x=X,y=Y,z=Z, ...) { #environment check - print(class(params)) + print(params) print("----") print(x) print("----") diff --git a/src/main/java/it/istat/is2/app/service/AdministrationService.java b/src/main/java/it/istat/is2/app/service/AdministrationService.java new file mode 100644 index 00000000..8a227034 --- /dev/null +++ b/src/main/java/it/istat/is2/app/service/AdministrationService.java @@ -0,0 +1,45 @@ +/** + * 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 <framato @ istat.it> + * @author Mauro Bruno <mbruno @ istat.it> + * @author Paolo Francescangeli <pafrance @ istat.it> + * @author Renzo Iannacone <iannacone @ istat.it> + * @author Stefano Macone <macone @ istat.it> + * @version 1.0 + */ +package it.istat.is2.app.service; + +import java.io.File; +import java.io.IOException; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +public class AdministrationService { + + @Value("${path.script.R}") + private String pathR; + + @Value("${RServe.file.start}") + private String startRServe; + + public void startR() throws IOException { + Process process = Runtime.getRuntime().exec("cmd /c "+startRServe, null, new File(pathR)); + + } +} diff --git a/src/main/java/it/istat/is2/workflow/engine/EngineR.java b/src/main/java/it/istat/is2/workflow/engine/EngineR.java index cf603c1f..e9495dca 100644 --- a/src/main/java/it/istat/is2/workflow/engine/EngineR.java +++ b/src/main/java/it/istat/is2/workflow/engine/EngineR.java @@ -141,7 +141,7 @@ public void init(DataProcessing dataProcessing, StepInstance stepInstance) throw prepareEnv(); createConnection(serverRHost, serverRPort); bindInputColumns(worksetVariabili, EngineR.IS2_WORKSET); - bindInputColumns(parametriMap, EngineR.IS2_PARAMETRI); + bindInputColumnsParams(parametriMap, EngineR.IS2_PARAMETRI); bindInputColumns(ruleset, EngineR.IS2_RULESET); setRuoli(ruoliVariabileNome); @@ -218,6 +218,40 @@ public void bindInputColumns(LinkedHashMap<String, ArrayList<String>> workset, S } } + + public void bindInputColumnsParams(LinkedHashMap<String, ArrayList<String>> workset, String varR) + throws REngineException { + + if (!workset.isEmpty()) { + List<String> keys = new ArrayList<String>(workset.keySet()); + String listaCampi = ""; + String listaCampiLabel = ""; + int size = keys.size(); + String key = ""; + + for (int i = 0; i < size; i++) { + key = keys.get(i); + + String[] arrX = workset.get(key).toArray(new String[workset.get(key).size()]); + listaCampi += key + ","; + listaCampiLabel += "'" + key + "',"; + connection.assign(key, arrX); + } + listaCampi = listaCampi.substring(0, listaCampi.length() - 1); + listaCampiLabel = listaCampiLabel.substring(0, listaCampiLabel.length() - 1); + connection.eval(varR + " <- c(" + listaCampi + ")"); + + // assegnazione nome dei campi alle colonne + + String namecols = ((size > 1) ? "col" : "") + "names(" + varR + ") = c(" + listaCampiLabel + ")"; + // String exec = "colnames(" + varR + ") = c(" + listaCampi + ")"; + Logger.getRootLogger().debug("Bind input columns names " + namecols); + connection.eval(namecols); + + } + } + + private boolean isNumeric(String[] arrX) { // TODO Auto-generated method stub diff --git a/src/main/resources/templates/admin/home.html b/src/main/resources/templates/admin/home.html new file mode 100644 index 00000000..77b9101e --- /dev/null +++ b/src/main/resources/templates/admin/home.html @@ -0,0 +1,58 @@ +<!-- + 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 <framato @ istat.it> + @author Mauro Bruno <mbruno @ istat.it> + @author Paolo Francescangeli <pafrance @ istat.it> + @author Renzo Iannacone <iannacone @ istat.it> + @author Stefano Macone <macone @ istat.it> + @version 1.0 +--> +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> + <head> + <head th:include="layout :: site-head" th:remove="tag" /> + + + </head> + <body class="app header-fixed sidebar-fixed aside-menu-fixed sidebar-lg-show"> + <header th:replace="layout :: site-header"></header> + <!-- Body --> + <div class="app-body"> + <aside th:replace="layout :: site-modals"></aside> + <aside th:replace="layout :: site-aside"></aside> + <!-- Main container --> + <main class="main"> + <!-- Breadcrumb--> + <ol class="breadcrumb"> + <li class="breadcrumb-item"> + <a th:href="@{/}">Home</a> + </li> + + </ol> + <div class="container-fluid"> + <div class="animated fadeIn"> + <a th:href="@{/startr}">Start R</a> + </div> + </div> + </main> + </div> + <!-- End body --> + <footer th:replace="layout :: site-footer" /> + + + </body> +</html>