Commit e2a3e779 authored by Piotr Gawron's avatar Piotr Gawron

try to fix project problems during upload

parent d8fe55f7
......@@ -40,6 +40,7 @@ import lcsb.mapviewer.model.user.annotator.AnnotatorData;
import lcsb.mapviewer.modelutils.map.ClassTreeNode;
import lcsb.mapviewer.modelutils.map.ElementUtils;
import lcsb.mapviewer.persist.DbUtils;
import lcsb.mapviewer.persist.ObjectValidator;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.map.LayoutDao;
import lcsb.mapviewer.persist.dao.map.ModelDao;
......@@ -331,6 +332,7 @@ public class ProjectService implements IProjectService {
}
Project project = createProjectFromParams(params);
fixProjectIssues(project);
projectDao.add(project);
if (params.isAsync()) {
projectDao.commit();
......@@ -751,13 +753,12 @@ public class ProjectService implements IProjectService {
l.setVisible(false);
}
}
fixProjectIssues(project);
assignZoomLevelDataToModel(topModel);
dbProject.setNotifyEmail(params.getNotifyEmail());
updateProjectStatus(project, ProjectStatus.UPLOADING_TO_DB, 0.0, params);
dbUtils.setAutoFlush(false);
projectDao.update(project);
dbUtils.setAutoFlush(true);
projectDao.flush();
......@@ -884,6 +885,7 @@ public class ProjectService implements IProjectService {
|| (Math.abs(progress - project.getProgress()) > IProgressUpdater.PROGRESS_BAR_UPDATE_RESOLUTION)) {
project.setStatus(status);
project.setProgress(progress);
fixProjectIssues(project);
projectDao.update(project);
if (params.isAsync()) {
projectDao.commit();
......@@ -1191,4 +1193,27 @@ public class ProjectService implements IProjectService {
return entry;
}
private void fixProjectIssues(Project project) {
ObjectValidator validator = new ObjectValidator();
List<Pair<Object, String>> issues = validator.getValidationIssues(project);
if (issues.size() > 0) {
for (Pair<Object, String> pair : issues) {
ProjectLogEntry entry = new ProjectLogEntry();
entry.setContent(pair.getRight());
Object left = pair.getLeft();
if (left instanceof BioEntity) {
BioEntity bioEntity = (BioEntity) left;
entry.setMapName(bioEntity.getModel().getName());
entry.setObjectClass(bioEntity.getClass().getSimpleName());
entry.setObjectIdentifier(bioEntity.getElementId());
} else if (left instanceof ModelData) {
entry.setMapName(((ModelData) left).getName());
}
entry.setSeverity("WARNING");
entry.setType(ProjectLogEntryType.DATABASE_PROBLEM);
project.addLogEntry(entry);
}
}
validator.fixValidationIssues(project);
}
}
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