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@151220 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-24 09:59:00 +00:00
parent 19fef1b9c5
commit 7ce0d5ec45
4 changed files with 36 additions and 17 deletions

View File

@ -313,6 +313,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
logger.debug("SetMainCode(): " + itemDescription); logger.debug("SetMainCode(): " + itemDescription);
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials); Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
if (project != null) { if (project != null) {
FilesStorage filesStorage = new FilesStorage();
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
itemDescription.setPublicLink(link);
project.setMainCode(new MainCode(itemDescription)); project.setMainCode(new MainCode(itemDescription));
project.setInputData(null); project.setInputData(null);
project.setProjectTarget(null); project.setProjectTarget(null);
@ -348,6 +351,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) { if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBlackBox) {
ProjectSupportBlackBox projectSupportBlackBox = (ProjectSupportBlackBox) project ProjectSupportBlackBox projectSupportBlackBox = (ProjectSupportBlackBox) project
.getProjectConfig().getProjectSupport(); .getProjectConfig().getProjectSupport();
FilesStorage filesStorage = new FilesStorage();
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
itemDescription.setPublicLink(link);
projectSupportBlackBox.setBinaryItem(itemDescription); projectSupportBlackBox.setBinaryItem(itemDescription);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
logger.debug("Project: " + project); logger.debug("Project: " + project);
@ -355,6 +361,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) { if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit) {
ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project ProjectSupportBashEdit projectSupportBashEdit = (ProjectSupportBashEdit) project
.getProjectConfig().getProjectSupport(); .getProjectConfig().getProjectSupport();
FilesStorage filesStorage = new FilesStorage();
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
itemDescription.setPublicLink(link);
projectSupportBashEdit.setBinaryItem(itemDescription); projectSupportBashEdit.setBinaryItem(itemDescription);
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project); SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
logger.debug("Project: " + project); logger.debug("Project: " + project);

View File

@ -64,9 +64,12 @@ public class GeneralPurposeScriptProducer {
String URLtoSoftware) throws Exception { String URLtoSoftware) throws Exception {
String mainSoftwareName = mainSoftware; String mainSoftwareName = mainSoftware;
if (URLtoSoftware!=null) { //if (URLtoSoftware!=null) {
mainSoftwareName = URLReader(URLtoSoftware); // logger.debug("Reading main software from remote URL: "+URLtoSoftware);
} // mainSoftwareName = URLReader(URLtoSoftware);
// logger.debug("Main software name: "+mainSoftwareName);
//
//}
String inputDeclaration = generateInputStrings(input, softwareType, mainSoftwareName); String inputDeclaration = generateInputStrings(input, softwareType, mainSoftwareName);
String processInvocation = generateExternalProcessInvokation(mainSoftwareName, input); String processInvocation = generateExternalProcessInvokation(mainSoftwareName, input);

View File

@ -34,7 +34,6 @@ public class MainGenerator {
private static final String R_MIMETYPE = "text/plain"; private static final String R_MIMETYPE = "text/plain";
private static final String R_DESCRIPTION = "R script for "; private static final String R_DESCRIPTION = "R script for ";
public void createMain(ServiceCredentials serviceCredentials, Project project, String remoteTemplateFile) public void createMain(ServiceCredentials serviceCredentials, Project project, String remoteTemplateFile)
throws StatAlgoImporterServiceException { throws StatAlgoImporterServiceException {
@ -77,13 +76,20 @@ public class MainGenerator {
Path producedScript = null; Path producedScript = null;
if (project.getProjectConfig().getProjectSupport() instanceof ProjectSupportBashEdit){ // if (project.getProjectConfig().getProjectSupport() instanceof
producedScript = s.generateScript(input, output, binarySoftware.getName(), // ProjectSupportBashEdit){
project.getProjectConfig().getLanguage(), binarySoftware.getPublicLink()); // logger.debug("Generate Script R with public link:
} else { // "+binarySoftware.getPublicLink());
// producedScript = s.generateScript(input, output,
// binarySoftware.getName(),
// project.getProjectConfig().getLanguage(),
// binarySoftware.getPublicLink());
// } else {
logger.debug("Generate Script R");
producedScript = s.generateScript(input, output, binarySoftware.getName(), producedScript = s.generateScript(input, output, binarySoftware.getName(),
project.getProjectConfig().getLanguage()); project.getProjectConfig().getLanguage());
} // }
if (producedScript == null || !Files.exists(producedScript)) { if (producedScript == null || !Files.exists(producedScript)) {
String error = "Error creating script: file not exists!"; String error = "Error creating script: file not exists!";

View File

@ -60,10 +60,10 @@ public class CodeSave {
private ItemDescription saveInWorkspace(Path tempFile, ServiceCredentials serviceCredentials, ItemDescription file, private ItemDescription saveInWorkspace(Path tempFile, ServiceCredentials serviceCredentials, ItemDescription file,
String folderId) throws StatAlgoImporterServiceException { String folderId) throws StatAlgoImporterServiceException {
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();
WorkspaceItem mainCodeItem; WorkspaceItem worksapceItem;
try { try {
mainCodeItem = filesStorage.createItemOnWorkspace(serviceCredentials.getUserName(), worksapceItem = filesStorage.createItemOnWorkspace(serviceCredentials.getUserName(),
Files.newInputStream(tempFile, StandardOpenOption.READ), file.getName(), ALGORITHM_DESCRIPTION, Files.newInputStream(tempFile, StandardOpenOption.READ), file.getName(), ALGORITHM_DESCRIPTION,
ALGORITHM_MIMETYPE, folderId); ALGORITHM_MIMETYPE, folderId);
} catch (IOException e) { } catch (IOException e) {
@ -71,17 +71,18 @@ public class CodeSave {
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e); throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
} }
ItemDescription mainCode; ItemDescription item;
try { try {
mainCode = new ItemDescription(mainCodeItem.getId(), mainCodeItem.getName(), item = new ItemDescription(worksapceItem.getId(), worksapceItem.getName(),
mainCodeItem.getOwner().getPortalLogin(), mainCodeItem.getPath(), mainCodeItem.getType().name()); worksapceItem.getOwner().getPortalLogin(), worksapceItem.getPath(), worksapceItem.getType().name());
item.setPublicLink(worksapceItem.getPublicLink(false));
} catch (InternalErrorException e) { } catch (InternalErrorException e) {
logger.error(e.getLocalizedMessage(),e); logger.error(e.getLocalizedMessage(),e);
throw new StatAlgoImporterServiceException(e.getLocalizedMessage()); throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
} }
return mainCode; return item;
} }