Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Gitlab will go into maintenance Friday 3rd February from 9:00 to 10:00
Open sidebar
minerva
core
Commits
bd7a13be
Commit
bd7a13be
authored
Jul 26, 2019
by
Piotr Gawron
Browse files
comment contains only information about submodel (not the top level model)
parent
7720b265
Changes
9
Hide whitespace changes
Inline
Side-by-side
model/src/main/java/lcsb/mapviewer/model/map/Comment.java
View file @
bd7a13be
...
...
@@ -50,15 +50,9 @@ public class Comment implements Serializable {
/**
* The model that was commented.
*/
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
private
ModelData
model
;
/**
* The model that was commented.
*/
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
private
ModelData
submodel
;
/**
* User who gave the feedback (if logged in).
*/
...
...
@@ -314,38 +308,4 @@ public class Comment implements Serializable {
this
.
model
=
model2
;
}
/**
* @return the submodel
* @see #submodel
*/
public
ModelData
getSubmodelData
()
{
return
submodel
;
}
/**
* @param submodel
* the submodel to set
* @see #submodel
*/
public
void
setSubmodelData
(
ModelData
submodel
)
{
this
.
submodel
=
submodel
;
}
/**
* @return the submodel
* @see #submodel
*/
public
Model
getSubmodel
()
{
return
this
.
submodel
.
getModel
();
}
/**
* @param submodel
* the submodel to set
* @see #submodel
*/
public
void
setSubmodel
(
Model
submodel
)
{
this
.
submodel
=
submodel
.
getModelData
();
}
}
model/src/test/java/lcsb/mapviewer/model/map/CommentTest.java
View file @
bd7a13be
...
...
@@ -64,10 +64,6 @@ public class CommentTest extends ModelTestFunctions {
assertEquals
(
pinned
,
comment
.
isPinned
());
comment
.
setRemoveReason
(
removeReason
);
assertEquals
(
removeReason
,
comment
.
getRemoveReason
());
comment
.
setSubmodel
(
submodel
);
assertEquals
(
submodel
,
comment
.
getSubmodel
());
comment
.
setSubmodelData
(
submodel
.
getModelData
());
assertEquals
(
submodel
.
getModelData
(),
comment
.
getSubmodelData
());
comment
.
setTableId
(
tableId
);
assertEquals
(
tableId
,
comment
.
getTableId
());
comment
.
setTableName
(
tableName
);
...
...
persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190725__comment_submodel_column_is_removed.sql
0 → 100644
View file @
bd7a13be
--remove submodel_id column
update
comment_table
set
model_id
=
submodel_id
where
submodel_id
is
not
null
;
ALTER
TABLE
comment_table
drop
COLUMN
submodel_id
;
--comment must be attached to a model
delete
from
comment_table
where
model_id
is
null
;
ALTER
TABLE
comment_table
ALTER
COLUMN
model_id
SET
NOT
NULL
;
-- pinned should be not null
update
comment_table
set
pinned
=
false
where
pinned
is
null
;
ALTER
TABLE
comment_table
ALTER
COLUMN
pinned
SET
NOT
NULL
;
persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java
View file @
bd7a13be
...
...
@@ -48,9 +48,15 @@ public class CommentDaoTest extends PersistTestFunctions {
@Test
public
void
testGetById
()
throws
Exception
{
Model
model
=
createModel
();
project
.
addModel
(
model
);
modelDao
.
add
(
model
);
projectDao
.
update
(
project
);
int
counter
=
(
int
)
commentDao
.
getCount
();
Comment
comment
=
new
Comment
();
comment
.
setUser
(
user
);
comment
.
setModel
(
model
);
commentDao
.
add
(
comment
);
int
counter2
=
(
int
)
commentDao
.
getCount
();
assertEquals
(
counter
+
1
,
counter2
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/comments/CommentRestImpl.java
View file @
bd7a13be
...
...
@@ -107,7 +107,7 @@ public class CommentRestImpl extends BaseRestImpl {
value
=
getId
(
comment
);
break
;
case
"modelid"
:
value
=
comment
.
get
Subm
odelData
().
getId
();
value
=
comment
.
get
M
odelData
().
getId
();
break
;
case
"title"
:
value
=
getTitle
(
comment
);
...
...
@@ -279,7 +279,7 @@ public class CommentRestImpl extends BaseRestImpl {
throw
new
QueryException
(
"Unknown type of commented object: "
+
elementType
);
}
Comment
comment
=
commentService
.
addComment
(
name
,
email
,
content
,
model
,
pointCoordinates
,
commentedObject
,
pinned
,
Comment
comment
=
commentService
.
addComment
(
name
,
email
,
content
,
pointCoordinates
,
commentedObject
,
pinned
,
submodel
);
return
preparedComment
(
comment
,
createCommentColumnSet
(
""
));
...
...
service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java
View file @
bd7a13be
...
...
@@ -12,13 +12,10 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
lcsb.mapviewer.common.ObjectUtils
;
import
lcsb.mapviewer.common.exception.InvalidClassException
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.Comment
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelData
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.user.User
;
import
lcsb.mapviewer.persist.dao.map.CommentDao
;
import
lcsb.mapviewer.services.interfaces.*
;
...
...
@@ -79,26 +76,17 @@ public class CommentService implements ICommentService {
}
@Override
public
Comment
addComment
(
String
name
,
String
email
,
String
content
,
Model
model
,
Point2D
coordinates
,
Object
object
,
public
Comment
addComment
(
String
name
,
String
email
,
String
content
,
Point2D
coordinates
,
Object
object
,
boolean
pinned
,
Model
submodel
)
{
Comment
comment
=
new
Comment
();
comment
.
setName
(
name
);
comment
.
setEmail
(
email
);
comment
.
setContent
(
content
);
comment
.
setModel
(
model
);
comment
.
setModel
(
sub
model
);
comment
.
setCoordinates
(
coordinates
);
if
(
object
!=
null
)
{
comment
.
setTableName
(
object
.
getClass
());
comment
.
setTableId
(
ObjectUtils
.
getIdOfObject
(
object
));
if
(
object
instanceof
Element
)
{
comment
.
setSubmodel
(((
Element
)
object
).
getModel
());
}
else
if
(
object
instanceof
Reaction
)
{
comment
.
setSubmodel
(((
Reaction
)
object
).
getModel
());
}
else
{
throw
new
InvalidClassException
(
"Cannot comment on object of class: "
+
object
.
getClass
());
}
}
else
{
comment
.
setSubmodel
(
submodel
);
}
comment
.
setUser
(
null
);
comment
.
setPinned
(
pinned
);
...
...
@@ -106,8 +94,8 @@ public class CommentService implements ICommentService {
try
{
EmailSender
emailSender
=
new
EmailSender
(
configurationService
);
emailSender
.
sendEmail
(
"New comment appeard in the "
+
model
.
getProject
().
getProjectId
(),
content
,
model
.
getProject
().
getNotifyEmail
());
emailSender
.
sendEmail
(
"New comment appeard in the "
+
sub
model
.
getProject
().
getProjectId
(),
content
,
sub
model
.
getProject
().
getNotifyEmail
());
}
catch
(
MessagingException
e
)
{
logger
.
error
(
"Problem with sending email."
,
e
);
}
...
...
service/src/main/java/lcsb/mapviewer/services/interfaces/ICommentService.java
View file @
bd7a13be
...
...
@@ -30,8 +30,6 @@ public interface ICommentService {
* email of the person that comments
* @param content
* content of the comment
* @param model
* which map we comment on
* @param submodel
* on which submodel we comment on
* @param coordinates
...
...
@@ -39,7 +37,7 @@ public interface ICommentService {
*
* @return comment object created based on the data provided as parameters
*/
Comment
addComment
(
String
name
,
String
email
,
String
content
,
Model
model
,
Point2D
coordinates
,
Object
object
,
Comment
addComment
(
String
name
,
String
email
,
String
content
,
Point2D
coordinates
,
Object
object
,
boolean
pinned
,
Model
submodel
);
/**
...
...
service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java
View file @
bd7a13be
...
...
@@ -62,16 +62,11 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public
void
testGetAgregatedComments
()
throws
Exception
{
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Conteneta 1"
,
model
,
new
Point2D
.
Double
(
0
,
1
),
alias
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetb 2"
,
model
,
new
Point2D
.
Double
(
0
,
2
),
alias
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 3"
,
model
,
new
Point2D
.
Double
(
0
,
3
),
alias2
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 4"
,
model
,
new
Point2D
.
Double
(
0
,
4
),
null
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 5"
,
model
,
new
Point2D
.
Double
(
0
,
5
),
null
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Conteneta 1"
,
new
Point2D
.
Double
(
0
,
1
),
alias
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetb 2"
,
new
Point2D
.
Double
(
0
,
2
),
alias
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 3"
,
new
Point2D
.
Double
(
0
,
3
),
alias2
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 4"
,
new
Point2D
.
Double
(
0
,
4
),
null
,
false
,
model
);
commentService
.
addComment
(
"John Doe"
,
"a@a.pl"
,
"Contenetc 5"
,
new
Point2D
.
Double
(
0
,
5
),
null
,
false
,
model
);
CommentService
service
=
new
CommentService
(
null
,
null
,
null
,
null
);
service
.
setCommentDao
(
commentDao
);
List
<
List
<
Comment
>>
comments
=
service
.
getAgregatedComments
(
model
,
null
);
...
...
@@ -92,7 +87,7 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public
void
testAddComment
()
throws
Exception
{
long
counter
=
commentService
.
getCommentCount
();
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
model
,
new
Point2D
.
Double
(
0
,
0
),
null
,
false
,
model
);
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
new
Point2D
.
Double
(
0
,
0
),
null
,
false
,
model
);
long
counter2
=
commentService
.
getCommentCount
();
assertEquals
(
counter
+
1
,
counter2
);
commentDao
.
delete
(
feedback
);
...
...
@@ -101,7 +96,7 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public
void
testAddCommentForReaction
()
throws
Exception
{
long
counter
=
commentService
.
getCommentCount
();
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
model
,
new
Point2D
.
Double
(
0
,
0
),
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
new
Point2D
.
Double
(
0
,
0
),
model
.
getReactions
().
iterator
().
next
(),
false
,
model
);
long
counter2
=
commentService
.
getCommentCount
();
assertEquals
(
counter
+
1
,
counter2
);
...
...
@@ -112,7 +107,7 @@ public class CommentServiceTest extends ServiceTestFunctions {
public
void
testAddCommentForAlias
()
throws
Exception
{
Element
alias
=
model
.
getElementByElementId
(
"sa1"
);
long
counter
=
commentService
.
getCommentCount
();
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
model
,
new
Point2D
.
Double
(
0
,
0
),
alias
,
false
,
model
);
Comment
feedback
=
commentService
.
addComment
(
"a"
,
"b"
,
"c"
,
new
Point2D
.
Double
(
0
,
0
),
alias
,
false
,
model
);
long
counter2
=
commentService
.
getCommentCount
();
assertEquals
(
counter
+
1
,
counter2
);
commentDao
.
delete
(
feedback
);
...
...
web/src/test/java/lcsb/mapviewer/web/CommentControllerIntegrationTest.java
View file @
bd7a13be
...
...
@@ -702,7 +702,6 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
private
Comment
createComment
()
{
Comment
comment
=
new
Comment
();
comment
.
setSubmodelData
(
map
);
comment
.
setModel
(
map
);
comment
.
setCoordinates
(
new
Point2D
.
Double
(
10
,
20
));
return
comment
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment