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:
parent
ecbf7a137d
commit
d9c84066ae
|
@ -8,6 +8,7 @@ import java.nio.file.StandardOpenOption;
|
|||
import java.util.ArrayList;
|
||||
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.input.InterpreterPackageInfo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
|
@ -23,14 +24,15 @@ import org.slf4j.LoggerFactory;
|
|||
public class InfoGenerator {
|
||||
private static final String INFO_NAME = "Info";
|
||||
private static final String INFO_EXTENTION = ".txt";
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(InfoGenerator.class);
|
||||
public static final Logger logger = LoggerFactory.getLogger(InfoGenerator.class);
|
||||
|
||||
private Project project;
|
||||
private ServiceCredentials serviceCredentials;
|
||||
|
||||
public InfoGenerator(Project project) {
|
||||
public InfoGenerator(Project project, ServiceCredentials serviceCredentials) {
|
||||
super();
|
||||
this.project = project;
|
||||
this.serviceCredentials = serviceCredentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,84 +46,106 @@ public class InfoGenerator {
|
|||
Path tempFile = Files.createTempFile(INFO_NAME, INFO_EXTENTION);
|
||||
|
||||
List<String> lines = createInfoData();
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.WRITE);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(), StandardOpenOption.WRITE);
|
||||
logger.debug(tempFile.toString());
|
||||
return tempFile;
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<String> createInfoData() {
|
||||
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().getProjectInfo() != null) {
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmName() != null) {
|
||||
infos.add("Algorithm Name: "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToUpper());
|
||||
infos.add("Class Name: org.gcube.dataanalysis.executor.rscripts."+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName());
|
||||
|
||||
infos.add("Algorithm Name: " + project.getInputData().getProjectInfo().getAlgorithmNameToUpper());
|
||||
infos.add("Class Name: org.gcube.dataanalysis.executor.rscripts."
|
||||
+ project.getInputData().getProjectInfo().getAlgorithmNameToClassName());
|
||||
|
||||
} else {
|
||||
infos.add("Algorithm Name: ");
|
||||
infos.add("Class Name: ");
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmDescription() != null) {
|
||||
infos.add("Algorithm Description: "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmDescription());
|
||||
+ project.getInputData().getProjectInfo().getAlgorithmDescription());
|
||||
} else {
|
||||
infos.add("Algorithm Description: ");
|
||||
}
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmCategory() != null) {
|
||||
infos.add("Algorithm Category: "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmCategory());
|
||||
infos.add("Algorithm Category: " + project.getInputData().getProjectInfo().getAlgorithmCategory());
|
||||
} else {
|
||||
infos.add("Algorithm Category: ");
|
||||
}
|
||||
|
||||
|
||||
infos.add("");
|
||||
|
||||
/*
|
||||
if (project.getInputData().getProjectInfo()
|
||||
.getListRequestedVRE() != null
|
||||
&& project.getInputData().getProjectInfo()
|
||||
.getListRequestedVRE().size() > 0) {
|
||||
infos.add("Deployable VRE:");
|
||||
for (RequestedVRE deployableVRE : project.getInputData()
|
||||
.getProjectInfo().getListRequestedVRE()) {
|
||||
infos.add("" + deployableVRE.getName() + " " + deployableVRE.getDescription());
|
||||
}
|
||||
infos.add("");
|
||||
}*/
|
||||
|
||||
* if (project.getInputData().getProjectInfo()
|
||||
* .getListRequestedVRE() != null &&
|
||||
* project.getInputData().getProjectInfo()
|
||||
* .getListRequestedVRE().size() > 0) {
|
||||
* infos.add("Deployable VRE:"); for (RequestedVRE deployableVRE
|
||||
* : project.getInputData()
|
||||
* .getProjectInfo().getListRequestedVRE()) { infos.add("" +
|
||||
* deployableVRE.getName() + " " +
|
||||
* deployableVRE.getDescription()); } infos.add(""); }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
if (project.getInputData().getInterpreterInfo() != null) {
|
||||
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
|
||||
infos.add("Interpreter Version: "
|
||||
+ project.getInputData().getInterpreterInfo()
|
||||
.getVersion());
|
||||
infos.add("Interpreter Version: " + project.getInputData().getInterpreterInfo().getVersion());
|
||||
} else {
|
||||
infos.add("Interpreter Version: Any");
|
||||
}
|
||||
infos.add("");
|
||||
if (project.getInputData().getInterpreterInfo()
|
||||
.getInterpreterPackagesInfo() != null
|
||||
&& project.getInputData().getInterpreterInfo()
|
||||
.getInterpreterPackagesInfo().size() > 0) {
|
||||
if (project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo() != null
|
||||
&& project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size() > 0) {
|
||||
infos.add("Packages:");
|
||||
for (InterpreterPackageInfo info : project.getInputData()
|
||||
.getInterpreterInfo().getInterpreterPackagesInfo()) {
|
||||
for (InterpreterPackageInfo info : project.getInputData().getInterpreterInfo()
|
||||
.getInterpreterPackagesInfo()) {
|
||||
infos.add("" + info.getName() + " " + info.getVersion());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -587,7 +587,7 @@ public class ProjectBuilder {
|
|||
}
|
||||
|
||||
private void createIntegrationInfo() throws StatAlgoImporterServiceException {
|
||||
InfoGenerator integrationInfoGenerator = new InfoGenerator(project);
|
||||
InfoGenerator integrationInfoGenerator = new InfoGenerator(project, serviceCredentials);
|
||||
infoTXT = integrationInfoGenerator.createInfo();
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
|
Loading…
Reference in New Issue