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

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

Updated the support for Processes as Black Boxes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@150616 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-06-28 15:49:13 +00:00
parent ecbf7a137d
commit d9c84066ae
2 changed files with 65 additions and 41 deletions

View File

@ -8,6 +8,7 @@ import java.nio.file.StandardOpenOption;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InterpreterPackageInfo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
@ -23,14 +24,15 @@ import org.slf4j.LoggerFactory;
public class InfoGenerator { public class InfoGenerator {
private static final String INFO_NAME = "Info"; private static final String INFO_NAME = "Info";
private static final String INFO_EXTENTION = ".txt"; private static final String INFO_EXTENTION = ".txt";
public static final Logger logger = LoggerFactory public static final Logger logger = LoggerFactory.getLogger(InfoGenerator.class);
.getLogger(InfoGenerator.class);
private Project project; private Project project;
private ServiceCredentials serviceCredentials;
public InfoGenerator(Project project) { public InfoGenerator(Project project, ServiceCredentials serviceCredentials) {
super(); super();
this.project = project; this.project = project;
this.serviceCredentials = serviceCredentials;
} }
@Override @Override
@ -44,84 +46,106 @@ public class InfoGenerator {
Path tempFile = Files.createTempFile(INFO_NAME, INFO_EXTENTION); Path tempFile = Files.createTempFile(INFO_NAME, INFO_EXTENTION);
List<String> lines = createInfoData(); List<String> lines = createInfoData();
Files.write(tempFile, lines, Charset.defaultCharset(), Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.WRITE);
StandardOpenOption.WRITE);
logger.debug(tempFile.toString()); logger.debug(tempFile.toString());
return tempFile; return tempFile;
} catch (IOException e) { } catch (IOException e) {
logger.error(e.getLocalizedMessage()); logger.error(e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
e);
} }
} }
private List<String> createInfoData() { private List<String> createInfoData() {
ArrayList<String> infos = new ArrayList<String>(); ArrayList<String> infos = new ArrayList<String>();
if (serviceCredentials != null) {
if (serviceCredentials.getUserName() != null && !serviceCredentials.getUserName().isEmpty()) {
infos.add("UserName: " + serviceCredentials.getUserName());
} else {
infos.add("UserName: ");
}
if (serviceCredentials.getFullName() != null) {
infos.add("FullName: " + serviceCredentials.getFullName());
} else {
infos.add("FullName: ");
}
if (serviceCredentials.getEmail() != null) {
infos.add("Email: " + serviceCredentials.getEmail());
} else {
infos.add("Email: ");
}
} else {
infos.add("Username: ");
infos.add("FullName: ");
infos.add("Email: ");
}
infos.add("");
if (project.getProjectConfig()!=null) {
if(project.getProjectConfig().getLanguage()!=null){
infos.add("Language: " + project.getProjectConfig().getLanguage());
} else {
infos.add("Language: ");
}
} else {
infos.add("Language: ");
}
if (project.getInputData() != null) { if (project.getInputData() != null) {
if (project.getInputData().getProjectInfo() != null) { if (project.getInputData().getProjectInfo() != null) {
if (project.getInputData().getProjectInfo().getAlgorithmName() != null) { if (project.getInputData().getProjectInfo().getAlgorithmName() != null) {
infos.add("Algorithm Name: " infos.add("Algorithm Name: " + project.getInputData().getProjectInfo().getAlgorithmNameToUpper());
+ project.getInputData().getProjectInfo() infos.add("Class Name: org.gcube.dataanalysis.executor.rscripts."
.getAlgorithmNameToUpper()); + project.getInputData().getProjectInfo().getAlgorithmNameToClassName());
infos.add("Class Name: org.gcube.dataanalysis.executor.rscripts."+ project.getInputData().getProjectInfo()
.getAlgorithmNameToClassName());
} else { } else {
infos.add("Algorithm Name: "); infos.add("Algorithm Name: ");
infos.add("Class Name: "); infos.add("Class Name: ");
} }
if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) { if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) {
infos.add("Algorithm Description: " infos.add("Algorithm Description: "
+ project.getInputData().getProjectInfo() + project.getInputData().getProjectInfo().getAlgorithmDescription());
.getAlgorithmDescription());
} else { } else {
infos.add("Algorithm Description: "); infos.add("Algorithm Description: ");
} }
if (project.getInputData().getProjectInfo().getAlgorithmCategory() != null) { if (project.getInputData().getProjectInfo().getAlgorithmCategory() != null) {
infos.add("Algorithm Category: " infos.add("Algorithm Category: " + project.getInputData().getProjectInfo().getAlgorithmCategory());
+ project.getInputData().getProjectInfo()
.getAlgorithmCategory());
} else { } else {
infos.add("Algorithm Category: "); infos.add("Algorithm Category: ");
} }
infos.add(""); infos.add("");
/* /*
if (project.getInputData().getProjectInfo() * if (project.getInputData().getProjectInfo()
.getListRequestedVRE() != null * .getListRequestedVRE() != null &&
&& project.getInputData().getProjectInfo() * project.getInputData().getProjectInfo()
.getListRequestedVRE().size() > 0) { * .getListRequestedVRE().size() > 0) {
infos.add("Deployable VRE:"); * infos.add("Deployable VRE:"); for (RequestedVRE deployableVRE
for (RequestedVRE deployableVRE : project.getInputData() * : project.getInputData()
.getProjectInfo().getListRequestedVRE()) { * .getProjectInfo().getListRequestedVRE()) { infos.add("" +
infos.add("" + deployableVRE.getName() + " " + deployableVRE.getDescription()); * deployableVRE.getName() + " " +
} * deployableVRE.getDescription()); } infos.add(""); }
infos.add(""); */
}*/
} }
if (project.getInputData().getInterpreterInfo() != null) { if (project.getInputData().getInterpreterInfo() != null) {
if (project.getInputData().getInterpreterInfo().getVersion() != null) { if (project.getInputData().getInterpreterInfo().getVersion() != null) {
infos.add("Interpreter Version: " infos.add("Interpreter Version: " + project.getInputData().getInterpreterInfo().getVersion());
+ project.getInputData().getInterpreterInfo()
.getVersion());
} else { } else {
infos.add("Interpreter Version: Any"); infos.add("Interpreter Version: Any");
} }
infos.add(""); infos.add("");
if (project.getInputData().getInterpreterInfo() if (project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo() != null
.getInterpreterPackagesInfo() != null && project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size() > 0) {
&& project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size() > 0) {
infos.add("Packages:"); infos.add("Packages:");
for (InterpreterPackageInfo info : project.getInputData() for (InterpreterPackageInfo info : project.getInputData().getInterpreterInfo()
.getInterpreterInfo().getInterpreterPackagesInfo()) { .getInterpreterPackagesInfo()) {
infos.add("" + info.getName() + " " + info.getVersion()); infos.add("" + info.getName() + " " + info.getVersion());
} }
} }

View File

@ -587,7 +587,7 @@ public class ProjectBuilder {
} }
private void createIntegrationInfo() throws StatAlgoImporterServiceException { private void createIntegrationInfo() throws StatAlgoImporterServiceException {
InfoGenerator integrationInfoGenerator = new InfoGenerator(project); InfoGenerator integrationInfoGenerator = new InfoGenerator(project, serviceCredentials);
infoTXT = integrationInfoGenerator.createInfo(); infoTXT = integrationInfoGenerator.createInfo();
FilesStorage filesStorage = new FilesStorage(); FilesStorage filesStorage = new FilesStorage();