diff --git a/model/src/main/java/lcsb/mapviewer/model/Project.java b/model/src/main/java/lcsb/mapviewer/model/Project.java index be02286a96229a2f8edda057ed512cd159ebbfbc..936f0874c8b1fc247d7ac900466631c1374892a0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/Project.java +++ b/model/src/main/java/lcsb/mapviewer/model/Project.java @@ -184,13 +184,13 @@ public class Project implements Serializable { } /** - * Constructor with the project name in the parameter. + * Constructor with the project id in the parameter. * - * @param projectName - * name of the project + * @param projectId + * id of the project */ - public Project(String projectName) { - this.projectId = projectName; + public Project(String projectId) { + this.projectId = projectId; } /** diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java index 675cb75690d87efd460616fb237ffd26f3432372..fda7f054299cb9e5bb3189a0ea4a2d1691717655 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -33,6 +33,7 @@ import lcsb.mapviewer.annotation.services.MeSHParser; import lcsb.mapviewer.annotation.services.ModelAnnotator; import lcsb.mapviewer.annotation.services.ProblematicAnnotation; import lcsb.mapviewer.annotation.services.TaxonomyBackend; +import lcsb.mapviewer.annotation.services.TaxonomySearchException; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator; import lcsb.mapviewer.commands.ClearColorModelCommand; @@ -735,27 +736,7 @@ public class ProjectService implements IProjectService { dbUtils.createSessionForCurrentThread(); } - Project project = new Project(); - project.setProjectId(params.getProjectId()); - project.setName(params.getProjectName()); - if (params.getProjectDir() == null) { - logger.warn("Project directory not set"); - project.setDirectory(null); - } else { - project.setDirectory(new File(params.getProjectDir()).getName()); - } - project.setSbgnFormat(params.isSbgnFormat()); - - MiriamData disease = null; - if (params.getDisease() != null && !params.getDisease().isEmpty()) { - disease = new MiriamData(MiriamType.MESH_2012, params.getDisease()); - } - MiriamData organism = null; - if (params.getOrganism() != null && !params.getOrganism().isEmpty()) { - organism = new MiriamData(MiriamType.TAXONOMY, params.getOrganism()); - } - project.setMapCanvasType(params.getMapCanvasType()); - project.setVersion(params.getVersion()); + Project project = createProjectFromParams(params); projectDao.add(project); if (params.isAsync()) { projectDao.commit(); @@ -787,7 +768,6 @@ public class ProjectService implements IProjectService { file.setOwner(owner); project.setInputData(file); } - createModel(params, project); Model originalModel = project.getModels().iterator().next().getModel(); @@ -808,22 +788,6 @@ public class ProjectService implements IProjectService { } } - try { - if (meshParser.isValidMeshId(disease)) { - project.setDisease(disease); - } else { - logger.warn("No valid disease is provided for project:" + project.getName()); - } - } catch (AnnotatorException e1) { - logger.warn("Problem with accessing mesh db. More info in logs."); - } - - if (taxonomyBackend.getNameForTaxonomy(organism) != null) { - project.setOrganism(organism); - } else { - logger.warn(project.getProjectId() + "\tNo valid organism is provided for project. " + organism); - } - projectDao.update(project); if (params.isAnalyzeAnnotations()) { @@ -869,6 +833,7 @@ public class ProjectService implements IProjectService { Logger.getRootLogger().removeAppender(appender); } } + }); if (params.isAsync()) { computations.start(); @@ -1379,4 +1344,48 @@ public class ProjectService implements IProjectService { return projectDao.getAll(); } + private Project createProjectFromParams(final CreateProjectParams params) { + Project project = new Project(params.getProjectId()); + project.setName(params.getProjectName()); + if (params.getProjectDir() == null) { + logger.warn("Project directory not set"); + project.setDirectory(null); + } else { + project.setDirectory(new File(params.getProjectDir()).getName()); + } + project.setSbgnFormat(params.isSbgnFormat()); + + MiriamData disease = null; + if (params.getDisease() != null && !params.getDisease().isEmpty()) { + disease = new MiriamData(MiriamType.MESH_2012, params.getDisease()); + } + MiriamData organism = null; + if (params.getOrganism() != null && !params.getOrganism().isEmpty()) { + organism = new MiriamData(MiriamType.TAXONOMY, params.getOrganism()); + } + try { + if (meshParser.isValidMeshId(disease)) { + project.setDisease(disease); + } else { + logger.warn("No valid disease is provided for project:" + project.getName()); + } + } catch (AnnotatorException e1) { + logger.warn("Problem with accessing mesh db. More info in logs.", e1); + } + + try { + if (taxonomyBackend.getNameForTaxonomy(organism) != null) { + project.setOrganism(organism); + } else { + logger.warn(project.getProjectId() + "\tNo valid organism is provided for project. " + organism); + } + } catch (TaxonomySearchException e) { + logger.warn("Problem with accessing taxonomy db. More info in logs.", e); + } + + project.setMapCanvasType(params.getMapCanvasType()); + project.setVersion(params.getVersion()); + return project; + } + }