diff --git a/frontend-js/.project b/frontend-js/.project index b16945b817cadc67c596ea9a7523ad04e6e8ad27..428200f5255e66aa2f44c2a8b2e4dd871ee20285 100644 --- a/frontend-js/.project +++ b/frontend-js/.project @@ -16,12 +16,12 @@ </arguments> </buildCommand> <buildCommand> - <name>org.eclipse.m2e.core.maven2Builder</name> + <name>org.eclipse.wst.validation.validationbuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> - <name>org.eclipse.wst.validation.validationbuilder</name> + <name>org.eclipse.m2e.core.maven2Builder</name> <arguments> </arguments> </buildCommand> diff --git a/frontend-js/.settings/org.eclipse.wst.validation.prefs b/frontend-js/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000000000000000000000000000000000000..04cad8cb752a9761c4e5167d0301d3a27674430f --- /dev/null +++ b/frontend-js/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/model/src/main/java/lcsb/mapviewer/model/Project.java b/model/src/main/java/lcsb/mapviewer/model/Project.java index 16e701ed09eda6e3ca1e219ea2f34849c0dd4544..58dda0f6ce3b8620b41dae387f1833b6bc8c67ad 100644 --- a/model/src/main/java/lcsb/mapviewer/model/Project.java +++ b/model/src/main/java/lcsb/mapviewer/model/Project.java @@ -88,6 +88,12 @@ public class Project implements Serializable { */ private String version; + /** + * Email of the user who should be notified when some serious modification to + * the map were performed. + */ + private String notifyEmail; + /** * Directory where the images on the server will be stored for this project. */ @@ -561,4 +567,20 @@ public class Project implements Serializable { this.inputData = inputData; } + /** + * @return the notifyEmail + * @see #notifyEmail + */ + public String getNotifyEmail() { + return notifyEmail; + } + + /** + * @param notifyEmail the notifyEmail to set + * @see #notifyEmail + */ + public void setNotifyEmail(String notifyEmail) { + this.notifyEmail = notifyEmail; + } + } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java index 5f7e5f5e87d2b42694aaf322317191ef5147fbcb..f5d4a32637e68c4141e308b33f965e728724926b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java @@ -189,19 +189,6 @@ public interface Model { */ void addBlockDiagream(BlockDiagram blockDiagram); - /** - * @param notifyEmail - * the notifyEmail to set - * @see Model#notifyEmail - */ - void setNotifyEmail(String notifyEmail); - - /** - * @return the notifyEmail - * @see Model#notifyEmail - */ - String getNotifyEmail(); - /** * @param idModel * the idModel to set diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java index 549517cd27004183f486f195fe0649cdd1d947ee..448470f1d801487df805bdcf070be01b41f13194 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java @@ -131,12 +131,6 @@ public class ModelData implements Serializable { */ private String idModel; - /** - * Email of the user who should be notified when some serious modification to - * the map were performed. - */ - private String notifyEmail; - /** * How many hierarchical levels are in this map. */ @@ -501,23 +495,6 @@ public class ModelData implements Serializable { this.idModel = idModel; } - /** - * @return the notifyEmail - * @see #notifyEmail - */ - public String getNotifyEmail() { - return notifyEmail; - } - - /** - * @param notifyEmail - * the notifyEmail to set - * @see #notifyEmail - */ - public void setNotifyEmail(String notifyEmail) { - this.notifyEmail = notifyEmail; - } - /** * @return the model * @see #model diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java index 6f30507ce9a27579b2f02495539427570a3ab0f9..cef95d6fd21ac50827dea0321c6e19c0e59dc866 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java @@ -450,16 +450,6 @@ public class ModelFullIndexed implements Model { this.modelData.setIdModel(idModel); } - @Override - public String getNotifyEmail() { - return modelData.getNotifyEmail(); - } - - @Override - public void setNotifyEmail(String notifyEmail) { - modelData.setNotifyEmail(notifyEmail); - } - @Override public ModelData getModelData() { return modelData; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java index 83a31526baa3eea98be9d5e85f826bce2d1b936d..d59e5028c19e6fcad561c39a6cd4414d7daeb6d4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java @@ -277,9 +277,6 @@ public class ModelDataTest { md.setIdModel(modelId); assertEquals(modelId, md.getIdModel()); - md.setNotifyEmail(email); - assertEquals(email, md.getNotifyEmail()); - md.setNotes(notes); assertEquals(notes, md.getNotes()); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java index 7cd152ac576f46b70667979648cf09ab2c63244b..2ab4f685e19c3960f69652a33b82fce47521a566 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java @@ -781,8 +781,6 @@ public class ModelFullIndexedTest { assertEquals(zoomLevels, model.getZoomLevels()); model.setTileSize(tileSize); assertEquals(tileSize, model.getTileSize()); - model.setNotifyEmail(notifyEmail); - assertEquals(notifyEmail, model.getNotifyEmail()); model.setIdModel(idModel); assertEquals(idModel, model.getIdModel()); model.setCreationDate(creationDate); diff --git a/persist/src/db/11.1.0/fix_db_20170814.sql b/persist/src/db/11.1.0/fix_db_20170814.sql new file mode 100644 index 0000000000000000000000000000000000000000..344f566bf05e5bae94da19c4b9e28649bb44b770 --- /dev/null +++ b/persist/src/db/11.1.0/fix_db_20170814.sql @@ -0,0 +1,4 @@ +-- notify email from model into project +alter table project_table add column notifyemail character varying default ''; +update project_table set version = model_table.notifyemail from model_table where project_table.iddb = model_table.project_iddb; +alter table model_table drop column notifyemail; diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java index 8ee4e0cefaf44bb525d71dd1923407e8230debfe..0f5e9a63fadc3198bc62cc848d100718f8b521a3 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java @@ -2,12 +2,14 @@ package lcsb.mapviewer.api.projects; import java.io.IOException; import java.util.List; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -27,15 +29,28 @@ import lcsb.mapviewer.services.SecurityException; @RestController public class ProjectController extends BaseController { + @Autowired private ProjectRestImpl projectController; @RequestMapping(value = "/projects/{projectId:.+}", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public ProjectMetaData getMetaData(// + public ProjectMetaData getProject(// @PathVariable(value = "projectId") String projectId, // @CookieValue(value = Configuration.AUTH_TOKEN) String token // ) throws SecurityException, ObjectNotFoundException { - return projectController.getMetaData(projectId, token); + return projectController.getProject(projectId, token); + } + + @RequestMapping(value = "/projects/{projectId:.+}", method = { RequestMethod.PATCH }, produces = { MediaType.APPLICATION_JSON_VALUE }) + public ProjectMetaData updateProject(// + @RequestBody String body, // + @PathVariable(value = "projectId") String projectId, // + @CookieValue(value = Configuration.AUTH_TOKEN) String token // + ) throws SecurityException, IOException, QueryException { + Map<String, Object> node = parseBody(body); + Map<String, Object> data = getData(node, "project"); + return projectController.updateProject(token, projectId, data); + } @RequestMapping(value = "/projects/", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java index 3741471d0344f55f2cc0969e19ae37bf76414900..585664b010bc12b0d1e8edbe4d4d7455234dbc8d 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectMetaData.java @@ -33,6 +33,7 @@ public class ProjectMetaData implements Serializable { private Integer idObject; private String status; private Double progress; + private String notifyEmail; /** * Name of the project. @@ -228,4 +229,20 @@ public class ProjectMetaData implements Serializable { public void setProgress(Double progress) { this.progress = progress; } + + /** + * @return the notifyEmail + * @see #notifyEmail + */ + public String getNotifyEmail() { + return notifyEmail; + } + + /** + * @param notifyEmail the notifyEmail to set + * @see #notifyEmail + */ + public void setNotifyEmail(String notifyEmail) { + this.notifyEmail = notifyEmail; + } } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index 8f51075df61edfaa2274a37c6407ef771507e295..34bdb657aa18d6c5aab258d84212fcef9320472e 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -31,6 +31,7 @@ import lcsb.mapviewer.commands.CopyCommand; import lcsb.mapviewer.commands.SetFixedHierarchyLevelCommand; import lcsb.mapviewer.commands.SubModelCommand; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.ConverterException; import lcsb.mapviewer.converter.IConverter; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; @@ -53,6 +54,7 @@ import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.interfaces.ILayoutService; @@ -88,7 +90,7 @@ public class ProjectRestImpl extends BaseRestImpl { @Autowired private OverviewImageViewFactory factory; - public ProjectMetaData getMetaData(String projectId, String token) throws SecurityException, ObjectNotFoundException { + public ProjectMetaData getProject(String projectId, String token) throws SecurityException, ObjectNotFoundException { AuthenticationToken authenticationToken = getUserService().getToken(token); Project project = getProjectService().getProjectByProjectId(projectId, authenticationToken); if (project == null) { @@ -105,6 +107,7 @@ public class ProjectRestImpl extends BaseRestImpl { result.setProjectId(project.getProjectId()); result.setIdObject(project.getId()); result.setVersion(project.getVersion()); + result.setNotifyEmail(project.getNotifyEmail()); if (project.getStatus() != null) { result.setStatus(project.getStatus().toString()); } @@ -395,4 +398,70 @@ public class ProjectRestImpl extends BaseRestImpl { return result; } + public ProjectMetaData updateProject(String token, String projectId, Map<String, Object> data) throws SecurityException, QueryException { + AuthenticationToken authenticationToken = getUserService().getToken(token); + Project project = getProjectService().getProjectByProjectId(projectId, authenticationToken); + if (project == null) { + throw new ObjectNotFoundException("Project with given id doesn't exist"); + } + boolean canModify = getUserService().userHasPrivilege(authenticationToken, PrivilegeType.ADD_MAP); + if (!canModify) { + throw new SecurityException("You cannot update projects"); + } + Set<String> fields = data.keySet(); + for (String string : fields) { + if (string.equalsIgnoreCase("version")) { + project.setVersion((String) data.get(string)); + } else if (string.equalsIgnoreCase("id")) { + try { + int id = Integer.parseInt(string); + if (id != project.getId()) { + throw new QueryException("Invalid id: " + string); + } + } catch (NumberFormatException e) { + throw new QueryException("Invalid id: " + string); + } + } else if (string.equalsIgnoreCase("projectId")) { + if (!project.getProjectId().equalsIgnoreCase(string)) { + throw new QueryException("You cannot modify projectId"); + } + } else if (string.equalsIgnoreCase("name")) { + project.setName((String) data.get(string)); + } else if (string.equalsIgnoreCase("notifyEmail")) { + project.setNotifyEmail((String) data.get(string)); + } else if (string.equalsIgnoreCase("organism")) { + Object res = data.get(string); + MiriamData organism = updateMiriamData(project.getOrganism(), res); + project.setOrganism(organism); + } else if (string.equalsIgnoreCase("disease")) { + Object res = data.get(string); + MiriamData disease = updateMiriamData(project.getDisease(), res); + project.setDisease(disease); + } else { + throw new QueryException("Unknown field: " + string); + } + } + getProjectService().updateProject(project); + return getProject(projectId, token); + } + + private MiriamData updateMiriamData(MiriamData organism, Object res) { + if (res == null) { + return null; + } + if (organism == null) { + organism = new MiriamData(); + } + + if (res instanceof Map) { + @SuppressWarnings("unchecked") + Map<String, Object> map = (Map<String, Object>) res; + organism.setDataType(MiriamType.valueOf((String) map.get("type"))); + organism.setResource((String) map.get("resource")); + return organism; + } else { + throw new InvalidArgumentException("invalid miriamdData: " + res); + } + } + } diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java index 4d008c74dc9ecfaaadda2c0750045acc84547236..aaa01d3ccd8f745d25d4dfaf0106133e7db8842c 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java @@ -136,7 +136,7 @@ public class OverlayRestImpl extends BaseRestImpl { AuthenticationToken authenticationToken = getUserService().getToken(token); Model model = getModelService().getLastModelByProjectId(projectId, authenticationToken); if (model == null) { - throw new QueryException("Project with given id doesn't exist"); + throw new ObjectNotFoundException("Project with given id doesn't exist"); } if (overlayData == null) { throw new QueryException("overlay field cannot be undefined"); @@ -159,10 +159,10 @@ public class OverlayRestImpl extends BaseRestImpl { layout.setTitle((String) overlayData.get("name")); } layoutDao.update(layout); + return layoutService.getLayoutById(model, Integer.valueOf(overlayId), authenticationToken); } catch (NumberFormatException e) { throw new ObjectNotFoundException("overlay doesn't exist"); } - return layoutService.getLayoutById(model, Integer.valueOf(overlayId), authenticationToken); } public Map<String, Object> removeOverlay(String token, String projectId, String overlayId) throws QueryException, SecurityException, IOException { diff --git a/rest-api/src/test/java/lcsb/mapviewer/api/projects/ProjectRestImplTest.java b/rest-api/src/test/java/lcsb/mapviewer/api/projects/ProjectRestImplTest.java index b22b43fefb257b5651e10c2f7f8995180af60bf8..697196ce282385b7f203b70f84e244eacb06e67f 100644 --- a/rest-api/src/test/java/lcsb/mapviewer/api/projects/ProjectRestImplTest.java +++ b/rest-api/src/test/java/lcsb/mapviewer/api/projects/ProjectRestImplTest.java @@ -8,6 +8,7 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.times; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -84,7 +85,7 @@ public class ProjectRestImplTest extends RestTestFunctions { public void testGetModelDataDependencies() throws Exception { try { ProjectRestImpl projectRest = createMockProjectRest("testFiles/model/sample.xml"); - ProjectMetaData result = projectRest.getMetaData("sample", token.getId()); + ProjectMetaData result = projectRest.getProject("sample", token.getId()); Gson gson = new Gson(); assertNotNull(gson.toJson(result)); Mockito.verify(projectRest.getModelService(), times(0)).getLastModelByProjectId(anyString(), any()); @@ -97,7 +98,7 @@ public class ProjectRestImplTest extends RestTestFunctions { @Test(expected = ObjectNotFoundException.class) public void testGetInvalidMetaData() throws Exception { ProjectRestImpl projectRest = createMockProjectRest(null); - projectRest.getMetaData("unknown_model_id", token.getId()); + projectRest.getProject("unknown_model_id", token.getId()); } @Test @@ -149,10 +150,10 @@ public class ProjectRestImplTest extends RestTestFunctions { } @Test - public void testGetMetaData() throws Exception { + public void testGetProject() throws Exception { try { ProjectRestImpl projectRest = createMockProjectRest("testFiles/model/sample.xml"); - ProjectMetaData result = projectRest.getMetaData("sample", token.getId()); + ProjectMetaData result = projectRest.getProject("sample", token.getId()); Gson gson = new Gson(); assertNotNull(gson.toJson(result)); } catch (Exception e) { @@ -161,6 +162,25 @@ public class ProjectRestImplTest extends RestTestFunctions { } } + @Test + public void testUpdateProject() throws Exception { + try { + ProjectRestImpl projectRest = createMockProjectRest("testFiles/model/sample.xml"); + Map<String,String> disease = new HashMap<>(); + disease.put("type",MiriamType.MESH_2012.name()); + disease.put("resource", "D010300"); + Map<String, Object> data = new HashMap<>(); + data.put("version", "1"); + data.put("name", "test"); + data.put("organism", null); + data.put("disease", disease); + projectRest.updateProject(adminToken.getId(), "sample", data); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testGetProjects() throws Exception { try { @@ -200,7 +220,7 @@ public class ProjectRestImplTest extends RestTestFunctions { public void testGetMetaDataForComplexWithImages() throws Exception { try { ProjectRestImpl projectRest = createMockProjectRest("testFiles/model/complex_model_with_submaps.zip"); - ProjectMetaData result = projectRest.getMetaData("sample", token.getId()); + ProjectMetaData result = projectRest.getProject("sample", token.getId()); Gson gson = new Gson(); assertNotNull(gson.toJson(result)); } catch (Exception e) { diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java index c27eea82cec7b868ef6610e70de715e82a9d7fd6..c52bfa74a3c7490fe458d10b46320e30450d466d 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java @@ -120,7 +120,7 @@ public class CommentService implements ICommentService { try { EmailSender emailSender = new EmailSender(configurationService); - emailSender.sendEmail("New comment appeard in the " + model.getProject().getProjectId(), content, model.getNotifyEmail()); + emailSender.sendEmail("New comment appeard in the " + model.getProject().getProjectId(), content, model.getProject().getNotifyEmail()); } catch (MessagingException e) { logger.error("Problem with sending email.", e); } diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java index 78513655c609304555e06f3ca6582b3cec52fca2..d59ddfb6dce2be3d1ffebc15e10e1ebd427a7439 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java @@ -657,11 +657,11 @@ public class LayoutService implements ILayoutService { String table = prepareTableResult(schemas, new ColorSchemaReader()); content.append(table); + String email = params.getModel().getProject().getNotifyEmail(); if (params.getUser() != null) { // send email to a user who owns the layout emailSender.sendEmail("MapViewer notification", content.toString(), params.getUser()); // send email to the model owner - String email = params.getModel().getNotifyEmail(); if (email != null && !email.equals(params.getUser().getEmail())) { content = new StringBuilder(""); String username = "UNKNOWN"; @@ -672,9 +672,9 @@ public class LayoutService implements ILayoutService { emailSender.sendEmail("MapViewer notification", content.toString(), email); } - } else if (params.getModel().getNotifyEmail() != null) { + } else if (email != null) { // if nobody owns the layout then send it to the model owner - emailSender.sendEmail("MapViewer notification", content.toString(), params.getModel().getNotifyEmail()); + emailSender.sendEmail("MapViewer notification", content.toString(), email); } } diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java index 5afe3aad70e9251264e129b2f4317f7d36f8c435..b419e81a7e085027f9f1e1f09fb0aed89b22ebe6 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java @@ -258,7 +258,6 @@ public class ModelService implements IModelService { */ private void setModel(ModelData model, ProjectView selectedProject) { model.setNotes(selectedProject.getDescription()); - model.setNotifyEmail(selectedProject.getNotifyEmail()); List<Layout> toRemove = new ArrayList<Layout>(); for (Layout layout : model.getLayouts()) { boolean exists = false; 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 9b3a35889a70fa76dcae72c9f9f7d48f7c671c3f..4ed367e981ce3ef02b7f1dfba436b8ecf21e194c 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -315,6 +315,7 @@ public class ProjectService implements IProjectService { project.setProjectId(selectedProject.getProjectId()); project.setName(selectedProject.getProjectName()); project.setVersion(selectedProject.getVersion()); + project.setNotifyEmail(selectedProject.getNotifyEmail()); MiriamData disease = null; MiriamData organism = null; if (selectedProject.getNewDiseaseName() != null && !selectedProject.getNewDiseaseName().isEmpty()) { @@ -439,7 +440,7 @@ public class ProjectService implements IProjectService { } } } - email = originalModel.getNotifyEmail(); + email = project.getNotifyEmail(); } projectDao.delete(project); if (async) { @@ -716,7 +717,7 @@ public class ProjectService implements IProjectService { Model topModel = project.getModels().iterator().next().getModel(); topModel.setZoomLevels(generator.computeZoomLevels(topModel)); topModel.setTileSize(MapGenerator.TILE_SIZE); - topModel.setNotifyEmail(params.getNotifyEmail()); + dbProject.setNotifyEmail(params.getNotifyEmail()); updateProjectStatus(project, ProjectStatus.UPLOADING_TO_DB, 0.0, params); dbUtils.setAutoFlush(false); @@ -1009,7 +1010,7 @@ public class ProjectService implements IProjectService { Logger.getRootLogger().removeAppender(appender); project.addLoggingInfo(appender); updateProjectStatus(project, ProjectStatus.DONE, IProgressUpdater.MAX_PROGRESS, params); - if (originalModel.getNotifyEmail() != null && !originalModel.getNotifyEmail().equals("")) { + if (project.getNotifyEmail() != null && !project.getNotifyEmail().equals("")) { try { sendSuccesfullEmail(originalModel); } catch (MessagingException e) { @@ -1443,7 +1444,7 @@ public class ProjectService implements IProjectService { protected void sendSuccesfullEmail(Model originalModel) throws MessagingException { EmailSender emailSender = new EmailSender(configurationService); StringBuilder content = new StringBuilder("Your map was generated successfully.<br/>"); - emailSender.sendEmail("MapViewer notification", content.toString(), originalModel.getNotifyEmail()); + emailSender.sendEmail("MapViewer notification", content.toString(), originalModel.getProject().getNotifyEmail()); } @Override diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java index 1137ef9a900ee683b9f26055ca6c3834759f0367..45af2c1ff6ed3987c486ab653b79e11a410c7ce6 100644 --- a/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java @@ -55,6 +55,7 @@ public class ProjectViewFactory extends AbstractViewFactory<Project, ProjectView result.setErrors(project.getErrors()); result.setProjectId(project.getProjectId()); result.setProjectName(project.getName()); + result.setNotifyEmail(project.getNotifyEmail()); if (project.getDisease() != null) { result.setProjectDiseaseLink(annotationViewFactory.create(project.getDisease())); result.setNewDiseaseName(project.getDisease().getResource()); @@ -95,7 +96,6 @@ public class ProjectViewFactory extends AbstractViewFactory<Project, ProjectView result.setModelId(model.getId()); result.setDescription(model.getNotes()); result.getLayouts().clear(); - result.setNotifyEmail(model.getNotifyEmail()); for (Layout layout : model.getLayouts()) { LayoutView layoutRow = layoutViewFactory.create(layout); result.addLayout(layoutRow);