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
0dbd7728
Commit
0dbd7728
authored
Feb 19, 2018
by
Piotr Gawron
Browse files
transaction was not available during loading war file in tomcat
parent
6959d58e
Pipeline
#3659
passed with stage
in 1 minute and 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java
View file @
0dbd7728
...
...
@@ -1459,26 +1459,26 @@ public class ProjectService implements IProjectService {
userService
.
updateUser
(
dbUser
);
user
.
setAnnotationSchema
(
annotationSchema
);
}
@Override
public
List
<
UserAnnotatorsParam
>
getAnnotatorsParams
(
User
user
)
{
User
dbUser
=
userDao
.
getById
(
user
.
getId
());
UserAnnotationSchema
annotationSchema
=
dbUser
.
getAnnotationSchema
();
if
(
annotationSchema
==
null
)
{
annotationSchema
=
new
UserAnnotationSchema
();
dbUser
.
setAnnotationSchema
(
annotationSchema
);
}
/*
* Hibernate lazy loads collections so each element needs to be accessed
* to be
loaded now or otherwise the data might not be available
* when accessed because
the session might not be available at that time.
*/
List
<
UserAnnotatorsParam
>
aps
=
new
ArrayList
<>();
for
(
UserAnnotatorsParam
ap:
annotationSchema
.
getAnnotatorsParams
())
{
aps
.
add
(
ap
);
}
return
aps
;
User
dbUser
=
userDao
.
getById
(
user
.
getId
());
UserAnnotationSchema
annotationSchema
=
dbUser
.
getAnnotationSchema
();
if
(
annotationSchema
==
null
)
{
annotationSchema
=
new
UserAnnotationSchema
();
dbUser
.
setAnnotationSchema
(
annotationSchema
);
}
/*
* Hibernate lazy loads collections so each element needs to be accessed
to be
*
loaded now or otherwise the data might not be available
when accessed because
*
the session might not be available at that time.
*/
List
<
UserAnnotatorsParam
>
aps
=
new
ArrayList
<>();
for
(
UserAnnotatorsParam
ap
:
annotationSchema
.
getAnnotatorsParams
())
{
aps
.
add
(
ap
);
}
return
aps
;
}
/**
...
...
@@ -1627,4 +1627,9 @@ public class ProjectService implements IProjectService {
this
.
taxonomyBackend
=
taxonomyBackend
;
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectDao
.
getAll
();
}
}
service/src/main/java/lcsb/mapviewer/services/interfaces/IProjectService.java
View file @
0dbd7728
...
...
@@ -22,180 +22,184 @@ import lcsb.mapviewer.services.view.ProjectView;
*/
public
interface
IProjectService
{
/**
* Returns a project with a give {@link Project#projectId project identifier}.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return project with an identifier given as parameter. Null if such project
* doesn't exist.
*/
Project
getProjectByProjectId
(
String
projectId
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Checks if project with a given {@link Project#projectId identifier} exists.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return <code>true</code> if the project with the given name exists,
* <code>false</code> otherwise
*/
boolean
projectExists
(
String
projectId
);
/**
* Returns list of all projects.
*
* @return list of all projects.
*/
List
<
Project
>
getAllProjects
(
AuthenticationToken
token
);
/**
* Returns a list of Project views for all projects.
*
* @return list of Project views for all projects
*/
List
<
ProjectView
>
getAllProjectViews
(
AuthenticationToken
token
);
/**
* Updates project.
*
* @param projectView
* project view with the data to update
*/
void
updateProject
(
ProjectView
projectView
);
/**
* Removes project from the system.
*
* @param homeDir
* directory where the system is deployed
*
* @param projectView
* information about project to remove
* @param async
* should the operation be done asynchronously
* @throws UserAccessException
*/
void
removeProject
(
ProjectView
projectView
,
String
homeDir
,
boolean
async
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Removes project from the system.
*
* @param homeDir
* directory where the system is deployed
* @param project
* object to remove
* @param async
* should the operation be done asynchronously
* @throws UserAccessException
*/
void
removeProject
(
Project
project
,
String
homeDir
,
boolean
async
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Gets view of the project by the {@link Project#projectId project
* identifier}.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return view of the project
* @throws UserAccessException
*/
ProjectView
getProjectViewByProjectId
(
String
projectId
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Adds project to the system.
*
* @param project
* object to add
*/
void
addProject
(
Project
project
);
/**
* Return the view of the project identified by database identifier.
*
* @param id
* database identifier of the project
* @return project view
* @throws UserAccessException
*/
ProjectView
getProjectViewById
(
Integer
id
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Creates project using give parameters. See {@link CreateProjectParams}.
*
* @param params
* information about project to create
* @throws SecurityException
*/
void
createProject
(
CreateProjectParams
params
)
throws
SecurityException
;
/**
* Creates empty {@link ProjectView}.
*
* @return empty {@link ProjectView}
*/
ProjectView
createEmpty
();
/**
* Creates {@link TreeNode} that contains information about all classes that
* can be annotated and associate set of
* {@link lcsb.mapviewer.annotation.services.annotators.ElementAnnotator
* ElementAnnotator} valid for these classes.
*
* @param user
* for which information should be retrieved
* @return {@link TreeNode} that contains information about all classes that
* can be annotated
*/
TreeNode
createClassAnnotatorTree
(
User
user
);
/**
* Update default set of annotators, lists of required/valid annotations for a
* given user and default params used when creating project.
*
* @param user
* user for which we updte information
* @param sbgnFormat
* new
* {@link lcsb.mapviewer.model.user.UserAnnotationSchema#sbgnFormat}
* value
* @param networkLayoutAsDefault
* new
* {@link lcsb.mapviewer.model.user.UserAnnotationSchema#networkLayoutAsDefault}
* value
* @param annotatorsTree
* {@link TreeNode} that contains information about all classes that
* can be annotated
*/
void
updateClassAnnotatorTreeForUser
(
User
user
,
TreeNode
annotatorsTree
,
boolean
sbgnFormat
,
boolean
networkLayoutAsDefault
);
/**
* Method that updates information about raw {@link Project} object.
*
* @param project
* project to update
*/
void
updateProject
(
Project
project
);
/**
* Returns content of the file that was used to create project given in the
* parameter.
*
* @param projectView
* view of the {@link Project} for which we are looking for an
* original source file
* @return content of the file that was used to create project given in the
* parameter
*/
byte
[]
getInputDataForProject
(
ProjectView
projectView
);
UserAnnotationSchema
prepareUserAnnotationSchema
(
User
user
);
/**
* Retrieves list of annotators {@link UserAnnotatorsParam parameters}
* @return
* list of annotators parameters
*/
List
<
UserAnnotatorsParam
>
getAnnotatorsParams
(
User
user
);
/**
* Returns a project with a give {@link Project#projectId project identifier}.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return project with an identifier given as parameter. Null if such project
* doesn't exist.
*/
Project
getProjectByProjectId
(
String
projectId
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Checks if project with a given {@link Project#projectId identifier} exists.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return <code>true</code> if the project with the given name exists,
* <code>false</code> otherwise
*/
boolean
projectExists
(
String
projectId
);
/**
* Returns list of all projects.
*
* @return list of all projects.
*/
List
<
Project
>
getAllProjects
(
AuthenticationToken
token
);
/**
* Returns a list of Project views for all projects.
*
* @return list of Project views for all projects
*/
List
<
ProjectView
>
getAllProjectViews
(
AuthenticationToken
token
);
/**
* Updates project.
*
* @param projectView
* project view with the data to update
*/
void
updateProject
(
ProjectView
projectView
);
/**
* Removes project from the system.
*
* @param homeDir
* directory where the system is deployed
*
* @param projectView
* information about project to remove
* @param async
* should the operation be done asynchronously
* @throws UserAccessException
*/
void
removeProject
(
ProjectView
projectView
,
String
homeDir
,
boolean
async
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Removes project from the system.
*
* @param homeDir
* directory where the system is deployed
* @param project
* object to remove
* @param async
* should the operation be done asynchronously
* @throws UserAccessException
*/
void
removeProject
(
Project
project
,
String
homeDir
,
boolean
async
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Gets view of the project by the {@link Project#projectId project identifier}.
*
* @param projectId
* {@link Project#projectId project identifier}
* @return view of the project
* @throws UserAccessException
*/
ProjectView
getProjectViewByProjectId
(
String
projectId
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Adds project to the system.
*
* @param project
* object to add
*/
void
addProject
(
Project
project
);
/**
* Return the view of the project identified by database identifier.
*
* @param id
* database identifier of the project
* @return project view
* @throws UserAccessException
*/
ProjectView
getProjectViewById
(
Integer
id
,
AuthenticationToken
token
)
throws
UserAccessException
;
/**
* Creates project using give parameters. See {@link CreateProjectParams}.
*
* @param params
* information about project to create
* @throws SecurityException
*/
void
createProject
(
CreateProjectParams
params
)
throws
SecurityException
;
/**
* Creates empty {@link ProjectView}.
*
* @return empty {@link ProjectView}
*/
ProjectView
createEmpty
();
/**
* Creates {@link TreeNode} that contains information about all classes that can
* be annotated and associate set of
* {@link lcsb.mapviewer.annotation.services.annotators.ElementAnnotator
* ElementAnnotator} valid for these classes.
*
* @param user
* for which information should be retrieved
* @return {@link TreeNode} that contains information about all classes that can
* be annotated
*/
TreeNode
createClassAnnotatorTree
(
User
user
);
/**
* Update default set of annotators, lists of required/valid annotations for a
* given user and default params used when creating project.
*
* @param user
* user for which we updte information
* @param sbgnFormat
* new
* {@link lcsb.mapviewer.model.user.UserAnnotationSchema#sbgnFormat}
* value
* @param networkLayoutAsDefault
* new
* {@link lcsb.mapviewer.model.user.UserAnnotationSchema#networkLayoutAsDefault}
* value
* @param annotatorsTree
* {@link TreeNode} that contains information about all classes that
* can be annotated
*/
void
updateClassAnnotatorTreeForUser
(
User
user
,
TreeNode
annotatorsTree
,
boolean
sbgnFormat
,
boolean
networkLayoutAsDefault
);
/**
* Method that updates information about raw {@link Project} object.
*
* @param project
* project to update
*/
void
updateProject
(
Project
project
);
/**
* Returns content of the file that was used to create project given in the
* parameter.
*
* @param projectView
* view of the {@link Project} for which we are looking for an original
* source file
* @return content of the file that was used to create project given in the
* parameter
*/
byte
[]
getInputDataForProject
(
ProjectView
projectView
);
UserAnnotationSchema
prepareUserAnnotationSchema
(
User
user
);
/**
* Retrieves list of annotators {@link UserAnnotatorsParam parameters}
*
* @return list of annotators parameters
*/
List
<
UserAnnotatorsParam
>
getAnnotatorsParams
(
User
user
);
List
<
Project
>
getAllProjects
();
}
web/src/main/java/lcsb/mapviewer/bean/utils/StartupBean.java
View file @
0dbd7728
...
...
@@ -31,137 +31,144 @@ import lcsb.mapviewer.services.interfaces.IReferenceGenomeService;
@ApplicationScoped
public
class
StartupBean
{
/**
* Default class logger.
*/
private
final
transient
Logger
logger
=
Logger
.
getLogger
(
StartupBean
.
class
);
/**
* Dao used to access information about projects.
*
*/
@ManagedProperty
(
value
=
"#{ProjectDao}"
)
private
transient
ProjectDao
projectDao
;
/**
* Service used to access configuration params from db.
*
* @see IProjectService
*/
@ManagedProperty
(
value
=
"#{ConfigurationService}"
)
private
transient
IConfigurationService
configurationService
;
/**
* Service used to access information about reference genomes.
*
* @see IReferenceGenomeService
*/
@ManagedProperty
(
value
=
"#{ReferenceGenomeService}"
)
private
transient
IReferenceGenomeService
referenceGenomeService
;
/**
* Method that process initial script of application.
*/
@PostConstruct
public
void
init
()
{
logger
.
debug
(
"Application startup script starts"
);
try
{
setInterruptedProjectsStatuses
();
Configuration
.
setxFrameDomain
(
configurationService
.
getConfigurationValue
(
ConfigurationElementType
.
X_FRAME_DOMAIN
));
removeInterruptedReferenceGenomeDownloads
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Problem running init script..."
,
e
);
}
logger
.
debug
(
"Application startup script ends"
);
}
/**
* Removes downloads of reference genomes that were interrupted by tomcat
* restart.
*/
private
void
removeInterruptedReferenceGenomeDownloads
()
{
for
(
ReferenceGenome
genome
:
referenceGenomeService
.
getDownloadedGenomes
())
{
if
(
genome
.
getDownloadProgress
()
<
IProgressUpdater
.
MAX_PROGRESS
)
{
logger
.
warn
(
"Removing genome that was interrupted: "
+
genome
);
try
{
referenceGenomeService
.
removeGenome
(
genome
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"Problem with removing genome: "
+
genome
);
}
}
}
}
/**
* Set {@link ProjectStatus#FAIL} statuses to projects that were uploading
* when application was shutdown.
*/
private
void
setInterruptedProjectsStatuses
()
{
for
(
Project
project
:
projectDao
.
getAll
())
{
if
(!
ProjectStatus
.
DONE
.
equals
(
project
.
getStatus
())
&&
!
ProjectStatus
.
FAIL
.
equals
(
project
.
getStatus
()))
{
String
errors
=
project
.
getErrors
();
if
(
errors
==
null
||
errors
.
trim
().
isEmpty
())
{
errors
=
""
;
}
else
{
errors
=
errors
.
trim
()
+
"\n"
;
}
errors
+=
"Project uploading was interrupted by application restart (at the stage: "
+
project
.
getStatus
()
+
")."
;
project
.
setStatus
(
ProjectStatus
.
FAIL
);
project
.
setErrors
(
errors
);
projectDao
.
update
(
project
);
logger
.
info
(
"Status of project: "
+
project
.
getProjectId
()
+
" changed to fail. Errors: "
+
errors
);
}
}
}
/**
* @return the configurationService
* @see #configurationService
*/
public
IConfigurationService
getConfigurationService
()
{
return
configurationService
;
}
/**
* @param configurationService
* the configurationService to set
* @see #configurationService
*/
public
void
setConfigurationService
(
IConfigurationService
configurationService
)
{
this
.
configurationService
=
configurationService
;
}
/**
* @return the referenceGenomeService
* @see #referenceGenomeService
*/
public
IReferenceGenomeService
getReferenceGenomeService
()
{
return
referenceGenomeService
;
}
/**
* @param referenceGenomeService
* the referenceGenomeService to set
* @see #referenceGenomeService
*/
public
void
setReferenceGenomeService
(
IReferenceGenomeService
referenceGenomeService
)
{
this
.
referenceGenomeService
=
referenceGenomeService
;
}
/**
* @return the projectDao
* @see #projectDao
*/
public
ProjectDao
getProjectDao
()
{
return
projectDao
;
}
/**
* @param projectDao the projectDao to set
* @see #projectDao
*/
public
void
setProjectDao
(
ProjectDao
projectDao
)
{
this
.
projectDao
=
projectDao
;
}
/**
* Default class logger.
*/
private
final
transient
Logger
logger
=
Logger
.
getLogger
(
StartupBean
.
class
);
/**
* Dao used to access information about projects.
*
*/
@ManagedProperty
(
value
=
"#{ProjectService}"
)
private
transient
IProjectService
projectService
;
/**
* Service used to access configuration params from db.
*
* @see IProjectService
*/
@ManagedProperty
(
value
=
"#{ConfigurationService}"
)
private
transient
IConfigurationService
configurationService
;
/**
* Service used to access information about reference genomes.
*
* @see IReferenceGenomeService
*/
@ManagedProperty
(
value
=
"#{ReferenceGenomeService}"
)
private
transient
IReferenceGenomeService
referenceGenomeService
;
/**
* Method that process initial script of application.
*/
@PostConstruct
public
void
init
()
{
logger
.
debug
(
"Application startup script starts"
);
setInterruptedProjectsStatuses
();
modifyXFrameDomain
();
removeInterruptedReferenceGenomeDownloads
();
logger
.
debug
(
"Application startup script ends"
);
}
private
void
modifyXFrameDomain
()
{