Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
MecBoc committed Dec 6, 2019
1 parent 4e00a69 commit fea7e65
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RScripts/selemix/IS2_selemix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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("----")
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/it/istat/is2/app/service/AdministrationService.java
Original file line number Diff line number Diff line change
@@ -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));

}
}
36 changes: 35 additions & 1 deletion src/main/java/it/istat/is2/workflow/engine/EngineR.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/main/resources/templates/admin/home.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit fea7e65

Please sign in to comment.