getExecutions() throws BusinessException {
+ try {
+ return executionPublicDAO.getExecutions();
+ } catch (DAOException ex) {
+ throw new BusinessException(ex);
+ }
+ }
+}
+
diff --git a/vip-application/src/main/java/fr/insalyon/creatis/vip/application/server/business/ReproVipBusiness.java b/vip-application/src/main/java/fr/insalyon/creatis/vip/application/server/business/ReproVipBusiness.java
new file mode 100644
index 000000000..a59b36bcd
--- /dev/null
+++ b/vip-application/src/main/java/fr/insalyon/creatis/vip/application/server/business/ReproVipBusiness.java
@@ -0,0 +1,257 @@
+package fr.insalyon.creatis.vip.application.server.business;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import fr.insalyon.creatis.vip.application.client.bean.AppVersion;
+import fr.insalyon.creatis.vip.application.client.bean.InOutData;
+import fr.insalyon.creatis.vip.application.client.bean.Task;
+import fr.insalyon.creatis.vip.application.client.view.ApplicationException;
+import fr.insalyon.creatis.vip.application.server.dao.h2.SimulationData;
+import fr.insalyon.creatis.vip.core.client.bean.Execution;
+import fr.insalyon.creatis.vip.core.client.bean.User;
+import fr.insalyon.creatis.vip.core.server.business.BusinessException;
+import fr.insalyon.creatis.vip.core.server.business.ConfigurationBusiness;
+import fr.insalyon.creatis.vip.core.server.business.EmailBusiness;
+import fr.insalyon.creatis.vip.core.server.business.Server;
+import fr.insalyon.creatis.vip.core.server.dao.DAOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+@Service
+@Transactional
+public class ReproVipBusiness {
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ @Autowired
+ private ConfigurationBusiness configurationBusiness;
+ @Autowired
+ private WorkflowBusiness workflowBusiness;
+ @Autowired
+ private ApplicationBusiness applicationBusiness;
+ @Autowired
+ private EmailBusiness emailBusiness;
+ @Autowired
+ private ExecutionInOutData executionInOutData;
+ @Autowired
+ private Server server;
+ @Autowired
+ private SimulationBusiness simulationBusiness;
+ public void executionAdminEmail(Execution execution) throws DAOException, BusinessException {
+ String adminsEmailContents = ""
+ + ""
+ + ""
+ + "Dear Administrator,
"
+ + "A new user requested to make an execution public
"
+ + "Details:
"
+ + ""
+ + "- ID: " + execution.getId() + "
"
+ + "- Name: " + execution.getSimulationName() + "
"
+ + "- Name: " + execution.getApplicationName() + "
"
+ + "- Version: " + execution.getVersion() + "
"
+ + "- Status: " + execution.getStatus() + "
"
+ + "- Author: " + execution.getAuthor() + "
"
+ + "- Comments: " + execution.getComments() + "
"
+ + "
"
+ + "Best Regards,
"
+ + "VIP Team
"
+ + ""
+ + "";
+
+ logger.info("Sending confirmation email from '" + execution.getAuthor() + "'.");
+ for (String adminEmail : configurationBusiness.getAdministratorsEmails()) {
+ emailBusiness.sendEmail("[VIP Admin] Execution Public Request", adminsEmailContents,
+ new String[]{adminEmail}, true, execution.getAuthor());
+ }
+ logger.info("Email send");
+ }
+
+ public ExecutionInOutData executionOutputData(String executionID, User currentUser) throws ApplicationException, BusinessException {
+ logger.info("Fetching data for executionID: {}", executionID);
+
+ List outputData = workflowBusiness.getOutputData(executionID, currentUser.getFolder());
+ logger.info(String.valueOf(outputData));
+ List inputData = workflowBusiness.getInputData(executionID, currentUser.getFolder());
+
+ if (outputData != null) {
+ logger.info("Fetched {} output data items", outputData.size());
+ logger.info(outputData.toString());
+ } else {
+ logger.info("Output data is null for executionID: {}", executionID);
+ }
+
+ if (inputData != null) {
+ logger.info("Fetched {} input data items", inputData.size());
+ logger.info(inputData.toString());
+ } else {
+ logger.info("Input data is null for executionID: {}", executionID);
+ }
+
+ return new ExecutionInOutData(inputData, outputData);
+ }
+
+ public ExecutionJobTaskData getExecutionJobTaskData(String executionID) throws BusinessException {
+ logger.info("Fetching job and task data for executionID: {}", executionID);
+ List jobList = simulationBusiness.getJobsList(executionID);
+ if (jobList == null || jobList.isEmpty()) {
+ logger.info("No jobs found for executionID: {}", executionID);
+ }
+ return new ExecutionJobTaskData(jobList);
+ }
+ public String generateReprovipJson(Path reproVipDir, String executionName, String executionID, String version,
+ String comments, User currentUser, List provenanceFiles)
+ throws BusinessException, DAOException {
+ Path workflowVipDir = Paths.get("/vip/ReproVip/" + executionID);
+ String filesToDownload = getDescritporBoutiqueJsonPath(executionName, version);
+
+ List filesToUpload = provenanceFiles.stream()
+ .map(Path::toString)
+ .collect(Collectors.toList());
+
+ Map structuredJson = new LinkedHashMap<>();
+ structuredJson.put("path_workflow_directory", workflowVipDir);
+ structuredJson.put("descriptor_boutique", filesToDownload);
+ structuredJson.put("files_to_upload", filesToUpload);
+
+ Map> invocationOutputsMap = new LinkedHashMap<>();
+
+ for (Path provenanceFile : provenanceFiles) {
+ String fileName = provenanceFile.getFileName().toString();
+ String invocationID = fileName.substring(0, fileName.indexOf(".sh.provenance.json"));
+ List outputDataPaths = simulationBusiness.getSimulationDAO(executionID).getOutputData(invocationID);
+ invocationOutputsMap.put(invocationID, outputDataPaths);
+ }
+
+ structuredJson.put("invocation_outputs", invocationOutputsMap);
+
+ Map metadataOuter = new LinkedHashMap<>();
+ Map metadataInner = new LinkedHashMap<>();
+
+ metadataInner.put("title", "your title");
+ metadataInner.put("upload_type", "workflow");
+ metadataInner.put("description", comments);
+
+ List