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 9f8111197fd2cd33ea13978d6f9c2592cb258bd4..f178102c82c2212396c9c6cd62316ea05b26ebf7 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java @@ -17,15 +17,12 @@ import lcsb.mapviewer.annotation.services.MiriamConnector; import lcsb.mapviewer.annotation.services.PubmedParser; import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.TaxonomyBackend; -import lcsb.mapviewer.annotation.services.TaxonomySearchException; -import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.commands.CopyCommand; import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -41,10 +38,8 @@ import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.services.search.data.LightAliasView; import lcsb.mapviewer.services.search.data.LightAliasViewFactory; import lcsb.mapviewer.services.search.data.LightReactionView; -import lcsb.mapviewer.services.view.LayoutView; import lcsb.mapviewer.services.view.ModelView; import lcsb.mapviewer.services.view.ModelViewFactory; -import lcsb.mapviewer.services.view.ProjectView; /** * Implementation of the service that manages models. @@ -122,7 +117,8 @@ public class ModelService implements IModelService { private TaxonomyBackend taxonomyBackend; @Override - public Model getLastModelByProjectId(String projectName, String token) throws lcsb.mapviewer.services.SecurityException { + public Model getLastModelByProjectId(String projectName, String token) + throws lcsb.mapviewer.services.SecurityException { if (projectName == null) { return null; } @@ -235,82 +231,6 @@ public class ModelService implements IModelService { logger.debug("Caching finished"); } - @Override - public void updateModel(ModelData model, ProjectView selectedProject) { - - for (Model cachedModel : models.values()) { - if (cachedModel.getId().equals(selectedProject.getModelId())) { - setModel(cachedModel.getModelData(), selectedProject); - } - } - setModel(model, selectedProject); - modelDao.update(model); - } - - /** - * Sets the data from selectedProject into model. - * - * @param model - * destination of the data - * @param selectedProject - * source of the data - */ - private void setModel(ModelData model, ProjectView selectedProject) { - model.setNotes(selectedProject.getDescription()); - List<Layout> toRemove = new ArrayList<Layout>(); - for (Layout layout : model.getLayouts()) { - boolean exists = false; - for (LayoutView row : selectedProject.getLayouts()) { - if (layout.getId() == row.getIdObject()) { - exists = true; - // don't allow client side to edit layouts - // layout.setDirectory(row.getDirectory()); - layout.setTitle(row.getName()); - layout.setDescription(row.getDescription()); - } - } - if (!exists) { - toRemove.add(layout); - } - } - model.getLayouts().removeAll(toRemove); - - MiriamData disease = null; - if (selectedProject.getNewDiseaseName() != null) { - disease = new MiriamData(MiriamType.MESH_2012, selectedProject.getNewDiseaseName()); - } - - try { - if (meshParser.isValidMeshId(disease)) { - model.getProject().setDisease(disease); - } else { - model.getProject().setDisease(null); - selectedProject.setNewDiseaseName(null); - } - } catch (AnnotatorException e) { - logger.warn("Problem with accessing mesh db"); - } - - if (model.getProject() != null) { - MiriamData organism = null; - if (selectedProject.getNewOrganismName() != null && !selectedProject.getNewOrganismName().isEmpty()) { - organism = new MiriamData(MiriamType.TAXONOMY, selectedProject.getNewOrganismName()); - } - - try { - if (taxonomyBackend.getNameForTaxonomy(organism) != null) { - model.getProject().setOrganism(organism); - } else { - model.getProject().setOrganism(null); - } - } catch (TaxonomySearchException e) { - logger.error("Problem with accessing taxonomy db", e); - model.getProject().setOrganism(null); - } - } - - } - @Override public void removeModelFromCache(Model model) { models.remove(model.getProject().getProjectId()); 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 a6713e8be40dbf351ce845634fe18fc958ca44f8..7480e12f91a3308d83bb71813ea2309284ecddbc 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -33,7 +33,6 @@ 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; @@ -106,8 +105,6 @@ import lcsb.mapviewer.services.utils.CreateProjectParams; import lcsb.mapviewer.services.utils.EmailSender; import lcsb.mapviewer.services.utils.InvalidDataMiningInputFile; import lcsb.mapviewer.services.utils.data.BuildInLayout; -import lcsb.mapviewer.services.view.ProjectView; -import lcsb.mapviewer.services.view.ProjectViewFactory; /** * Implementation of the project service. It allows to manage and access project @@ -240,12 +237,6 @@ public class ProjectService implements IProjectService { @Autowired private DbUtils dbUtils; - /** - * Factory object for {@link ProjectView} elements. - */ - @Autowired - private ProjectViewFactory projectViewFactory; - /** * Access point and parser for the online ctd database. */ @@ -300,70 +291,6 @@ public class ProjectService implements IProjectService { return result; } - @Override - public List<ProjectView> getAllProjectViews(String token) throws SecurityException { - List<ProjectView> result = new ArrayList<>(); - List<Project> projects = getAllProjects(token); - for (Project project : projects) { - result.add(projectViewFactory.create(project)); - } - return result; - } - - @Override - public void updateProject(ProjectView selectedProject) { - Project project = projectDao.getById(selectedProject.getIdObject()); - 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()) { - disease = new MiriamData(MiriamType.MESH_2012, selectedProject.getNewDiseaseName()); - } - if (selectedProject.getNewOrganismName() != null && !selectedProject.getNewOrganismName().isEmpty()) { - organism = new MiriamData(MiriamType.TAXONOMY, selectedProject.getNewOrganismName()); - } - try { - if (meshParser.isValidMeshId(disease)) { - project.setDisease(disease); - } else { - project.setDisease(null); - selectedProject.setNewDiseaseName(null); - } - } catch (AnnotatorException e) { - logger.error("Problem with accessing mesh", e); - project.setDisease(null); - selectedProject.setNewDiseaseName(null); - } - try { - if (taxonomyBackend.getNameForTaxonomy(organism) != null) { - project.setOrganism(organism); - } else { - project.setOrganism(null); - selectedProject.setNewOrganismName(null); - } - } catch (TaxonomySearchException e) { - logger.error("Problem with accessing taxonomy db", e); - project.setOrganism(null); - selectedProject.setNewOrganismName(null); - } - for (ModelData model : project.getModels()) { - if (model.getId().equals(selectedProject.getModelId())) { - modelService.updateModel(model, selectedProject); - } - } - projectDao.update(project); - } - - @Override - public void removeProject(ProjectView selectedProject, String homeDir, boolean async, String token) - throws SecurityException { - Project project = projectDao.getById(selectedProject.getIdObject()); - removeProject(project, homeDir, async, token); - } - /** * Removes all types of privileges from every user to the project given in the * parameter. @@ -379,12 +306,6 @@ public class ProjectService implements IProjectService { } } - @Override - public ProjectView getProjectViewByProjectId(String name, String token) throws SecurityException { - Project project = getProjectByProjectId(name, token); - return projectViewFactory.create(project); - } - @Override public void removeProject(final Project p, final String dir, final boolean async, String token) throws SecurityException { @@ -538,18 +459,6 @@ public class ProjectService implements IProjectService { } - @Override - public ProjectView getProjectViewById(Integer id, String token) throws SecurityException { - Project project = projectDao.getById(id); - if (userService.userHasPrivilege(token, PrivilegeType.VIEW_PROJECT, project)) { - return projectViewFactory.create(project); - } else if (userService.userHasPrivilege(token, PrivilegeType.ADD_MAP)) { - return projectViewFactory.create(project); - } else { - throw new UserAccessException("User cannot access project"); - } - } - /** * This methods add privileges for the users listed in params to the project. * @@ -1277,11 +1186,6 @@ public class ProjectService implements IProjectService { this.dataMiningService = dataMiningService; } - @Override - public ProjectView createEmpty() { - return projectViewFactory.create(null); - } - /** * Analyzes annotation of the model and put information about invalid * annotations into the {@link Model#creationWarnings} field. @@ -1559,30 +1463,6 @@ public class ProjectService implements IProjectService { } - @Override - public byte[] getInputDataForProject(ProjectView projectView) { - return getInputDataForProject(projectView.getIdObject()); - } - - /** - * Returns byte array containing data from original input file that was used to - * create this project. - * - * @param projectId - * identifier of project for which we want to retrieve original file - * data - * @return original data file for given layout, if such file is not stored in - * database (compatibility reasons) then null is returned - */ - private byte[] getInputDataForProject(int projectId) { - Project project = projectDao.getById(projectId); - if (project == null || project.getInputData() == null) { - return null; - } else { - return project.getInputData().getFileContent(); - } - } - /** * Method that handles exception reporting during creation of a project. * diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java index 57495869e7ca7959078d9ee7cc9ba1d7148c1ab4..b7ad235241bf8dc8bc86681091e0b4f0d4273bd0 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java @@ -11,7 +11,6 @@ import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.search.data.LightAliasView; import lcsb.mapviewer.services.search.data.LightReactionView; import lcsb.mapviewer.services.view.ModelView; -import lcsb.mapviewer.services.view.ProjectView; /** * Service that manages models (maps). @@ -28,7 +27,7 @@ public interface IModelService { * @param projectId * {@link lcsb.mapviewer.model.Project#projectId project identifier} * @return the newest model for the project - * @throws SecurityException + * @throws SecurityException */ Model getLastModelByProjectId(String projectId, String token) throws SecurityException; @@ -42,16 +41,6 @@ public interface IModelService { */ void cacheAllPubmedIds(Model model, IProgressUpdater updater); - /** - * Updates information in the model with the one taken from selectedProject. - * - * @param model - * model to update - * @param selectedProject - * source of data that should be used in the update - */ - void updateModel(ModelData model, ProjectView selectedProject); - /** * Removes model from application cache. * diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java index aaf3bbf5d8a6a7a3a0e14a322ab9fe79a526c020..d3a236cfb7fe828b643bc1689cb1c2bb4328d6eb 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java @@ -11,7 +11,6 @@ import lcsb.mapviewer.model.user.UserAnnotatorsParam; import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.UserAccessException; import lcsb.mapviewer.services.utils.CreateProjectParams; -import lcsb.mapviewer.services.view.ProjectView; /** * Service that manages projects. @@ -28,7 +27,7 @@ public interface IProjectService { * {@link Project#projectId project identifier} * @return project with an identifier given as parameter. Null if such project * doesn't exist. - * @throws SecurityException + * @throws SecurityException */ Project getProjectByProjectId(String projectId, String token) throws UserAccessException, SecurityException; @@ -46,39 +45,9 @@ public interface IProjectService { * Returns list of all projects. * * @return list of all projects. - * @throws SecurityException - */ - List<Project> getAllProjects(String token) throws SecurityException; - - /** - * Returns a list of Project views for all projects. - * - * @return list of Project views for all projects - * @throws SecurityException - */ - List<ProjectView> getAllProjectViews(String token) throws SecurityException; - - /** - * Updates project. - * - * @param projectView - * project view with the data to update - */ - void updateProject(ProjectView projectView); - - /** - * Removes project from the system. - * - * @param homeDir - * directory where the system is deployed - * - * @param projectView - * information about project to remove - * @param async - * should the operation be done asynchronously * @throws SecurityException */ - void removeProject(ProjectView projectView, String homeDir, boolean async, String token) throws SecurityException; + List<Project> getAllProjects(String token) throws SecurityException; /** * Removes project from the system. @@ -93,17 +62,6 @@ public interface IProjectService { */ void removeProject(Project project, String homeDir, boolean async, String token) throws SecurityException; - /** - * Gets view of the project by the {@link Project#projectId project identifier}. - * - * @param projectId - * {@link Project#projectId project identifier} - * @return view of the project - * @throws UserAccessException - * @throws SecurityException - */ - ProjectView getProjectViewByProjectId(String projectId, String token) throws UserAccessException, SecurityException; - /** * Adds project to the system. * @@ -112,17 +70,6 @@ public interface IProjectService { */ void addProject(Project project); - /** - * Return the view of the project identified by database identifier. - * - * @param id - * database identifier of the project - * @return project view - * @throws UserAccessException - * @throws SecurityException - */ - ProjectView getProjectViewById(Integer id, String token) throws UserAccessException, SecurityException; - /** * Creates project using give parameters. See {@link CreateProjectParams}. * @@ -132,13 +79,6 @@ public interface IProjectService { */ void createProject(CreateProjectParams params) throws SecurityException; - /** - * Creates empty {@link ProjectView}. - * - * @return empty {@link ProjectView} - */ - ProjectView createEmpty(); - /** * Creates {@link TreeNode} that contains information about all classes that can * be annotated and associate set of @@ -157,7 +97,7 @@ public interface IProjectService { * given user and default params used when creating project. * * @param user - * user for which we updte information + * user for which we update information * @param sbgnFormat * new * {@link lcsb.mapviewer.model.user.UserAnnotationSchema#sbgnFormat} @@ -181,18 +121,6 @@ public interface IProjectService { */ void updateProject(Project project); - /** - * Returns content of the file that was used to create project given in the - * parameter. - * - * @param projectView - * view of the {@link Project} for which we are looking for an original - * source file - * @return content of the file that was used to create project given in the - * parameter - */ - byte[] getInputDataForProject(ProjectView projectView); - UserAnnotationSchema prepareUserAnnotationSchema(User user); /** diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ProjectView.java b/service/src/main/java/lcsb/mapviewer/services/view/ProjectView.java deleted file mode 100644 index 6e1ed975ea37398c6e56a39020d759674f3932f2..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ProjectView.java +++ /dev/null @@ -1,527 +0,0 @@ -package lcsb.mapviewer.services.view; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import lcsb.mapviewer.common.comparator.IntegerComparator; -import lcsb.mapviewer.model.Project; - -/** - * This class is a client view that represents {@link Project} class. Right now - * this class highly entangles {@link Project} and - * {@link lcsb.mapviewer.model.map.model.db.model.map.Model Model}. In the - * future it should separate it. - * - * @author Piotr Gawron - * - */ -public class ProjectView extends AbstractView<Project> implements Comparable<ProjectView>, Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Identifier of the model that is represented in this project view (this must - * be refactorized in the future). - */ - private Integer modelId; - - /** - * List of layouts in the model (identified by {@link #modelId}). - */ - private List<LayoutView> layouts = new ArrayList<LayoutView>(); - - /** - * {@link Project#projectId Identifier} of the project. - */ - private String projectId; - - /** - * {@link Project#name Name} of the project. - */ - private String projectName; - - /** - * {@link Project#name newDiseaseName} of the project. - */ - private String newDiseaseName; - - /** - * {@link Project#organism newOrganismName} of the project. - */ - private String newOrganismName; - - /** - * {@link Project#disease Disease} of the project. - */ - private AnnotationView projectDiseaseLink; - - /** - * {@link Project#disease Disease name} of the project. - */ - private String diseaseName = "N/A"; - - /** - * {@link Project#organism Organism} of the project. - */ - private AnnotationView organismLink; - - /** - * Email used for notification obut the events connected to this project. - */ - private String notifyEmail; - - /** - * Status of the project processing. - */ - private String status; - - /** - * Errors that appeard in the project. - */ - private String errors; - - /** - * Progress of the project processng (value between 0..100). - */ - private Integer progress; - - /** - * Short list of warnings that appeard during model creation. - */ - private String warningsPreview; - - /** - * List of warnings that appeard during model creation. - */ - private List<String> warnings; - - /** - * Description of the model. - */ - private String description; - /** - * Version of the model. - */ - private String version; - - /** - * "true" if input file from which project was created is available, "false" - * otherwise. - */ - private String inputDataAvailable; - - /** - * List of data mining sets used to gernerate suggested connections. - */ - private List<DataMiningSetView> dataMiningSets = new ArrayList<DataMiningSetView>(); - - /** - * Default constructor. - * - * @param project - * {@link Project} for which this view is created - */ - protected ProjectView(Project project) { - super(project); - } - - /** - * Default constructor. Should be used only for deserialization. - */ - protected ProjectView() { - } - - /** - * Constructor that creates copy of the {@link ProjectView}. - * - * @param row - * original object - */ - public ProjectView(ProjectView row) { - super(null); - setIdObject(row.getIdObject()); - modelId = row.getModelId(); - layouts.addAll(row.getLayouts()); - projectId = row.getProjectId(); - projectName = row.getProjectName(); - newDiseaseName = row.getNewDiseaseName(); - newOrganismName = row.getNewOrganismName(); - projectDiseaseLink = row.getProjectDiseaseLink(); - organismLink = row.getOrganismLink(); - notifyEmail = row.getNotifyEmail(); - status = row.getStatus(); - progress = row.getProgress(); - description = row.getDescription(); - version = row.getVersion(); - errors = row.getErrors(); - warningsPreview = row.getWarningsPreview(); - warnings = row.getWarnings(); - for (DataMiningSetView view : row.getDataMiningSets()) { - dataMiningSets.add(new DataMiningSetView(view)); - } - inputDataAvailable = row.getInputDataAvailable(); - } - - @Override - public int compareTo(ProjectView o) { - if (o == null) { - new IntegerComparator().compare(getIdObject(), null); - } - return new IntegerComparator().compare(getIdObject(), o.getIdObject()); - } - - /** - * @return the modelId - * @see #modelId - */ - public Integer getModelId() { - return modelId; - } - - /** - * @param modelId - * the modelId to set - * @see #modelId - */ - public void setModelId(Integer modelId) { - this.modelId = modelId; - } - - /** - * @return the layouts - * @see #layouts - */ - public List<LayoutView> getLayouts() { - return layouts; - } - - /** - * @param layouts - * the layouts to set - * @see #layouts - */ - public void setLayouts(List<LayoutView> layouts) { - this.layouts = layouts; - } - - /** - * @return the name - * @see #projectId - */ - public String getProjectId() { - return projectId; - } - - /** - * @param projectId - * project identifier - * @see #projectId - */ - public void setProjectId(String projectId) { - this.projectId = projectId; - } - - /** - * @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 status - * @see #status - */ - public String getStatus() { - return status; - } - - /** - * @param status - * the status to set - * @see #status - */ - public void setStatus(String status) { - this.status = status; - } - - /** - * @return the progress - * @see #progress - */ - public Integer getProgress() { - return progress; - } - - /** - * @param progress - * the progress to set - * @see #progress - */ - public void setProgress(Integer progress) { - this.progress = progress; - } - - /** - * @return the description - * @see #description - */ - public String getDescription() { - return description; - } - - /** - * @param description - * the description to set - * @see #description - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the version - * @see #version - */ - public String getVersion() { - return version; - } - - /** - * @param version - * the version to set - * @see #version - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Adds layout to the view. - * - * @param row - * layout to add - */ - public void addLayout(LayoutView row) { - layouts.add(row); - } - - /** - * @return the warnings - * @see #warnings - */ - public List<String> getWarnings() { - return warnings; - } - - /** - * @param warnings - * the warnings to set - * @see #warnings - */ - public void setWarnings(List<String> warnings) { - this.warnings = warnings; - } - - /** - * @return the errors - * @see #errors - */ - public String getErrors() { - return errors; - } - - /** - * @param errors - * the errors to set - * @see #errors - */ - public void setErrors(String errors) { - this.errors = errors; - } - - /** - * @return the dataMiningSets - * @see #dataMiningSets - */ - public List<DataMiningSetView> getDataMiningSets() { - return dataMiningSets; - } - - /** - * @param dataMiningSets - * the dataMiningSets to set - * @see #dataMiningSets - */ - public void setDataMiningSets(List<DataMiningSetView> dataMiningSets) { - this.dataMiningSets = dataMiningSets; - } - - /** - * Adds {@link DataMiningSetView} to {@link #dataMiningSets}. - * - * @param dataMiningSetView - * object to add - */ - public void addDataMiningSet(DataMiningSetView dataMiningSetView) { - dataMiningSets.add(dataMiningSetView); - } - - /** - * @return the projectName - * @see #projectName - */ - public String getProjectName() { - return projectName; - } - - /** - * @param projectName - * the projectName to set - * @see #projectName - */ - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - /** - * @return project disease link - */ - public AnnotationView getProjectDiseaseLink() { - return projectDiseaseLink; - } - - /** - * @param projectDiseaseLink - * the link for the disease. - */ - public void setProjectDiseaseLink(AnnotationView projectDiseaseLink) { - this.projectDiseaseLink = projectDiseaseLink; - } - - /** - * @return this is used to update or add different disease association. - */ - public String getNewDiseaseName() { - return newDiseaseName; - } - - /** - * @param newDiseaseName - * this is used to update or add different disease association. - */ - public void setNewDiseaseName(String newDiseaseName) { - this.newDiseaseName = newDiseaseName; - } - - /** - * @return the diseaseName - * @see #diseaseName - */ - public String getDiseaseName() { - return diseaseName; - } - - /** - * @param diseaseName - * the diseaseName to set - * @see #diseaseName - */ - public void setDiseaseName(String diseaseName) { - this.diseaseName = diseaseName; - } - - /** - * @return the inputDataAvailable - * @see #inputDataAvailable - */ - public String getInputDataAvailable() { - return inputDataAvailable; - } - - /** - * @param inputDataAvailable - * the inputDataAvailable to set - * @see #inputDataAvailable - */ - public void setInputDataAvailable(String inputDataAvailable) { - this.inputDataAvailable = inputDataAvailable; - } - - /** - * @param value - * the inputDataAvailable to set - * @see #inputDataAvailable - */ - public void setInputDataAvailable(boolean value) { - if (value) { - this.inputDataAvailable = "true"; - } else { - this.inputDataAvailable = "false"; - } - - } - - /** - * @return the organismLink - * @see #organismLink - */ - public AnnotationView getOrganismLink() { - return organismLink; - } - - /** - * @param organismLink the organismLink to set - * @see #organismLink - */ - public void setOrganismLink(AnnotationView organismLink) { - this.organismLink = organismLink; - } - - /** - * @return the newOrganismName - * @see #newOrganismName - */ - public String getNewOrganismName() { - return newOrganismName; - } - - /** - * @param newOrganismName the newOrganismName to set - * @see #newOrganismName - */ - public void setNewOrganismName(String newOrganismName) { - this.newOrganismName = newOrganismName; - } - - /** - * @return the warningsPreview - * @see #warningsPreview - */ - public String getWarningsPreview() { - return warningsPreview; - } - - /** - * @param warningsPreview the warningsPreview to set - * @see #warningsPreview - */ - public void setWarningsPreview(String warningsPreview) { - this.warningsPreview = warningsPreview; - } - -} diff --git a/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java deleted file mode 100644 index 45af2c1ff6ed3987c486ab653b79e11a410c7ce6..0000000000000000000000000000000000000000 --- a/service/src/main/java/lcsb/mapviewer/services/view/ProjectViewFactory.java +++ /dev/null @@ -1,119 +0,0 @@ -package lcsb.mapviewer.services.view; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -import com.google.gson.Gson; - -import lcsb.mapviewer.annotation.data.MeSH; -import lcsb.mapviewer.annotation.services.MeSHParser; -import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.graph.DataMiningSet; -import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.model.ModelData; - -/** - * Factory class for {@link ProjectView} class. - * - * @author Piotr Gawron - * - */ -public class ProjectViewFactory extends AbstractViewFactory<Project, ProjectView> { - - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(ProjectViewFactory.class); - - /** - * Factory object for {@link LayoutView} elements. - */ - @Autowired - private LayoutViewFactory layoutViewFactory; - - /** - * Factory object used for creation of {@link AnnotationView} elements. - */ - @Autowired - private AnnotationViewFactory annotationViewFactory; - - /** - * Access object for information about mesh terms. - */ - @Autowired - private MeSHParser meSHParser; - - @Override - public ProjectView create(Project project) { - ProjectView result = new ProjectView(project); - if (project == null) { - return result; - } - result.setIdObject(project.getId()); - 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()); - MeSH mesh; - try { - mesh = meSHParser.getMeSH(project.getDisease()); - if (mesh != null) { - result.setDiseaseName(mesh.getName()); - } - } catch (AnnotatorException e) { - logger.error("Problem with getting info about mesh entry: ", e); - } - } - - if (project.getOrganism() != null) { - result.setOrganismLink(annotationViewFactory.create(project.getOrganism())); - result.setNewOrganismName(project.getOrganism().getResource()); - } - result.setStatus(project.getStatus().toString()); - result.setProgress(Integer.valueOf((int) project.getProgress())); - result.setInputDataAvailable(project.getInputData() != null); - - int warnCount = 0; - String warnPreview = ""; - for (String w : project.getWarnings()) { - if (!"".equals(w)) { - if (warnCount <= 2) { - warnPreview += w + "\n"; - } - warnCount++; - } - } - result.setWarningsPreview(warnPreview); - result.setWarnings(project.getWarnings()); - result.setVersion(project.getVersion()); - - for (ModelData model : project.getModels()) { - result.setModelId(model.getId()); - result.setDescription(model.getNotes()); - result.getLayouts().clear(); - for (Layout layout : model.getLayouts()) { - LayoutView layoutRow = layoutViewFactory.create(layout); - result.addLayout(layoutRow); - } - for (DataMiningSet dms : model.getDataMiningSets()) { - result.addDataMiningSet(new DataMiningSetView(dms)); - } - } - return result; - } - - @Override - public String createGson(ProjectView object) { - return new Gson().toJson(object); - } - - @Override - public Project viewToObject(ProjectView view) { - throw new NotImplementedException(); - } -} diff --git a/service/src/main/resources/applicationContext-service.xml b/service/src/main/resources/applicationContext-service.xml index 60ec25e5948ca31698356a57255cffa06f6c6769..ec3ec8712ac02f1c945688271fe435ddb9ed8953 100644 --- a/service/src/main/resources/applicationContext-service.xml +++ b/service/src/main/resources/applicationContext-service.xml @@ -56,7 +56,6 @@ <bean id="OverviewImageViewFactory" class="lcsb.mapviewer.services.view.OverviewImageViewFactory"/> <bean id="OverviewLinkViewFactory" class="lcsb.mapviewer.services.view.OverviewLinkViewFactory"/> <bean id="PrivilegeViewFactory" class="lcsb.mapviewer.services.view.PrivilegeViewFactory"/> - <bean id="ProjectViewFactory" class="lcsb.mapviewer.services.view.ProjectViewFactory"/> <bean id="ReferenceGenomeViewFactory" class="lcsb.mapviewer.services.view.ReferenceGenomeViewFactory"/> <bean id="ReferenceGenomeGeneMappingViewFactory" class="lcsb.mapviewer.services.view.ReferenceGenomeGeneMappingViewFactory"/> diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java index 11cc1b98006d3ffbf892157e35d3f2b6fef8575d..48edf8414c4f3f97df236f1d36ae76c115d4ca5d 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java @@ -1,10 +1,8 @@ package lcsb.mapviewer.services.impl; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -18,16 +16,11 @@ import org.springframework.test.annotation.Rollback; import lcsb.mapviewer.annotation.services.PubmedParser; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.graphics.MapGenerator; -import lcsb.mapviewer.converter.graphics.MapGenerator.MapGeneratorParams; -import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.search.data.LightAliasView; -import lcsb.mapviewer.services.view.ProjectView; @Rollback(true) public class ModelServiceTest extends ServiceTestFunctions { @@ -46,39 +39,6 @@ public class ModelServiceTest extends ServiceTestFunctions { public void tearDown() throws Exception { } - @Test - public void testRemoveModel() throws Exception { - try { - String directory = "test_directory"; - String projectId = "Some_id"; - Project project = new Project(); - project.setProjectId(projectId); - projectDao.add(project); - - Model model = getModelForFile("testFiles/sample.xml", false); - model.addLayout(new Layout("test", directory, false)); - - project.addModel(model); - projectDao.update(project); - - MapGenerator generator = new MapGenerator(); - MapGeneratorParams params = generator.new MapGeneratorParams().model(model).directory(directory); - generator.generateMapImages(params); - - String adminToken = userService.login("admin", "admin"); - ProjectView row = projectService.getProjectViewByProjectId(project.getProjectId(), adminToken); - projectService.removeProject(row, null, false, adminToken); - - File file = new File(directory); - assertFalse(file.exists()); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - @Test public void testGetAliasByIds() throws Exception { try { @@ -138,28 +98,4 @@ public class ModelServiceTest extends ServiceTestFunctions { } - @Test - public void testAddModel() throws Exception { - try { - String projectId = "Some_id"; - Project project = new Project(); - project.setProjectId(projectId); - projectDao.add(project); - - Model model = getModelForFile("testFiles/db_problem_model.xml", false); - - project.addModel(model); - projectDao.update(project); - - String adminToken = userService.login("admin", "admin"); - ProjectView row = projectService.getProjectViewByProjectId(project.getProjectId(), adminToken); - projectService.removeProject(row, null, false, adminToken); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - } diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java index de1196579ef6b56fe915a0cab70fa3b7d88b069a..a2df3103ff7b7ddb87c133e239c1777945e42e6f 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java @@ -43,9 +43,7 @@ import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.model.SubmodelType; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Protein; -import lcsb.mapviewer.model.user.ObjectPrivilege; import lcsb.mapviewer.model.user.PrivilegeType; -import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.model.user.UserAnnotationSchema; import lcsb.mapviewer.model.user.UserClassAnnotators; import lcsb.mapviewer.model.user.UserClassValidAnnotations; @@ -56,7 +54,6 @@ import lcsb.mapviewer.services.overlay.AnnotatedObjectTreeRow; import lcsb.mapviewer.services.utils.CreateProjectParams; import lcsb.mapviewer.services.utils.data.BuildInLayout; import lcsb.mapviewer.services.view.ConfigurationView; -import lcsb.mapviewer.services.view.ProjectView; @Rollback(true) public class ProjectServiceTest extends ServiceTestFunctions { @@ -128,100 +125,6 @@ public class ProjectServiceTest extends ServiceTestFunctions { } } - @Test - public void testRemove() throws Exception { - - try { - String project_id = "Some_id"; - Project project = new Project(); - project.setProjectId(project_id); - projectDao.add(project); - - List<ProjectView> projects2 = projectService.getAllProjectViews(adminToken); - ProjectView row = null; - for (ProjectView projectRow : projects2) { - if (projectRow.getIdObject() == project.getId()) { - row = projectRow; - } - } - assertNotNull(row); - - User user = new User(); - user.setLogin("x"); - userDao.add(user); - userDao.evict(user); - - int userId = user.getId(); - - user = userService.getUserById(userId); - - userDao.evict(user); - - userService.setUserPrivilege(user, new ObjectPrivilege(project, 1, PrivilegeType.VIEW_PROJECT, user)); - - user = userService.getUserById(userId); - int newAmount = user.getPrivileges().size(); - - userDao.evict(user); - - projectService.removeProject(row, tmpResultDir, false, adminToken); - - user = userService.getUserById(userId); - - assertEquals("After removing project number of privileges didn't drop down", newAmount - 1, - user.getPrivileges().size()); - - userDao.delete(user); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testRemoveUserAfterRemoveProject() throws Exception { - - try { - String projectId = "Some_id"; - Project project = new Project(); - project.setProjectId(projectId); - projectDao.add(project); - - List<ProjectView> projects2 = projectService.getAllProjectViews(adminToken); - ProjectView row = null; - for (ProjectView projectRow : projects2) { - if (projectRow.getIdObject() == project.getId()) { - row = projectRow; - } - } - assertNotNull(row); - - User user = new User(); - user.setLogin("x"); - userDao.add(user); - userDao.evict(user); - - int userId = user.getId(); - - userService.setUserPrivilege(user, new ObjectPrivilege(project, 1, PrivilegeType.VIEW_PROJECT, user)); - - user = userService.getUserById(userId); - - long counter = logDao.getCount(); - projectService.removeProject(row, tmpResultDir, false, adminToken); - long counter2 = logDao.getCount(); - assertTrue("Logs didn't appear after removing project", counter < counter2); - - user = userService.getUserById(userId); - userDao.delete(user); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - @Test public void testUpdater() throws Exception { try { diff --git a/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java b/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java index 476938b1524e2b45bdb3e28cddc22d9f3bf50d86..be2f29b80a9c1fc059038d4bed018bb4a143d32f 100644 --- a/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java +++ b/service/src/test/java/lcsb/mapviewer/services/view/AllViewTests.java @@ -25,8 +25,6 @@ import org.junit.runners.Suite.SuiteClasses; OverviewLinkViewTest.class, // PrivilegeViewFactoryTest.class, // PrivilegeViewTest.class, // - ProjectViewFactoryTest.class, // - ProjectViewTest.class, // ReferenceGenomeViewFactoryTest.class, // ReferenceGenomeGeneMappingViewFactoryTest.class, // }) diff --git a/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewFactoryTest.java deleted file mode 100644 index 6a7665d94aabd0e1eb97703d2f9835a90705c36d..0000000000000000000000000000000000000000 --- a/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewFactoryTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package lcsb.mapviewer.services.view; - -import static org.junit.Assert.*; -import lcsb.mapviewer.services.ServiceTestFunctions; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class ProjectViewFactoryTest extends ServiceTestFunctions{ - - @Autowired - ProjectViewFactory projectViewFactory; - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testCreateEmpty() throws Exception { - try { - Object object = projectViewFactory.create(null); - assertNotNull(object); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCreateGson() throws Exception { - try { - ProjectView object = projectViewFactory.create(null); - assertNotNull(projectViewFactory.createGson(object)); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} diff --git a/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewTest.java b/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewTest.java deleted file mode 100644 index 6af4866b3afc03fc07e0ca53d8ab2d61d7c8eaf9..0000000000000000000000000000000000000000 --- a/service/src/test/java/lcsb/mapviewer/services/view/ProjectViewTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package lcsb.mapviewer.services.view; - -import org.apache.commons.lang3.SerializationUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ProjectViewTest { - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new ProjectView()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } -}