Commit fe105d0a authored by Michael Menzel's avatar Michael Menzel

Optional assem for user site creation

parent 5550cc84
......@@ -101,12 +101,12 @@ public class BatchController {
Comparator<String> byIndex = Comparator.comparing(names::indexOf); // sort by index of names of user uploaded bed file names
for (MultipartFile mf : files) {
batchSites.add(ControllerHelper.getUserData(mf));
batchSites.add(ControllerHelper.getUserData(mf, Optional.of(assembly)));
names.add(mf.getOriginalFilename());
}
if (!Objects.isNull(bg) && !bg.isEmpty()) {
background = ControllerHelper.getUserData(bg);
background = ControllerHelper.getUserData(bg, Optional.of(assembly));
command = new BackendCommand.Builder(Command.Task.ANALYZE_BATCH, assembly)
.batchSites(batchSites)
......
......@@ -276,6 +276,7 @@ public class ControllerHelper {
model.addAttribute("expressionCommand", exCommand);
}
/**
* Reads the user data for a given uploaded multipart file.
* Returns the generated user sites
......@@ -284,7 +285,7 @@ public class ControllerHelper {
* @return User sites with the given data
* @throws IllegalArgumentException if the file was empty
*/
public static UserData getUserData(MultipartFile file) throws IllegalArgumentException {
public static UserData getUserData(MultipartFile file, Optional<Genome.Assembly> assembly) throws IllegalArgumentException {
String name = file.getOriginalFilename();
......@@ -299,8 +300,7 @@ public class ControllerHelper {
Path inputFilepath = basePath.resolve(filenameWithUUID);
UserData data = new UserData(AssemblyGuesser.guessAssembly(inputFilepath), inputFilepath, "Unknown");
UserData data = new UserData(assembly.orElseGet(() -> AssemblyGuesser.guessAssembly(inputFilepath)), inputFilepath, "Unknown");
try {
Files.deleteIfExists(inputFilepath);
} catch (IOException e) {
......
......@@ -100,7 +100,7 @@ public class UploadController {
StatisticsCollector stats = StatisticsCollector.getInstance();
try {
UserData data = ControllerHelper.getUserData(file);
UserData data = ControllerHelper.getUserData(file, Optional.empty());
if (data.getPositionCount() < 1) {
model.addAttribute("errorMessage", "There were no positions in the file '" + file.getOriginalFilename() + "' you uploaded." +
......@@ -158,7 +158,7 @@ public class UploadController {
String name = currentSession.getOriginalFilename();
try {
UserData sitesBg = ControllerHelper.getUserData(bgFile); //new UserData(assembly, inputFilepath, "none");
UserData sitesBg = ControllerHelper.getUserData(bgFile, Optional.empty()); //new UserData(assembly, inputFilepath, "none");
currentSession.setBgSites(sitesBg);
......
......@@ -44,6 +44,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpSession;
import java.net.SocketTimeoutException;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static de.thm.spring.controller.ControllerHelper.setModel;
......@@ -96,7 +97,7 @@ public class WizardController {
if(currentSession.getSites() == null) {
UserData data = ControllerHelper.getUserData(file);
UserData data = ControllerHelper.getUserData(file, Optional.empty());
currentSession.setSites(data);
currentSession.setOriginalFilename(file.getOriginalFilename());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment