ref 8819: Extend The Algorithms Importer to Manage Many Processes as Black Boxes

https://support.d4science.org/issues/8819

Updated the support Pre-Installed software

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@151169 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-20 13:21:56 +00:00
parent 4e9caaeecd
commit bd2d4e5ac0
4 changed files with 76 additions and 35 deletions

View File

@ -66,7 +66,6 @@ public class CodeViewerPanel extends ContentPanel {
private ListStore<CodeData> storeOutput;
private Grid<CodeData> gridOutput;
// private TextField fileNameField;
public CodeViewerPanel(EventBus eventBus) {
super();

View File

@ -437,7 +437,7 @@ public class HomeToolBar {
btnPublishSoftware.enable();
btnRepackageSoftware.enable();
btnHelp.enable();
break;
break;
default:
break;
}

View File

@ -202,17 +202,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
logger.debug("getCode()");
Project projectSession = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (projectSession != null) {
CodeReader codeFileReader = new CodeReader(projectSession, serviceCredentials);
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
for (CodeData codeData : codeList) {
logger.debug("" + codeData.getId() + " " + codeData.getCodeLine());
}
return codeList;
} else {
return new ArrayList<CodeData>();
}
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
CodeReader codeFileReader = new CodeReader(project, serviceCredentials);
ArrayList<CodeData> codeList = codeFileReader.getCodeList();
return codeList;
} catch (StatAlgoImporterServiceException e) {
e.printStackTrace();
throw e;
@ -654,7 +648,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
project.setInputData(inputData);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
SAIDescriptor saiDescriptor = SessionUtil.getSAIDescriptor(httpRequest, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials,saiDescriptor);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials, saiDescriptor);
project = projectBuilder.buildTarget();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);
@ -748,7 +742,7 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) {
SAIDescriptor saiDescriptor = SessionUtil.getSAIDescriptor(httpRequest, serviceCredentials);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials,saiDescriptor);
ProjectBuilder projectBuilder = new ProjectBuilder(project, serviceCredentials, saiDescriptor);
project = projectBuilder.buildRepackage();
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
ProjectArchiver.archive(project, serviceCredentials);

View File

@ -11,7 +11,10 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.File
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.MainCode;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportBashEdit;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.ProjectSupportREdit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,28 +30,78 @@ import org.slf4j.LoggerFactory;
public class CodeReader {
private Logger logger = LoggerFactory.getLogger(CodeReader.class);
private ArrayList<CodeData> code;
private Project project;
private ServiceCredentials serviceCredentials;
public CodeReader(Project projectSession,
ServiceCredentials serviceCredentials)
throws StatAlgoImporterServiceException {
try {
public CodeReader(Project project, ServiceCredentials serviceCredentials) {
this.project = project;
this.serviceCredentials = serviceCredentials;
if (projectSession == null
|| projectSession.getMainCode() == null
|| projectSession.getMainCode().getItemDescription() == null
|| projectSession.getMainCode().getItemDescription()
.getId() == null) {
throw new StatAlgoImporterServiceException(
"Project hasn't a valid main set!");
}
public ArrayList<CodeData> getCodeList() throws StatAlgoImporterServiceException {
retrieveCode();
logCode();
return code;
}
private void logCode(){
if (code != null) {
for (CodeData codeData : code) {
logger.debug("" + codeData.getId() + " " + codeData.getCodeLine());
}
} else{
logger.debug("no code!");
}
}
String itemId = projectSession.getMainCode().getItemDescription()
.getId();
private void retrieveCode() throws StatAlgoImporterServiceException {
if (project != null) {
if (project.getProjectConfig() != null && project.getProjectConfig().getProjectSupport() != null) {
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportREdit) {
MainCode mainCode = project.getMainCode();
if (mainCode == null || mainCode.getItemDescription() == null
|| mainCode.getItemDescription().getId() == null
|| mainCode.getItemDescription().getId().isEmpty()) {
throw new StatAlgoImporterServiceException("No main code set!");
} else {
String itemId = project.getMainCode().getItemDescription().getId();
readCodeFromItem(itemId);
}
} else {
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) {
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project
.getProjectConfig().getProjectSupport();
if (projectSupportBashEdit == null || projectSupportBashEdit.getBinaryItem() == null
|| projectSupportBashEdit.getBinaryItem().getId() == null
|| projectSupportBashEdit.getBinaryItem().getId().isEmpty()) {
throw new StatAlgoImporterServiceException("No binary code set!");
} else {
String itemId = projectSupportBashEdit.getBinaryItem().getId();
readCodeFromItem(itemId);
}
} else {
throw new StatAlgoImporterServiceException("Error reading code!");
}
}
} else {
throw new StatAlgoImporterServiceException("Error in project config!");
}
} else {
code = new ArrayList<>();
}
}
private void readCodeFromItem(String itemId) throws StatAlgoImporterServiceException {
try {
code = new ArrayList<CodeData>();
FilesStorage filesStorage = new FilesStorage();
InputStream is = filesStorage.retrieveItemOnWorkspace(
serviceCredentials.getUserName(), itemId);
InputStream is = filesStorage.retrieveItemOnWorkspace(serviceCredentials.getUserName(), itemId);
InputStreamReader isr = new InputStreamReader(is);
@ -63,15 +116,10 @@ public class CodeReader {
}
is.close();
logger.trace("Code size: " + code.size());
} catch (IOException e) {
e.printStackTrace();
new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
public ArrayList<CodeData> getCodeList() {
return code;
}
}