Commit f7cfd2de authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '927-add-created-by-column-in-the-admin-panel' into 'master'

Resolve "Add 'Created by' column in the Admin panel"

Closes #927

See merge request minerva/core!913
parents 415845d3 adf3a7eb
Pipeline #13217 passed with stage
in 9 minutes and 44 seconds
......@@ -10,6 +10,8 @@ minerva (14.0.0~beta.0) unstable; urgency=low
"View project" checkbox when editing privileges (#920)
* Small improvement: notification email uses minerva name and id of affected
project (#926)
* Small improvement: information about person who uploaded project is visible
in list of projects (#927)
* Bug fix: work on FF Private Window mode could cause logout or raise an
error on when opening new tab with minerva (#892)
* Bug fix: fetching list of miRnas resulted sometimes in "Internal Server
......
......@@ -127,6 +127,8 @@ MapsAdminPanel.prototype._createProjectTableRow = function () {
title: 'ProjectId'
}, {
title: 'Created'
}, {
title: 'Created by'
}, {
title: 'Name'
}, {
......@@ -141,7 +143,7 @@ MapsAdminPanel.prototype._createProjectTableRow = function () {
title: 'Remove'
}],
columnDefs: [
{"orderable": false, "targets": [6, 7]}
{"orderable": false, "targets": [7, 8]}
]
});
self.bindUserGuiPreference({
......@@ -261,9 +263,13 @@ MapsAdminPanel.prototype.projectToTableRow = function (project, row, user) {
}
row[1] = date;
row[2] = project.getName();
row[3] = disease;
row[4] = organism;
row[5] = status;
row[3] = project.getOwner();
if (row[3] === undefined) {
row[3] = 'N/A';
}
row[4] = disease;
row[5] = organism;
row[6] = status;
var disabledEdit = " disabled ";
var disabledRemove = " disabled ";
......@@ -281,12 +287,12 @@ MapsAdminPanel.prototype.projectToTableRow = function (project, row, user) {
disabledRemove = "";
}
row[6] = "<button name='showEditDialog' data='" + project.getProjectId() + "'" + disabledEdit + "><i class='fa fa-edit' style='font-size:17px'></i></button>";
row[7] = "<button name='showEditDialog' data='" + project.getProjectId() + "'" + disabledEdit + "><i class='fa fa-edit' style='font-size:17px'></i></button>";
if (self.getConfiguration().getOption(ConfigurationType.DEFAULT_MAP).getValue() === projectId) {
disabledRemove = " disabled ";
}
row[7] = "<button name='removeProject' data='" + project.getProjectId() + "'" + disabledRemove + "><i class='fa fa-trash-o' style='font-size:17px'></button>";
row[8] = "<button name='removeProject' data='" + project.getProjectId() + "'" + disabledRemove + "><i class='fa fa-trash-o' style='font-size:17px'></button>";
return row;
};
......
......@@ -70,6 +70,7 @@ Project.prototype.loadFromData = function (data) {
self.setTopOverviewImage(data.topOverviewImage);
self.setDisease(data.disease);
self.setOrganism(data.organism);
self.setOwner(data.owner);
self.setStatus(data.status);
self.setNotifyEmail(data.notifyEmail);
self.setProgress(data.progress);
......@@ -105,6 +106,7 @@ Project.prototype._update = function (data) {
self.setTopOverviewImage(data.getTopOverviewImage());
self.setDisease(data.getDisease());
self.setOrganism(data.getOrganism());
self.setOwner(data.getOwner());
self.setStatus(data.getStatus());
self.setProgress(data.getProgress());
self.setNotifyEmail(data.getNotifyEmail());
......@@ -378,6 +380,22 @@ Project.prototype.setStatus = function (status) {
this._status = status;
};
/**
*
* @returns {string}
*/
Project.prototype.getOwner = function () {
return this._owner;
};
/**
*
* @param {string} owner
*/
Project.prototype.setOwner = function (owner) {
this._owner = owner;
};
/**
*
* @returns {number}
......@@ -603,5 +621,4 @@ Project.prototype.setCreationDate = function (creationDate) {
};
module.exports = Project;
......@@ -21,6 +21,7 @@ import lcsb.mapviewer.model.map.layout.Layout;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.user.User;
@Entity
public class Project implements Serializable {
......@@ -42,6 +43,9 @@ public class Project implements Serializable {
private String version;
@ManyToOne(optional = false)
private User owner;
private String notifyEmail;
private String directory;
......@@ -388,4 +392,12 @@ public class Project implements Serializable {
parseGlyph.setProject(this);
}
public User getOwner() {
return owner;
}
public void setOwner(User owner) {
this.owner = owner;
}
}
alter table project_table add column owner_id integer;
-- match by email
update project_table set owner_id = (select id from user_table where email = notify_email and email<>'' limit 1) where owner_id is null;
-- assign admin owner to project without owner
update project_table set owner_id = (select id from user_table where id in (select user_id from user_privilege_map_table where privilege_id in (select id from privilege_table where type ='IS_ADMIN')) and removed =False limit 1) where owner_id is null;
-- in case there is no admin assign to any user that is not removed (shouldn't happen at all)
update project_table set owner_id = (select id from user_table where removed =False limit 1) where owner_id is null;
......@@ -32,6 +32,8 @@ import lcsb.mapviewer.persist.dao.user.UserDao;
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class PersistTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
public double EPSILON = 1e-6;
......
......@@ -37,6 +37,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
public void testGetProjectByName() throws Exception {
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.evict(project);
......@@ -52,6 +53,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
public void testGetProjectForModelId() throws Exception {
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
Model model = new ModelFullIndexed(null);
project.addModel(model);
......@@ -76,6 +78,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
assertFalse(projectDao.isProjectExistsByName(projectId));
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.evict(project);
......@@ -89,6 +92,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
@Test
public void testCheckEqualityAfterReload() throws Exception {
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.flush();
......@@ -110,6 +114,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
@Test
public void testCheckEqualityAfterReload2() throws Exception {
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Model model = createModel();
project.addModel(model);
......@@ -168,6 +173,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
oi.addLink(oml);
project.addOverviewImage(oi);
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.evict(project);
......@@ -198,6 +204,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
Project project = new Project("test_project_id");
project.addWarning("warning A");
project.addWarning("warning B");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
assertEquals(2, project.getWarnings().size());
projectDao.add(project);
......@@ -226,6 +233,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
@Test
public void testLayoutsInProject() throws Exception {
Project project = new Project("test_porject_id");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Model model = createModel();
project.addModel(model);
projectDao.add(project);
......@@ -252,6 +260,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
public void testGetNextId() throws Exception {
long id = projectDao.getNextId();
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
long id2 = projectDao.getNextId();
......
......@@ -36,6 +36,7 @@ public class CommentDaoTest extends PersistTestFunctions {
projectDao.delete(project);
}
project = new Project();
project.setOwner(user);
project.setProjectId(projectId);
projectDao.add(project);
}
......
......@@ -50,6 +50,7 @@ public class LayoutDaoTest extends PersistTestFunctions {
Project project = new Project("test_project_id");
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
modelDao.evict(model);
......@@ -91,6 +92,7 @@ public class LayoutDaoTest extends PersistTestFunctions {
Project project = new Project("test_project_id");
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
......@@ -174,6 +176,7 @@ public class LayoutDaoTest extends PersistTestFunctions {
Model model = createModel();
Project project = new Project("test_project_id");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.addModel(model);
projectDao.add(project);
......
......@@ -36,6 +36,7 @@ public class ModelDaoTest extends PersistTestFunctions {
}
project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
}
......@@ -273,6 +274,7 @@ public class ModelDaoTest extends PersistTestFunctions {
Model model = createModel();
Project project = new Project("test_project_id");
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
modelDao.evict(model);
......@@ -299,6 +301,7 @@ public class ModelDaoTest extends PersistTestFunctions {
Model model = createModel();
Project project = new Project("test_project_id");
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
modelDao.evict(model);
......
......@@ -13,17 +13,21 @@ import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.field.CodingRegion;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.PersistTestFunctions;
@Rollback(true)
public class AntisenseRnaTest extends PersistTestFunctions {
Logger logger = LogManager.getLogger(AntisenseRnaTest.class);
User admin;
int identifierCounter = 0;
String projectId = "Some_id";
@Before
public void setUp() throws Exception {
admin = userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN);
Project project = projectDao.getProjectByProjectId(projectId);
if (project != null) {
projectDao.delete(project);
......@@ -38,6 +42,7 @@ public class AntisenseRnaTest extends PersistTestFunctions {
public void testAntisenseRnaRegionInDb() throws Exception {
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(admin);
Model model = createModel();
......
......@@ -46,6 +46,7 @@ public class ElementDaoTest extends PersistTestFunctions {
}
project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
}
......
......@@ -40,6 +40,7 @@ public class RnaTest extends PersistTestFunctions {
Model model = createModel();
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.addModel(model);
projectDao.add(project);
projectDao.evict(project);
......
......@@ -105,6 +105,7 @@ public class ProjectRestImpl extends BaseRestImpl {
result.put("warnings", project.getWarnings().size() > 0);
result.put("errors", project.getErrors() != null && !project.getErrors().isEmpty());
result.put("name", project.getName());
result.put("owner", project.getOwner().getLogin());
result.put("projectId", project.getProjectId());
result.put("creationDate", super.prepareDate(project.getCreationDate()));
result.put("mapCanvasType", project.getMapCanvasType());
......
......@@ -47,6 +47,8 @@ import lcsb.mapviewer.services.interfaces.*;
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class RestTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
private static Map<String, Model> models = new HashMap<>();
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
......
......@@ -23,6 +23,7 @@ import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.user.UserDao;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.interfaces.IProjectService;
......@@ -34,12 +35,16 @@ public class ProjectRestImplTest extends RestTestFunctions {
@Autowired
IModelService modelService;
@Autowired
IProjectService projectService;
@Autowired
ProjectDao projectDao;
@Autowired
UserDao userDao;
@Before
public void before() {
_projectRestImpl.setModelService(modelService);
......@@ -66,6 +71,7 @@ public class ProjectRestImplTest extends RestTestFunctions {
String projectId = "test";
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
_projectRestImpl.removeProject(projectId, null);
}
......@@ -105,6 +111,7 @@ public class ProjectRestImplTest extends RestTestFunctions {
String projectId = "Some_id";
String directory1 = _projectRestImpl.computePathForProject(projectId, ".");
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.delete(project);
String directory2 = _projectRestImpl.computePathForProject(projectId, ".");
......@@ -202,6 +209,7 @@ public class ProjectRestImplTest extends RestTestFunctions {
project = new Project();
model = super.getModelForFile(string, true);
project.addModel(model);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.setProjectId(model.getName());
project.addWarning("some warning");
}
......
......@@ -17,6 +17,7 @@ import lcsb.mapviewer.model.map.layout.ColorSchemaType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.user.UserDao;
import lcsb.mapviewer.services.interfaces.IProjectService;
public class OverlayRestImplTest extends RestTestFunctions {
......@@ -27,6 +28,9 @@ public class OverlayRestImplTest extends RestTestFunctions {
@Autowired
ProjectDao projectDao;
@Autowired
UserDao userDao;
@Autowired
IProjectService projectService;
......@@ -96,6 +100,7 @@ public class OverlayRestImplTest extends RestTestFunctions {
private Project createProject(String string, String projectId) throws Exception {
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Model model = super.getModelForFile(string, false);
project.addModel(model);
projectDao.add(project);
......
......@@ -1103,6 +1103,7 @@ public class ProjectService implements IProjectService {
private Project createProjectFromParams(final CreateProjectParams params) {
Project project = new Project(params.getProjectId());
project.setOwner(userDao.getUserByLogin(params.getUser().getLogin()));
project.setName(params.getProjectName());
if (params.getProjectDir() == null) {
logger.warn("Project directory not set");
......
......@@ -40,6 +40,8 @@ import lcsb.mapviewer.services.search.drug.IDrugService;
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class ServiceTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
private static Map<String, Model> models = new HashMap<String, Model>();
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
......
......@@ -35,6 +35,8 @@ public class CommentServiceTest extends ServiceTestFunctions {
projectDao.delete(project);
}
project = new Project();
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.setProjectId(projectId);
model = getModelForFile("testFiles/centeredAnchorInModifier.xml", false);
model.setTileSize(128);
......
Supports Markdown
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