Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
7720b265
Commit
7720b265
authored
Jul 25, 2019
by
Piotr Gawron
Browse files
Merge branch '838-deprecacy-information-for-data-overlay' into 'master'
Resolve "deprecacy information for data overlay" Closes
#838
See merge request
!859
parents
aa4717ca
f73ef15b
Pipeline
#12095
passed with stage
in 10 minutes and 37 seconds
Changes
30
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
7720b265
...
...
@@ -19,6 +19,9 @@ minerva (14.0.0~alpha.0) unstable; urgency=low
about
type
of
database
that
identifies
the
target
(#
66
)
*
Small
improvement
:
redundant
'references'
field
in
gene
variants
data
overlay
is
now
deprecated
(#
850
)
*
Small
improvement
:
information
about
deprecated
columns
in
data
overlay
is
visible
in
overlay
list
(#
838
)
*
Small
improvement
:
publication
list
is
resizable
(#
740
)
*
Bug
fix
:
export
to
CellDesigner
of
reaction
with
two
modifiers
connected
with
boolean
operator
resulted
was
skipping
some
layout
information
*
Bug
fix
:
reaction
in
SBGNML
file
containing
two
products
was
improperly
...
...
commons/src/main/java/lcsb/mapviewer/common/UnitTestFailedWatcher.java
View file @
7720b265
...
...
@@ -6,6 +6,8 @@ import org.junit.runner.Description;
public
class
UnitTestFailedWatcher
extends
TestWatcher
{
@Override
protected
void
failed
(
Throwable
e
,
Description
description
)
{
e
.
printStackTrace
();
if
(!(
e
instanceof
AssertionError
))
{
e
.
printStackTrace
();
}
}
}
frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js
View file @
7720b265
...
...
@@ -318,7 +318,17 @@ OverlayPanel.prototype.createOverlayRow = function (overlay, checked, disabled)
OverlayPanel
.
prototype
.
overlayToDataRow
=
function
(
overlay
,
checked
,
disabled
)
{
var
result
=
[];
result
[
0
]
=
overlay
.
getOrder
();
result
[
1
]
=
overlay
.
getName
();
if
(
overlay
.
getDeprecatedColumns
()
!==
undefined
&&
overlay
.
getDeprecatedColumns
()
!==
null
&&
overlay
.
getDeprecatedColumns
().
length
>
0
)
{
result
[
1
]
=
"
<div title='This data overlay uses old deprecated column names:
"
;
for
(
var
j
=
0
;
j
<
overlay
.
getDeprecatedColumns
().
length
;
j
++
)
{
result
[
1
]
+=
overlay
.
getDeprecatedColumns
()[
j
]
+
"
,
"
;
}
result
[
1
]
+=
"
This format will be not supported in minerva 15 and higher. Please re-upload data set using new format.'>
"
+
"
<i class='fa fa-exclamation-triangle' style='font-size:18px; font-weight:400; padding-right:10px;color:orange'></i>
"
+
overlay
.
getName
()
+
"
</div>
"
}
else
{
result
[
1
]
=
overlay
.
getName
();
}
if
(
overlay
.
getInputDataAvailable
())
{
if
(
disabled
)
{
...
...
@@ -351,6 +361,7 @@ OverlayPanel.prototype.overlayToDataRow = function (overlay, checked, disabled)
"
</div>
"
;
}
}
logger
.
debug
(
result
);
return
result
;
};
...
...
frontend-js/src/main/js/map/data/DataOverlay.js
View file @
7720b265
...
...
@@ -26,6 +26,7 @@ function DataOverlay(overlayId, name) {
this
.
setImagesDirectory
(
object
.
images
);
this
.
setDescription
(
object
.
description
);
this
.
setCreator
(
object
.
creator
);
this
.
setDeprecatedColumns
(
object
.
deprecatedColumns
);
this
.
setContent
(
object
.
content
);
this
.
setFilename
(
object
.
filename
);
this
.
setPublicOverlay
(
object
.
publicOverlay
);
...
...
@@ -328,6 +329,22 @@ DataOverlay.prototype.setContent = function (content) {
this
.
_content
=
content
;
};
/**
*
* @returns {string[]}
*/
DataOverlay
.
prototype
.
getDeprecatedColumns
=
function
()
{
return
this
.
_deprecatedColumns
;
};
/**
*
* @param {string[]} deprecatedColumns
*/
DataOverlay
.
prototype
.
setDeprecatedColumns
=
function
(
deprecatedColumns
)
{
this
.
_deprecatedColumns
=
deprecatedColumns
;
};
/**
*
* @returns {number}
...
...
@@ -380,7 +397,7 @@ DataOverlay.prototype.setType = function (type) {
*
* @param {boolean} value
*/
DataOverlay
.
prototype
.
setGoogleLicenseConsent
=
function
(
value
)
{
DataOverlay
.
prototype
.
setGoogleLicenseConsent
=
function
(
value
)
{
this
.
_googleLicenseConsent
=
value
;
};
...
...
@@ -388,7 +405,7 @@ DataOverlay.prototype.setGoogleLicenseConsent = function(value) {
*
* @returns {boolean}
*/
DataOverlay
.
prototype
.
isGoogleLicenseConsent
=
function
()
{
DataOverlay
.
prototype
.
isGoogleLicenseConsent
=
function
()
{
return
this
.
_googleLicenseConsent
;
};
...
...
persist/src/main/java/lcsb/mapviewer/persist/dao/BaseDao.java
View file @
7720b265
...
...
@@ -254,7 +254,10 @@ public abstract class BaseDao<T> {
* @return object width identifier given as parameter
*/
@SuppressWarnings
(
"unchecked"
)
public
T
getById
(
int
id
)
{
public
T
getById
(
Integer
id
)
{
if
(
id
==
null
)
{
return
null
;
}
List
<?>
list
=
getSession
()
.
createQuery
(
" from "
+
this
.
clazz
.
getSimpleName
()
+
" where id=:id "
+
removableAndStatemant
())
.
setParameter
(
"id"
,
id
).
list
();
...
...
persist/src/main/java/lcsb/mapviewer/persist/dao/map/ModelDao.java
View file @
7720b265
...
...
@@ -40,12 +40,6 @@ public class ModelDao extends BaseDao<ModelData> {
super
.
delete
(
model
);
}
@Override
public
ModelData
getById
(
int
id
)
{
ModelData
result
=
super
.
getById
(
id
);
return
result
;
}
/**
* Return the latest model for the project with a given project identifier.
*
...
...
rest-api/src/main/java/lcsb/mapviewer/api/BaseController.java
View file @
7720b265
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.HttpMediaTypeNotSupportedException;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.method.annotation.MethodArgumentTypeMismatchException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
...
...
@@ -42,7 +43,7 @@ public abstract class BaseController {
||
e
instanceof
HttpMessageNotReadableException
||
e
instanceof
MissingServletRequestParameterException
||
e
instanceof
HttpMediaTypeNotSupportedException
||
e
instanceof
Illegal
ArgumentException
)
{
||
e
instanceof
Method
Argument
TypeMismatch
Exception
)
{
logger
.
error
(
e
,
e
);
return
createErrorResponse
(
"Query server error."
,
e
.
getMessage
(),
new
HttpHeaders
(),
HttpStatus
.
BAD_REQUEST
);
}
else
if
(
e
instanceof
ServletRequestBindingException
&&
e
.
getMessage
().
contains
(
Configuration
.
AUTH_TOKEN
))
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/BaseRestImpl.java
View file @
7720b265
...
...
@@ -8,6 +8,7 @@ import javax.xml.transform.*;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -160,10 +161,9 @@ public abstract class BaseRestImpl {
* @param modelId
* list of model identifiers separated by "," or '*' when all models
* should be returned
* @throws ObjectNotFoundException
* thrown when data for given identifiers doesn't exist
* @throws QueryException
*/
protected
List
<
Model
>
getModels
(
String
projectId
,
String
modelId
)
throws
ObjectNotFound
Exception
{
protected
List
<
Model
>
getModels
(
String
projectId
,
String
modelId
)
throws
Query
Exception
{
Model
model
=
modelService
.
getLastModelByProjectId
(
projectId
);
if
(
model
==
null
)
{
throw
new
ObjectNotFoundException
(
"Project with given id doesn't exist"
);
...
...
@@ -172,6 +172,10 @@ public abstract class BaseRestImpl {
if
(!
modelId
.
equals
(
"*"
))
{
for
(
String
str
:
modelId
.
split
(
","
))
{
if
(!
StringUtils
.
isNumeric
(
str
))
{
throw
new
QueryException
(
"Invalid modelId: "
+
modelId
);
}
Model
submodel
=
model
.
getSubmodelById
(
Integer
.
valueOf
(
str
));
if
(
submodel
==
null
)
{
throw
new
ObjectNotFoundException
(
"Model with given id doesn't exist"
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/files/FileController.java
View file @
7720b265
...
...
@@ -36,13 +36,13 @@ public class FileController extends BaseController {
@PostAuthorize
(
"hasAuthority('IS_ADMIN') or returnObject['owner'] == authentication.name"
)
@GetMapping
(
value
=
"/{id}"
)
public
Map
<
String
,
Object
>
getFile
(
@PathVariable
(
value
=
"id"
)
String
id
)
throws
ObjectNotFoundException
{
public
Map
<
String
,
Object
>
getFile
(
@PathVariable
(
value
=
"id"
)
Integer
id
)
throws
ObjectNotFoundException
{
return
fileRest
.
getFile
(
id
);
}
@PreAuthorize
(
"@fileService.get
ById(#id)?.owner
?.login == authentication.name"
)
@PreAuthorize
(
"@fileService.get
OwnerByFileId(#id)
?.login == authentication.name"
)
@PostMapping
(
value
=
"/{id}:uploadContent"
)
public
Map
<
String
,
Object
>
uploadContent
(
@PathVariable
(
value
=
"id"
)
String
id
,
@RequestBody
byte
[]
data
)
public
Map
<
String
,
Object
>
uploadContent
(
@PathVariable
(
value
=
"id"
)
Integer
id
,
@RequestBody
byte
[]
data
)
throws
ObjectNotFoundException
{
return
fileRest
.
uploadContent
(
id
,
data
);
}
...
...
rest-api/src/main/java/lcsb/mapviewer/api/files/FileRestImpl.java
View file @
7720b265
...
...
@@ -15,6 +15,7 @@ import lcsb.mapviewer.common.exception.InvalidStateException;
import
lcsb.mapviewer.model.cache.UploadedFileEntry
;
import
lcsb.mapviewer.model.user.User
;
import
lcsb.mapviewer.persist.dao.cache.UploadedFileEntryDao
;
import
lcsb.mapviewer.services.interfaces.IFileService
;
@Transactional
@Service
...
...
@@ -22,9 +23,12 @@ public class FileRestImpl extends BaseRestImpl {
private
UploadedFileEntryDao
uploadedFileEntryDao
;
private
IFileService
fileService
;
@Autowired
public
FileRestImpl
(
UploadedFileEntryDao
uploadedFileEntryDao
)
{
public
FileRestImpl
(
UploadedFileEntryDao
uploadedFileEntryDao
,
IFileService
fileService
)
{
this
.
uploadedFileEntryDao
=
uploadedFileEntryDao
;
this
.
fileService
=
fileService
;
}
public
Map
<
String
,
Object
>
createFile
(
String
filename
,
String
length
,
User
user
)
{
...
...
@@ -35,15 +39,14 @@ public class FileRestImpl extends BaseRestImpl {
entry
.
setOwner
(
user
);
uploadedFileEntryDao
.
add
(
entry
);
try
{
return
getFile
(
entry
.
getId
()
+
""
);
return
getFile
(
entry
.
getId
());
}
catch
(
ObjectNotFoundException
e
)
{
throw
new
InvalidStateException
(
e
);
}
}
public
Map
<
String
,
Object
>
getFile
(
String
id
)
throws
ObjectNotFoundException
{
int
fileId
=
Integer
.
valueOf
(
id
);
UploadedFileEntry
fileEntry
=
uploadedFileEntryDao
.
getById
(
fileId
);
public
Map
<
String
,
Object
>
getFile
(
Integer
id
)
throws
ObjectNotFoundException
{
UploadedFileEntry
fileEntry
=
fileService
.
getById
(
id
);
if
(
fileEntry
==
null
)
{
throw
new
ObjectNotFoundException
(
"Object not found"
);
}
...
...
@@ -60,7 +63,7 @@ public class FileRestImpl extends BaseRestImpl {
return
result
;
}
public
Map
<
String
,
Object
>
uploadContent
(
String
id
,
byte
[]
data
)
throws
ObjectNotFoundException
{
public
Map
<
String
,
Object
>
uploadContent
(
Integer
id
,
byte
[]
data
)
throws
ObjectNotFoundException
{
int
fileId
=
Integer
.
valueOf
(
id
);
UploadedFileEntry
fileEntry
=
uploadedFileEntryDao
.
getById
(
fileId
);
if
(
fileEntry
==
null
)
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/genomics/ReferenceGenomeRestImpl.java
View file @
7720b265
...
...
@@ -168,7 +168,12 @@ public class ReferenceGenomeRestImpl extends BaseRestImpl {
public
List
<
Map
<
String
,
Object
>>
getReferenceGenomeVersions
(
String
organismId
,
String
type
)
throws
QueryException
{
ReferenceGenomeType
genomeType
=
ReferenceGenomeType
.
valueOf
(
type
);
ReferenceGenomeType
genomeType
=
null
;
try
{
genomeType
=
ReferenceGenomeType
.
valueOf
(
type
);
}
catch
(
IllegalArgumentException
e
)
{
throw
new
QueryException
(
"Invalid type: "
+
type
);
}
MiriamData
organism
;
if
(
organismId
!=
null
&&
!
organismId
.
isEmpty
())
{
organism
=
new
MiriamData
(
MiriamType
.
TAXONOMY
,
organismId
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java
View file @
7720b265
...
...
@@ -114,7 +114,7 @@ public class ProjectController extends BaseController {
@PreAuthorize
(
"hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId)"
)
@GetMapping
(
value
=
"/{projectId}/statistics"
)
public
Object
getStatistics
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
ObjectNotFound
Exception
{
public
Object
getStatistics
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
Query
Exception
{
return
projectController
.
getStatistics
(
projectId
);
}
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java
View file @
7720b265
...
...
@@ -195,7 +195,7 @@ public class ProjectRestImpl extends BaseRestImpl {
return
project
.
getInputData
();
}
public
Map
<
String
,
Object
>
getStatistics
(
String
projectId
)
throws
ObjectNotFound
Exception
{
public
Map
<
String
,
Object
>
getStatistics
(
String
projectId
)
throws
Query
Exception
{
Map
<
String
,
Object
>
result
=
new
TreeMap
<>();
Map
<
MiriamType
,
Integer
>
elementAnnotations
=
new
TreeMap
<>();
...
...
@@ -624,7 +624,7 @@ public class ProjectRestImpl extends BaseRestImpl {
return
null
;
}
public
List
<
Map
<
String
,
Object
>>
getSubmapConnections
(
String
projectId
)
throws
ObjectNotFound
Exception
{
public
List
<
Map
<
String
,
Object
>>
getSubmapConnections
(
String
projectId
)
throws
Query
Exception
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Model
>
models
=
getModels
(
projectId
,
"*"
);
List
<
Element
>
elements
=
new
ArrayList
<>();
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelController.java
View file @
7720b265
...
...
@@ -4,6 +4,7 @@ import java.io.IOException;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -37,7 +38,7 @@ public class ModelController extends BaseController {
@PreAuthorize
(
"hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId)"
)
@GetMapping
(
value
=
"/"
)
public
List
<
Map
<
String
,
Object
>>
getModels
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
ObjectNotFound
Exception
{
throws
Query
Exception
{
return
modelController
.
getModels
(
projectId
);
}
...
...
@@ -45,7 +46,7 @@ public class ModelController extends BaseController {
@GetMapping
(
value
=
"/{modelId:.+}"
)
public
Object
getModel
(
@PathVariable
(
value
=
"modelId"
)
String
modelId
,
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
ObjectNotFound
Exception
{
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
Query
Exception
{
if
(
modelId
.
equals
(
"*"
))
{
return
modelController
.
getModels
(
projectId
);
}
else
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/ModelRestImpl.java
View file @
7720b265
package
lcsb.mapviewer.api.projects.models
;
import
java.awt.
*
;
import
java.awt.
Color
;
import
java.awt.geom.*
;
import
java.io.*
;
import
java.util.*
;
import
java.util.List
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -59,7 +59,7 @@ public class ModelRestImpl extends BaseRestImpl {
this
.
layoutService
=
layoutService
;
}
public
List
<
Map
<
String
,
Object
>>
getModels
(
String
projectId
)
throws
ObjectNotFound
Exception
{
public
List
<
Map
<
String
,
Object
>>
getModels
(
String
projectId
)
throws
Query
Exception
{
Project
project
=
getProjectService
().
getProjectByProjectId
(
projectId
);
if
(
project
==
null
)
{
throw
new
ObjectNotFoundException
(
"Project with given id doesn't exist"
);
...
...
@@ -67,7 +67,10 @@ public class ModelRestImpl extends BaseRestImpl {
return
createData
(
project
);
}
public
Map
<
String
,
Object
>
getModel
(
String
projectId
,
String
modelId
)
{
public
Map
<
String
,
Object
>
getModel
(
String
projectId
,
String
modelId
)
throws
QueryException
{
if
(!
StringUtils
.
isNumeric
(
modelId
))
{
throw
new
QueryException
(
"Invalid modelId: "
+
modelId
);
}
Model
model
=
getModelService
().
getLastModelByProjectId
(
projectId
);
Model
submodel
=
model
.
getSubmodelById
(
modelId
);
if
(
submodel
==
null
)
{
...
...
@@ -95,7 +98,7 @@ public class ModelRestImpl extends BaseRestImpl {
}
}
private
List
<
Map
<
String
,
Object
>>
createData
(
Project
project
)
{
private
List
<
Map
<
String
,
Object
>>
createData
(
Project
project
)
throws
QueryException
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
Model
model
=
getModelService
().
getLastModelByProjectId
(
project
.
getProjectId
());
if
(
model
!=
null
)
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/parameters/ParametersRestImpl.java
View file @
7720b265
...
...
@@ -36,7 +36,7 @@ public class ParametersRestImpl extends BaseRestImpl {
}
private
Set
<
SbmlParameter
>
getParametersFromProject
(
String
projectId
,
String
modelId
)
throws
ObjectNotFound
Exception
{
throws
Query
Exception
{
List
<
Model
>
models
=
getModels
(
projectId
,
modelId
);
Set
<
SbmlParameter
>
parameters
=
new
LinkedHashSet
<>();
...
...
@@ -52,7 +52,7 @@ public class ParametersRestImpl extends BaseRestImpl {
}
private
Set
<
SbmlParameter
>
getGlobalParametersFromProject
(
String
projectId
,
String
modelId
)
throws
ObjectNotFound
Exception
{
throws
Query
Exception
{
List
<
Model
>
models
=
getModels
(
projectId
,
modelId
);
Set
<
SbmlParameter
>
parameters
=
new
LinkedHashSet
<>();
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/models/units/UnitsRestImpl.java
View file @
7720b265
...
...
@@ -59,7 +59,7 @@ public class UnitsRestImpl extends BaseRestImpl {
return
result
;
}
public
List
<
Map
<
String
,
Object
>>
getUnits
(
String
projectId
,
String
modelId
)
throws
ObjectNotFound
Exception
{
public
List
<
Map
<
String
,
Object
>>
getUnits
(
String
projectId
,
String
modelId
)
throws
Query
Exception
{
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Model
>
models
=
getModels
(
projectId
,
modelId
);
for
(
Model
model
:
models
)
{
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayController.java
View file @
7720b265
...
...
@@ -53,18 +53,18 @@ public class OverlayController extends BaseController {
@GetMapping
(
value
=
"/{overlayId}/"
)
public
Map
<
String
,
Object
>
getOverlayById
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
)
throws
QueryException
{
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
)
throws
QueryException
{
return
overlayRestImp
.
getOverlayById
(
projectId
,
overlayId
);
}
@PreAuthorize
(
"hasAuthority('IS_ADMIN')"
+
" or hasAuthority('IS_CURATOR') and hasAuthority('READ_PROJECT:' + #projectId)"
+
" or hasAuthority('READ_PROJECT:' + #projectId) and "
+
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout)"
)
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout
== true
)"
)
@GetMapping
(
value
=
"/{overlayId}/models/{modelId}/bioEntities/"
)
public
List
<
Map
<
String
,
Object
>>
getOverlayElements
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
,
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
,
@RequestParam
(
value
=
"columns"
,
defaultValue
=
""
)
String
columns
)
throws
QueryException
{
return
overlayRestImp
.
getOverlayElements
(
projectId
,
Integer
.
valueOf
(
overlayId
),
columns
);
}
...
...
@@ -72,12 +72,12 @@ public class OverlayController extends BaseController {
@PreAuthorize
(
"hasAuthority('IS_ADMIN')"
+
" or hasAuthority('IS_CURATOR') and hasAuthority('READ_PROJECT:' + #projectId)"
+
" or hasAuthority('READ_PROJECT:' + #projectId) and "
+
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout)"
)
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout
== true
)"
)
@GetMapping
(
value
=
"/{overlayId}/models/{modelId}/bioEntities/reactions/{reactionId}/"
)
public
Map
<
String
,
Object
>
getFullReaction
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"modelId"
)
String
modelId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
,
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
,
@PathVariable
(
value
=
"reactionId"
)
String
reactionId
,
@RequestParam
(
value
=
"columns"
,
defaultValue
=
""
)
String
columns
)
throws
QueryException
,
NumberFormatException
,
ObjectNotFoundException
{
...
...
@@ -88,12 +88,12 @@ public class OverlayController extends BaseController {
@PreAuthorize
(
"hasAuthority('IS_ADMIN')"
+
" or hasAuthority('IS_CURATOR') and hasAuthority('READ_PROJECT:' + #projectId)"
+
" or hasAuthority('READ_PROJECT:' + #projectId) and "
+
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout)"
)
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout
== true
)"
)
@GetMapping
(
value
=
"/{overlayId}/models/{modelId}/bioEntities/elements/{elementId}/"
)
public
Map
<
String
,
Object
>
getFullSpecies
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"modelId"
)
String
modelId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
,
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
,
@PathVariable
(
value
=
"elementId"
)
String
reactionId
,
@RequestParam
(
value
=
"columns"
,
defaultValue
=
""
)
String
columns
)
throws
QueryException
,
NumberFormatException
,
ObjectNotFoundException
{
...
...
@@ -126,7 +126,7 @@ public class OverlayController extends BaseController {
@DeleteMapping
(
value
=
"/{overlayId}"
)
public
Map
<
String
,
Object
>
removeOverlay
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
)
throws
QueryException
,
IOException
{
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
)
throws
QueryException
,
IOException
{
return
overlayRestImp
.
removeOverlay
(
projectId
,
overlayId
);
}
...
...
@@ -136,7 +136,7 @@ public class OverlayController extends BaseController {
@PatchMapping
(
value
=
"/{overlayId}"
)
public
Map
<
String
,
Object
>
updateOverlay
(
@RequestBody
String
body
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
,
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
,
@PathVariable
(
value
=
"projectId"
)
String
projectId
)
throws
QueryException
,
IOException
{
Map
<
String
,
Object
>
node
=
parseBody
(
body
);
...
...
@@ -147,11 +147,11 @@ public class OverlayController extends BaseController {
@PreAuthorize
(
"hasAuthority('IS_ADMIN')"
+
" or hasAuthority('IS_CURATOR') and hasAuthority('READ_PROJECT:' + #projectId)"
+
" or hasAuthority('READ_PROJECT:' + #projectId) and "
+
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout)"
)
" (@layoutService.getLayoutById(#overlayId)?.creator?.login == authentication.name or @layoutService.getLayoutById(#overlayId)?.publicLayout
== true
)"
)
@GetMapping
(
value
=
"/{overlayId}:downloadSource"
)
public
ResponseEntity
<
byte
[]>
getOverlaySource
(
@PathVariable
(
value
=
"projectId"
)
String
projectId
,
@PathVariable
(
value
=
"overlayId"
)
String
overlayId
)
@PathVariable
(
value
=
"overlayId"
)
Integer
overlayId
)
throws
QueryException
{
FileEntry
file
=
overlayRestImp
.
getOverlaySource
(
projectId
,
overlayId
);
...
...
rest-api/src/main/java/lcsb/mapviewer/api/projects/overlays/OverlayRestImpl.java
View file @
7720b265
...
...
@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
import
lcsb.mapviewer.api.*
;
import
lcsb.mapviewer.common.Pair
;
import
lcsb.mapviewer.common.exception.InvalidStateException
;
import
lcsb.mapviewer.common.geometry.ColorParser
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.cache.FileEntry
;
...
...
@@ -26,6 +27,8 @@ import lcsb.mapviewer.persist.dao.cache.UploadedFileEntryDao;
import
lcsb.mapviewer.persist.dao.map.LayoutDao
;
import
lcsb.mapviewer.services.interfaces.ILayoutService
;
import
lcsb.mapviewer.services.interfaces.ILayoutService.CreateLayoutParams
;
import
lcsb.mapviewer.services.utils.ColorSchemaReader
;
import
lcsb.mapviewer.services.utils.data.ColorSchemaColumn
;
@Transactional
@Service
...
...
@@ -78,6 +81,8 @@ public class OverlayRestImpl extends BaseRestImpl {
result
.
put
(
"description"
,
overlay
.
getDescription
());
result
.
put
(
"publicOverlay"
,
overlay
.
isPublicLayout
());
result
.
put
(
"defaultOverlay"
,
overlay
.
isDefaultOverlay
());
result
.
put
(
"deprecatedColumns"
,
getDeprecatedColumns
(
overlay
));
result
.
put
(
"googleLicenseConsent"
,
overlay
.
isGoogleLicenseConsent
());
List
<
Map
<
String
,
Object
>>
images
=
new
ArrayList
<>();
List
<
DataOverlayImageLayer
>
imageList
=
new
ArrayList
<>(
overlay
.
getDataOverlayImageLayers
());
...
...
@@ -97,6 +102,18 @@ public class OverlayRestImpl extends BaseRestImpl {
return
result
;
}
private
List
<
String
>
getDeprecatedColumns
(
Layout
overlay
)
{
try
{
List
<
String
>
result
=
new
ArrayList
<>();
for
(
ColorSchemaColumn
column
:
new
ColorSchemaReader
().
getDeprecatedColumns
(
overlay
))
{
result
.
add
(
column
.
name
());
}
return
result
;
}
catch
(
IOException
|
InvalidColorSchemaException
e
)
{
throw
new
InvalidStateException
(
e
);
}
}
public
List
<
Map
<
String
,
Object
>>
getOverlayElements
(
String
projectId
,
int
overlayId
,
String
columns
)
throws
QueryException
{
...
...
@@ -130,28 +147,27 @@ public class OverlayRestImpl extends BaseRestImpl {
return
result
;
}
public
Map
<
String
,
Object
>
getOverlayById
(
String
projectId
,
String
overlayId
)
public
Map
<
String
,
Object
>
getOverlayById
(
String
projectId
,
Integer
overlayId
)
throws
QueryException
{
Model
model
=
getModelService
().
getLastModelByProjectId
(
projectId
);
if
(
model
==
null
)
{
throw
new
QueryException
(
"Project with given id doesn't exist"
);
}
Layout
overlay
=
layoutService
.
getLayoutById
(
Integer
.
valueOf
(
overlayId
)
)
;
Layout
overlay
=
layoutService
.
getLayoutById
(
overlayId
);
if
(
overlay
==
null
)
{
throw
new
QueryException
(
"Overlay with given id doesn't exist"
);
}
return
overlayToMap
(
overlay
);
}
public
FileEntry
getOverlaySource
(
String
projectId
,
String
overlayId
)
public
FileEntry
getOverlaySource
(
String
projectId
,
Integer
overlayId
)
throws
QueryException
{
Model
model
=
getModelService
().
getLastModelByProjectId
(
projectId
);
if
(
model
==
null
)
{
throw
new
QueryException
(
"Project with given id doesn't exist"
);
}
try
{
int
id
=
Integer
.
parseInt
(
overlayId
);
Layout
layout
=
layoutService
.
getLayoutById
(
id
);
Layout
layout
=
layoutService
.
getLayoutById
(
overlayId
);
if
(
layout
==
null
)
{
throw
new
QueryException
(
"Invalid overlay id"
);
}
...
...
@@ -163,13 +179,12 @@ public class OverlayRestImpl extends BaseRestImpl {
}
}
public
Map
<
String
,
Object
>
updateOverlay
(
String
overlayId
,
Map
<
String
,
Object
>
overlayData
)
throws
QueryException
{
public
Map
<
String
,
Object
>
updateOverlay
(
Integer
overlayId
,
Map
<
String
,
Object
>
overlayData
)
throws
QueryException
{
if
(
overlayData
==
null
)
{
throw
new
QueryException
(
"overlay field cannot be undefined"
);
}
try
{
int
id
=
Integer
.
parseInt
(
overlayId
);
Layout
layout
=
layoutService
.
getLayoutById
(
id
);
Layout
layout
=
layoutService
.
getLayoutById
(
overlayId
);
if
(
layout
==
null
)
{
throw
new
ObjectNotFoundException
(
"overlay doesn't exist"
);
}
...
...
@@ -215,15 +230,14 @@ public class OverlayRestImpl extends BaseRestImpl {
}
}
public
Map
<
String
,
Object
>
removeOverlay
(
String
projectId
,
String
overlayId
)
public
Map
<
String
,
Object
>
removeOverlay
(
String
projectId
,
Integer
overlayId
)
throws
QueryException
,
IOException
{
Project
project
=
getProjectService
().
getProjectByProjectId
(
projectId
);
if
(
project
==
null
)
{
throw
new
ObjectNotFoundException
(
"Project with given id doesn't exist"
);
}