Commit 2e0109c3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

get source file moved to controler

parent e48e63f0
......@@ -42,7 +42,6 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.converter.zip.ZipEntryFile;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.graphics.MapCanvasType;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -430,7 +429,8 @@ public class ProjectController extends BaseController {
@GetMapping(value = "/{projectId}:downloadSource")
public ResponseEntity<byte[]> getProjectSource(@PathVariable(value = "projectId") String projectId)
throws QueryException {
FileEntry file = projectController.getSource(projectId);
UploadedFileEntry file = projectService.getFileByProjectId(projectId);
if (file == null) {
throw new ObjectNotFoundException("File doesn't exist");
}
......
......@@ -18,7 +18,6 @@ import lcsb.mapviewer.api.OperationNotAllowedException;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.ProjectLogEntry;
import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.layout.ProjectBackground;
import lcsb.mapviewer.model.map.species.Element;
......@@ -55,15 +54,6 @@ public class ProjectRestImpl extends BaseRestImpl {
return project;
}
public FileEntry getSource(String projectId) throws QueryException {
Project project = getProjectByProjectId(projectId);
if (project.getInputData() != null) {
// fetch the data from db
project.getInputData().getFileContent();
}
return project.getInputData();
}
public Map<String, Object> getStatistics(String projectId) throws QueryException {
Map<String, Object> result = new TreeMap<>();
......
......@@ -1346,11 +1346,21 @@ public class ProjectService implements IProjectService {
@Override
public void updateBackground(ProjectBackground background) {
projectBackgroundDao.update(background);
}
@Override
public long getNextId() {
return projectDao.getNextId();
}
@Override
public UploadedFileEntry getFileByProjectId(String projectId) {
Project project = getProjectByProjectId(projectId);
if (project == null) {
return null;
}
Hibernate.initialize(project.getInputData());
return project.getInputData();
}
}
......@@ -5,6 +5,7 @@ import java.util.List;
import org.primefaces.model.TreeNode;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.layout.ProjectBackground;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.model.user.UserAnnotationSchema;
......@@ -119,4 +120,6 @@ public interface IProjectService {
void updateBackground(ProjectBackground background);
long getNextId();
UploadedFileEntry getFileByProjectId(String projectId);
}
......@@ -47,7 +47,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonParser;
import lcsb.mapviewer.api.projects.ProjectRestImpl;
import lcsb.mapviewer.converter.zip.ZipEntryFileDeserializer;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.ProjectStatus;
......
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