1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Added Constraint on Software Creation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122372 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0c8ad1cfba
commit
7293907826
|
@ -19,7 +19,6 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.SessionUtil;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
|
@ -61,7 +60,6 @@ public class ProjectBuilder {
|
|||
|
||||
private Project project;
|
||||
private ASLSession aslSession;
|
||||
private HttpSession session;
|
||||
private ProjectTarget projectTarget;
|
||||
private Path algorithmJava;
|
||||
private Path infoTXT;
|
||||
|
@ -70,7 +68,6 @@ public class ProjectBuilder {
|
|||
HttpSession session) {
|
||||
this.project = project;
|
||||
this.aslSession = aslSession;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
private void checkInfo() throws StatAlgoImporterServiceException {
|
||||
|
@ -94,21 +91,44 @@ public class ProjectBuilder {
|
|||
"Attention No Project Information Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmName() == null) {
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmName() == null
|
||||
|| project.getInputData().getProjectInfo().getAlgorithmName()
|
||||
.isEmpty()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Algorithm Name Set!");
|
||||
"Attention No Info Name Set!");
|
||||
}
|
||||
|
||||
if (project.getMainCode() == null) {
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmDescription() == null
|
||||
|| project.getInputData().getProjectInfo()
|
||||
.getAlgorithmDescription().isEmpty()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Info Description Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getInterpreterInfo() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Interpreter Info Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getInterpreterInfo().getVersion() == null
|
||||
|| project.getInputData().getInterpreterInfo().getVersion()
|
||||
.isEmpty()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Interpreter Version Set!");
|
||||
}
|
||||
|
||||
if (project.getInputData().getListInputOutputVariables() == null
|
||||
|| project.getInputData().getListInputOutputVariables().size() < 1) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Input/Output Set!");
|
||||
}
|
||||
|
||||
if (project.getMainCode() == null
|
||||
|| project.getMainCode().getItemDescription() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Main Code Set");
|
||||
}
|
||||
|
||||
if (project.getInputData() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Attention No Input Data Set!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Project build() throws StatAlgoImporterServiceException {
|
||||
|
@ -207,7 +227,8 @@ public class ProjectBuilder {
|
|||
try {
|
||||
projectPackageItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(), inputStream, project
|
||||
.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ PROJECT_PACKAGE_EXTENTION,
|
||||
PROJECT_PACKAGE_DESCRIPTION, PROJECT_PACKAGE_MIMETYPE,
|
||||
targetFolder.getId());
|
||||
|
@ -240,8 +261,7 @@ public class ProjectBuilder {
|
|||
|
||||
private void createIntegrationInfo()
|
||||
throws StatAlgoImporterServiceException {
|
||||
InfoGenerator integrationInfoGenerator = new InfoGenerator(
|
||||
project);
|
||||
InfoGenerator integrationInfoGenerator = new InfoGenerator(project);
|
||||
infoTXT = integrationInfoGenerator.createInfo();
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
|
@ -251,9 +271,9 @@ public class ProjectBuilder {
|
|||
infoItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(),
|
||||
Files.newInputStream(infoTXT, StandardOpenOption.READ),
|
||||
INFO_NAME + INFO_EXTENTION,
|
||||
INFO_DESCRIPTION, INFO_MIMETYPE,
|
||||
project.getProjectTarget().getTargetFolder().getId());
|
||||
INFO_NAME + INFO_EXTENTION, INFO_DESCRIPTION,
|
||||
INFO_MIMETYPE, project.getProjectTarget().getTargetFolder()
|
||||
.getId());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -297,12 +317,12 @@ public class ProjectBuilder {
|
|||
storage.downloadInputFile(ECOLOGICAL_ENGINE_SMART_EXECUTOR_JAR_URL,
|
||||
ecologicalEngineSmartExecutorJar);
|
||||
Path algorithmTempFile = new File(tempDirectory.toFile(), project
|
||||
.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ ALGORITHM_EXTENTION).toPath();
|
||||
Files.copy(algorithmJava, algorithmTempFile);
|
||||
Path infoTempFile = new File(tempDirectory.toFile(),
|
||||
INFO_NAME + INFO_EXTENTION)
|
||||
.toPath();
|
||||
Path infoTempFile = new File(tempDirectory.toFile(), INFO_NAME
|
||||
+ INFO_EXTENTION).toPath();
|
||||
Files.copy(infoTXT, infoTempFile);
|
||||
|
||||
createClassFile(tempDirectory);
|
||||
|
@ -321,17 +341,21 @@ public class ProjectBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private void copyJarOnWorkspace(Path tempDirectory) throws StatAlgoImporterServiceException {
|
||||
Path codeJar=Paths.get(tempDirectory.toString(),project.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
private void copyJarOnWorkspace(Path tempDirectory)
|
||||
throws StatAlgoImporterServiceException {
|
||||
Path codeJar = Paths.get(tempDirectory.toString(), project
|
||||
.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
+ JAR_EXTENTION);
|
||||
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
WorkspaceItem codeJarItem;
|
||||
|
||||
try {
|
||||
codeJarItem = filesStorage.createItemOnWorkspace(aslSession
|
||||
.getUsername(), Files.newInputStream(codeJar,
|
||||
StandardOpenOption.READ), project.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
codeJarItem = filesStorage.createItemOnWorkspace(
|
||||
aslSession.getUsername(),
|
||||
Files.newInputStream(codeJar, StandardOpenOption.READ),
|
||||
project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ JAR_EXTENTION, CODE_JAR_DESCRIPTION,
|
||||
CODE_JAR_MIMETYPE, project.getProjectTarget()
|
||||
.getTargetFolder().getId());
|
||||
|
@ -348,7 +372,8 @@ public class ProjectBuilder {
|
|||
codeJarItem.getName(), codeJarItem.getOwner()
|
||||
.getPortalLogin(), codeJarItem.getPath(),
|
||||
codeJarItem.getType().name());
|
||||
codeJarItemDescription.setPublicLink(codeJarItem.getPublicLink(true));
|
||||
codeJarItemDescription.setPublicLink(codeJarItem
|
||||
.getPublicLink(true));
|
||||
} catch (InternalErrorException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -369,7 +394,8 @@ public class ProjectBuilder {
|
|||
|
||||
ProcessBuilder pb = new ProcessBuilder("javac", "-cp",
|
||||
tempDirectory.toAbsolutePath().toString() + "/*", project
|
||||
.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ ALGORITHM_EXTENTION);
|
||||
pb.directory(tempDirectory.toFile());
|
||||
Path logTXT = new File(tempDirectory.toFile(), LOG_TXT).toPath();
|
||||
|
@ -398,7 +424,8 @@ public class ProjectBuilder {
|
|||
List<String> commands = new ArrayList<>();
|
||||
commands.add("jar");
|
||||
commands.add("-cvf");
|
||||
commands.add(project.getInputData().getProjectInfo().getAlgorithmNameToClassName()
|
||||
commands.add(project.getInputData().getProjectInfo()
|
||||
.getAlgorithmNameToClassName()
|
||||
+ JAR_EXTENTION);
|
||||
|
||||
DirectoryStream<Path> directoryStream = Files
|
||||
|
|
Loading…
Reference in New Issue