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

issue #12 PrivilegeType in db is mapped by privilege name not id of enum

parent cff9d812
......@@ -7,6 +7,8 @@ import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
......@@ -52,6 +54,7 @@ public class BasicPrivilege implements Serializable {
/**
* Type of the privilege.
*/
@Enumerated(EnumType.STRING)
private PrivilegeType type;
/**
......
......@@ -3,3 +3,20 @@ alter table project_table add column sbgnformat boolean default false ;
update project_table set sbgnformat = (select sbgnformat from model_table where project_iddb = project_table.iddb);
alter table model_table drop column sbgnformat;
--PrivilegeType should be mapped in database by name not by index
alter table privilege_table add column type_string character varying;
update privilege_table set type_string = 'VIEW_PROJECT' where type = 0;
update privilege_table set type_string = 'ADD_MAP' where type = 1;
update privilege_table set type_string = 'EDIT_MISSING_CONNECTIONS_PROJECT' where type = 2;
update privilege_table set type_string = 'EDIT_COMMENTS_PROJECT' where type = 3;
update privilege_table set type_string = 'DRUG_TARGETING_ADVANCED_VIEW_PROJECT' where type = 4;
update privilege_table set type_string = 'PROJECT_MANAGEMENT' where type = 5;
update privilege_table set type_string = 'USER_MANAGEMENT' where type = 6;
update privilege_table set type_string = 'CUSTOM_LAYOUTS' where type = 7;
update privilege_table set type_string = 'LAYOUT_VIEW' where type = 8;
update privilege_table set type_string = 'CONFIGURATION_MANAGE' where type = 9;
update privilege_table set type_string = 'LAYOUT_MANAGEMENT' where type = 10;
update privilege_table set type_string = 'MANAGE_GENOMES' where type = 11;
alter table privilege_table drop column type;
alter table privilege_table rename type_string TO type;
......@@ -20,6 +20,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.user.BasicPrivilege;
import lcsb.mapviewer.model.user.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.model.user.UserAnnotationSchema;
import lcsb.mapviewer.model.user.UserClassAnnotators;
......@@ -61,6 +63,7 @@ public class UserDaoTest extends PersistTestFunctions {
user = new User();
user.setLogin(testLogin);
user.addPrivilege(new BasicPrivilege(0, PrivilegeType.ADD_MAP, user));
userDao.add(user);
long counter2 = userDao.getCount();
......@@ -81,7 +84,7 @@ public class UserDaoTest extends PersistTestFunctions {
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception occured");
throw e;
}
}
......
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