diff --git a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java index 3e66cfbe5eed1e6e6f74c16e8e36aaf9f9796159..de2f67f108b60edd9b9e318782940e0a6d32a508 100644 --- a/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java +++ b/model/src/main/java/lcsb/mapviewer/model/user/UserAnnotatorsParam.java @@ -10,7 +10,6 @@ import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; - /** * This class defines set of annotators parameters that are used by a user. * @@ -21,146 +20,146 @@ import javax.persistence.Table; @Table(name = "annotators_params_table") public class UserAnnotatorsParam implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Unique identifier in the database. - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(unique = true, nullable = false) - private Integer id; - - /** - * {@link UserAnnotationSchema} that defines which user is using this set of - * annotators. - */ - @ManyToOne - private UserAnnotationSchema annotationSchema; - - - /** - * Class name of the annotator {@link #paramName parameter} of which is being set to the {@link #paramValue value}. - */ - @Column(name = "annotator_classname", nullable = false) - private Class<?> annotatorClassName; - - /** - * Parameter name to be set. - */ - @Column(name = "name", nullable = false) - private String paramName; - - /** - * Parameter value to be set. - */ - @Column(name = "value", nullable = false) - private String paramValue; - - /** - * Default constructor. - */ - public UserAnnotatorsParam() { - - } - - /** - * Default constructor. - * - * @param objectClass - * {@link #className} - * @param annotators - * {@link #annotators} - */ - public UserAnnotatorsParam(Class<?> annotatorClassName, String paramName, String paramValue) { - setAnnotatorClassName(annotatorClassName); - setParamName(paramName); - setParamValue(paramValue); - } - - /** - * @return the id - * @see #id - */ - public Integer getId() { - return id; - } - - /** - * @param id - * the id to set - * @see #id - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * @return the annotationSchema - * @see #annotationSchema - */ - public UserAnnotationSchema getAnnotationSchema() { - return annotationSchema; - } - - /** - * @param annotationSchema - * the annotationSchema to set - * @see #annotationSchema - */ - public void setAnnotationSchema(UserAnnotationSchema annotationSchema) { - this.annotationSchema = annotationSchema; - } - - /** - * @return the className - * @see #className - */ - public Class<?> getAnnotatorClassName() { - return annotatorClassName; - } - - /** - * @param className - * the className to set - * @see #className - */ - public void setAnnotatorClassName(Class<?> annotatorClassName) { - this.annotatorClassName = annotatorClassName; - } - - /** - * @return the parameter name - * @see #paramName - */ - public String getParamName() { - return paramName; - } - - /** - * @param paramName - * the {@link UserAnnotatorsParam#paramName} to set - */ - public void setParamName(String paramName) { - this.paramName = paramName; - } - - /** - * @return the parameter value - * @see #paramValue - */ - public String getParamValue() { - return paramValue; - } - - /** - * @param parameter value - * the {@link UserAnnotatorsParam#paramValue} to set - */ - public void setParamValue(String paramValue) { - this.paramValue = paramValue; - } + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier in the database. + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(unique = true, nullable = false) + private Integer id; + + /** + * {@link UserAnnotationSchema} that defines which user is using this set of + * annotators. + */ + @ManyToOne + private UserAnnotationSchema annotationSchema; + + /** + * Class name of the annotator {@link #paramName parameter} of which is being + * set to the {@link #paramValue value}. + */ + @Column(nullable = false) + private Class<?> annotatorClassName; + + /** + * Parameter name to be set. + */ + @Column(nullable = false) + private String paramName; + + /** + * Parameter value to be set. + */ + @Column(nullable = false) + private String paramValue; + + /** + * Default constructor. + */ + public UserAnnotatorsParam() { + + } + + /** + * Default constructor. + * + * @param objectClass + * {@link #className} + * @param annotators + * {@link #annotators} + */ + public UserAnnotatorsParam(Class<?> annotatorClassName, String paramName, String paramValue) { + setAnnotatorClassName(annotatorClassName); + setParamName(paramName); + setParamValue(paramValue); + } + + /** + * @return the id + * @see #id + */ + public Integer getId() { + return id; + } + + /** + * @param id + * the id to set + * @see #id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return the annotationSchema + * @see #annotationSchema + */ + public UserAnnotationSchema getAnnotationSchema() { + return annotationSchema; + } + + /** + * @param annotationSchema + * the annotationSchema to set + * @see #annotationSchema + */ + public void setAnnotationSchema(UserAnnotationSchema annotationSchema) { + this.annotationSchema = annotationSchema; + } + + /** + * @return the className + * @see #className + */ + public Class<?> getAnnotatorClassName() { + return annotatorClassName; + } + + /** + * @param className + * the className to set + * @see #className + */ + public void setAnnotatorClassName(Class<?> annotatorClassName) { + this.annotatorClassName = annotatorClassName; + } + + /** + * @return the parameter name + * @see #paramName + */ + public String getParamName() { + return paramName; + } + + /** + * @param paramName + * the {@link UserAnnotatorsParam#paramName} to set + */ + public void setParamName(String paramName) { + this.paramName = paramName; + } + + /** + * @return the parameter value + * @see #paramValue + */ + public String getParamValue() { + return paramValue; + } + + /** + * @param parameter + * value the {@link UserAnnotatorsParam#paramValue} to set + */ + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } } diff --git a/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024__table_attribute_rename.sql b/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024__table_attribute_rename.sql new file mode 100644 index 0000000000000000000000000000000000000000..e7f63f4c652dfebecf91dff36c33b020d819a802 --- /dev/null +++ b/persist/src/main/resources/db/migration/12.2.0~alpha.0/V12.2.0.20181024__table_attribute_rename.sql @@ -0,0 +1,5 @@ +-- rename attributes for annotators_params_table + +alter table annotators_params_table rename annotator_classname to annotator_class_name; +alter table annotators_params_table rename name to param_name; +alter table annotators_params_table rename value to param_value; diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java index a86e3519c9186748f365999e6453edaad4f70511..e1c95d96fab921e59326545e0907eb7ae81d7f33 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java @@ -23,6 +23,7 @@ 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.UserAnnotatorsParam; import lcsb.mapviewer.model.user.UserClassAnnotators; import lcsb.mapviewer.model.user.UserClassRequiredAnnotations; import lcsb.mapviewer.model.user.UserClassValidAnnotations; @@ -266,4 +267,30 @@ public class UserDaoTest extends PersistTestFunctions { } } + @Test + public void testUserWithAnnotatorParams() throws Exception { + try { + User user = new User(); + UserAnnotationSchema uas = new UserAnnotationSchema(); + user.setAnnotationSchema(uas); + UserAnnotatorsParam param = new UserAnnotatorsParam(); + param.setAnnotatorClassName(String.class); + param.setParamName("nam"); + param.setParamValue("val"); + uas.addAnnotatorParam(param); + userDao.add(user); + userDao.evict(user); + User user2 = userDao.getById(user.getId()); + assertNotNull(user2); + UserAnnotationSchema uas2 = user2.getAnnotationSchema(); + assertNotNull(uas2); + assertEquals(1, uas2.getAnnotatorsParams().size()); + + userDao.delete(user2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + }