Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
93a12b0f
Commit
93a12b0f
authored
Aug 12, 2021
by
Piotr Gawron
Browse files
provide inof about modifier type
parent
d81a0f64
Changes
9
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
93a12b0f
minerva
(
16.1.0
~
alpha
.0
)
stable
;
urgency
=
medium
*
Small
improvement
:
API
provides
information
about
modifier
type
(#
1085
)
*
Bug
fix
:
api
endpoints
were
exposed
without
'api'
prefix
*
Bug
fix
:
anonymous
user
could
upload
file
using
API
*
Bug
fix
:
when
passing
JSON
in
patch
/
post
methods
contentType
was
not
...
...
model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNode.java
View file @
93a12b0f
package
lcsb.mapviewer.model.map.reaction
;
import
javax.persistence.*
;
import
javax.persistence.DiscriminatorValue
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.modelutils.map.ElementUtils
;
import
lcsb.mapviewer.modelutils.serializer.model.map.reaction.ReactionNodeSerializer
;
/**
* One of two known types of nodes in the {@link Reaction}. It defines input or
...
...
@@ -22,6 +27,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils;
*/
@Entity
@DiscriminatorValue
(
"GENERIC_REACTION_NODE"
)
@JsonSerialize
(
using
=
ReactionNodeSerializer
.
class
)
public
abstract
class
ReactionNode
extends
AbstractNode
{
/**
...
...
model/src/main/java/lcsb/mapviewer/modelutils/serializer/model/map/reaction/ReactionNodeSerializer.java
0 → 100644
View file @
93a12b0f
package
lcsb.mapviewer.modelutils.serializer.model.map.reaction
;
import
java.io.IOException
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.databind.JsonSerializer
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
lcsb.mapviewer.model.map.reaction.ReactionNode
;
public
class
ReactionNodeSerializer
extends
JsonSerializer
<
ReactionNode
>
{
@Override
public
void
serialize
(
final
ReactionNode
node
,
final
JsonGenerator
gen
,
final
SerializerProvider
serializers
)
throws
IOException
{
gen
.
writeStartObject
();
gen
.
writeNumberField
(
"aliasId"
,
node
.
getElement
().
getId
());
gen
.
writeObjectField
(
"stoichiometry"
,
node
.
getStoichiometry
());
gen
.
writeStringField
(
"type"
,
node
.
getClass
().
getSimpleName
());
gen
.
writeEndObject
();
}
}
\ No newline at end of file
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/reactions/ReactionsController.java
View file @
93a12b0f
...
...
@@ -36,7 +36,6 @@ import lcsb.mapviewer.model.map.reaction.NodeOperator;
import
lcsb.mapviewer.model.map.reaction.Product
;
import
lcsb.mapviewer.model.map.reaction.Reactant
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.reaction.ReactionNode
;
import
lcsb.mapviewer.modelutils.serializer.MathMLSerializer
;
import
lcsb.mapviewer.services.QueryException
;
import
lcsb.mapviewer.services.interfaces.IReactionService
;
...
...
@@ -113,27 +112,15 @@ public class ReactionsController extends BaseController {
value
=
pt
.
getPointOnLine
(
centerLine
.
getP1
(),
centerLine
.
getP2
(),
0.5
);
break
;
case
"products"
:
{
List
<
Map
<
String
,
Object
>>
ids
=
new
ArrayList
<>();
for
(
Product
product
:
reaction
.
getProducts
())
{
ids
.
add
(
createReactionNode
(
product
));
}
value
=
ids
;
value
=
reaction
.
getProducts
();
break
;
}
case
"reactants"
:
{
List
<
Map
<
String
,
Object
>>
ids
=
new
ArrayList
<>();
for
(
Reactant
reactant
:
reaction
.
getReactants
())
{
ids
.
add
(
createReactionNode
(
reactant
));
}
value
=
ids
;
value
=
reaction
.
getReactants
();
break
;
}
case
"modifiers"
:
{
List
<
Map
<
String
,
Object
>>
ids
=
new
ArrayList
<>();
for
(
Modifier
modifier
:
reaction
.
getModifiers
())
{
ids
.
add
(
createReactionNode
(
modifier
));
}
value
=
ids
;
value
=
reaction
.
getModifiers
();
break
;
}
case
"type"
:
...
...
@@ -233,13 +220,6 @@ public class ReactionsController extends BaseController {
return
result
;
}
private
Map
<
String
,
Object
>
createReactionNode
(
ReactionNode
node
)
{
Map
<
String
,
Object
>
result
=
new
TreeMap
<>();
result
.
put
(
"aliasId"
,
node
.
getElement
().
getId
());
result
.
put
(
"stoichiometry"
,
node
.
getStoichiometry
());
return
result
;
}
private
Map
<
String
,
Object
>
kineticsToMap
(
SbmlKinetics
kinetics
)
{
if
(
kinetics
==
null
)
{
return
null
;
...
...
service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java
View file @
93a12b0f
...
...
@@ -1382,4 +1382,9 @@ public class ProjectService implements IProjectService {
return
new
ArrayList
<>();
}
}
@Override
public
void
add
(
Project
project
)
{
projectDao
.
add
(
project
);
}
}
service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java
View file @
93a12b0f
...
...
@@ -124,4 +124,6 @@ public interface IProjectService {
UploadedFileEntry
getFileByProjectId
(
String
projectId
);
List
<
ProjectBackground
>
getBackgrounds
(
String
projectId
,
boolean
initializeLazy
);
void
add
(
Project
project
);
}
web/src/test/java/lcsb/mapviewer/web/ControllerIntegrationTest.java
View file @
93a12b0f
...
...
@@ -107,6 +107,7 @@ import lcsb.mapviewer.persist.dao.map.ModelDao;
import
lcsb.mapviewer.persist.dao.user.ResetPasswordTokenDao
;
import
lcsb.mapviewer.persist.dao.user.UserDao
;
import
lcsb.mapviewer.services.interfaces.IDataOverlayService
;
import
lcsb.mapviewer.services.interfaces.IFileService
;
import
lcsb.mapviewer.services.interfaces.IProjectService
;
import
lcsb.mapviewer.services.interfaces.IUserService
;
import
lcsb.mapviewer.web.config.SpringWebConfig
;
...
...
@@ -161,6 +162,9 @@ abstract public class ControllerIntegrationTest {
@Autowired
private
UploadedFileEntryDao
fileDao
;
@Autowired
private
IFileService
fileService
;
@Autowired
private
DataOverlayDao
dataOverlayDao
;
...
...
@@ -444,7 +448,7 @@ abstract public class ControllerIntegrationTest {
background
.
setCreator
(
userService
.
getUserByLogin
(
BUILT_IN_TEST_ADMIN_LOGIN
));
project
.
addProjectBackground
(
background
);
project
Dao
.
add
(
project
);
project
Service
.
add
(
project
);
return
project
;
}
...
...
@@ -516,7 +520,7 @@ abstract public class ControllerIntegrationTest {
file
.
setOriginalFileName
(
"test_file"
);
file
.
setLength
(
content
.
length
);
file
.
setOwner
(
user
);
file
Dao
.
add
(
file
);
file
Service
.
add
(
file
);
return
file
;
}
...
...
web/src/test/java/lcsb/mapviewer/web/MapControllerIntegrationTest.java
View file @
93a12b0f
...
...
@@ -16,6 +16,8 @@ import static org.springframework.restdocs.request.RequestDocumentation.pathPara
import
static
org
.
springframework
.
restdocs
.
request
.
RequestDocumentation
.
requestParameters
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Supplier
;
...
...
@@ -30,6 +32,8 @@ import org.junit.runner.RunWith;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.mock.web.MockHttpSession
;
import
org.springframework.restdocs.payload.FieldDescriptor
;
import
org.springframework.restdocs.payload.JsonFieldType
;
import
org.springframework.restdocs.payload.ResponseFieldsSnippet
;
import
org.springframework.restdocs.request.PathParametersSnippet
;
import
org.springframework.restdocs.request.RequestParametersSnippet
;
...
...
@@ -229,62 +233,85 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
}
private
ResponseFieldsSnippet
listOfReactionResponseFields
()
{
return
responseFields
(
List
<
FieldDescriptor
>
fields
=
new
ArrayList
<>(
Arrays
.
asList
(
fieldWithPath
(
"[].id"
)
.
description
(
"unique element identifier"
)
.
type
(
"number"
)
.
type
(
JsonFieldType
.
NUMBER
)
.
optional
(),
fieldWithPath
(
"[].reactionId"
)
.
description
(
"reaction identifier taken from source file"
)
.
type
(
"string"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
(),
fieldWithPath
(
"[].modelId"
)
.
description
(
"map identifier"
)
.
type
(
"number"
)
.
type
(
JsonFieldType
.
NUMBER
)
.
optional
(),
fieldWithPath
(
"[].type"
)
.
description
(
"reaction type"
)
.
type
(
"string"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
(),
subsectionWithPath
(
"[].centerPoint"
)
.
description
(
"center point"
)
.
type
(
"point"
)
.
type
(
JsonFieldType
.
OBJECT
)
.
optional
(),
subsectionWithPath
(
"[].lines"
)
.
description
(
"list of lines used to draw reaction"
)
.
type
(
"array<line>"
)
.
type
(
JsonFieldType
.
ARRAY
)
.
optional
(),
fieldWithPath
(
"[].hierarchyVisibilityLevel"
)
.
description
(
"at what zoom level this element becomes visible in hierarchical view"
)
.
type
(
"string"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
(),
subsectionWithPath
(
"[].references"
)
.
description
(
"list of references"
)
.
type
(
"array<Reference>"
)
.
type
(
JsonFieldType
.
ARRAY
)
.
optional
(),
subsection
WithPath
(
"[].modifiers"
)
field
WithPath
(
"[].modifiers"
)
.
description
(
"list of modifiers"
)
.
type
(
"array<object>"
)
.
type
(
JsonFieldType
.
ARRAY
)
.
optional
(),
subsection
WithPath
(
"[].reactants"
)
field
WithPath
(
"[].reactants"
)
.
description
(
"list of reactants"
)
.
type
(
"array<object>"
)
.
type
(
JsonFieldType
.
ARRAY
)
.
optional
(),
subsection
WithPath
(
"[].products"
)
field
WithPath
(
"[].products"
)
.
description
(
"list of products"
)
.
type
(
"array<object>"
)
.
type
(
JsonFieldType
.
ARRAY
)
.
optional
(),
fieldWithPath
(
"[].notes"
)
.
description
(
"notes and description"
)
.
type
(
"string"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
(),
fieldWithPath
(
"[].kineticLaw"
)
.
description
(
"SBML kinetics law"
)
.
type
(
"object"
)
.
type
(
JsonFieldType
.
OBJECT
)
.
optional
(),
subsectionWithPath
(
"[].other"
)
.
description
(
"list of oher properties"
)
.
type
(
"object"
)
.
type
(
JsonFieldType
.
OBJECT
)
.
optional
()));
fields
.
addAll
(
reactionNodeFields
(
"[].reactants[]"
));
fields
.
addAll
(
reactionNodeFields
(
"[].products[]"
));
fields
.
addAll
(
reactionNodeFields
(
"[].modifiers[]"
));
return
responseFields
(
fields
);
}
private
List
<
FieldDescriptor
>
reactionNodeFields
(
String
prefix
)
{
if
(!
prefix
.
endsWith
(
"."
)
&&
!
prefix
.
isEmpty
())
{
prefix
=
prefix
+
"."
;
}
return
Arrays
.
asList
(
fieldWithPath
(
prefix
+
"aliasId"
)
.
description
(
"element identifier"
)
.
type
(
JsonFieldType
.
NUMBER
)
.
optional
(),
fieldWithPath
(
prefix
+
"type"
)
.
description
(
"type"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
(),
fieldWithPath
(
prefix
+
"stoichiometry"
)
.
description
(
"element stoichiometry"
)
.
type
(
JsonFieldType
.
STRING
)
.
optional
());
}
...
...
web/src/test/java/lcsb/mapviewer/web/ReactionControllerIntegrationTest.java
View file @
93a12b0f
...
...
@@ -6,10 +6,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.*
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.mock.web.MockHttpSession
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.web.servlet.RequestBuilder
;
...
...
@@ -36,10 +37,8 @@ public class ReactionControllerIntegrationTest extends ControllerIntegrationTest
@Before
public
void
setup
()
{
callInSeparateThreadNoReturn
(()
->
{
project
=
createProject
(
TEST_PROJECT
);
anonymous
=
userService
.
getUserByLogin
(
Configuration
.
ANONYMOUS_LOGIN
);
});
project
=
createProject
(
TEST_PROJECT
);
anonymous
=
userService
.
getUserByLogin
(
Configuration
.
ANONYMOUS_LOGIN
);
}
@After
...
...
@@ -51,8 +50,7 @@ public class ReactionControllerIntegrationTest extends ControllerIntegrationTest
public
void
testGetAllReactions
()
throws
Exception
{
userService
.
grantUserPrivilege
(
anonymous
,
PrivilegeType
.
READ_PROJECT
,
project
.
getProjectId
());
RequestBuilder
request
=
get
(
"/api/projects/"
+
TEST_PROJECT
+
"/models/*/bioEntities/reactions/"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
RequestBuilder
request
=
get
(
"/api/projects/{projectId}/models/*/bioEntities/reactions/"
,
TEST_PROJECT
);
String
response
=
mockMvc
.
perform
(
request
)
.
andExpect
(
status
().
is2xxSuccessful
())
...
...
@@ -70,7 +68,6 @@ public class ReactionControllerIntegrationTest extends ControllerIntegrationTest
MockHttpSession
session
=
createSession
(
BUILT_IN_TEST_ADMIN_LOGIN
,
BUILT_IN_TEST_ADMIN_PASSWORD
);
RequestBuilder
request
=
get
(
"/api/projects/*/models/*/bioEntities/reactions/"
)
.
contentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
)
.
session
(
session
);
mockMvc
.
perform
(
request
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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