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
b9d175da
Commit
b9d175da
authored
Oct 25, 2019
by
Piotr Gawron
Browse files
annotators provide information about type and source
parent
d231b8bd
Changes
18
Show whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java
View file @
b9d175da
...
...
@@ -12,6 +12,7 @@ import lcsb.mapviewer.annotation.cache.*;
import
lcsb.mapviewer.annotation.data.Chebi
;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.*
;
import
lcsb.mapviewer.model.map.species.Chemical
;
import
lcsb.mapviewer.model.user.annotator.*
;
...
...
@@ -449,7 +450,8 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
element
.
addMiriamData
(
chebi
);
return
annotateElement
(
element
,
chebi
,
parameters
);
}
else
{
logger
.
warn
(
element
.
getElementTag
()
+
"Chemical name cannot be found in chebi: "
+
name
);
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"Chemical name cannot be found in chebi: "
+
name
);
return
false
;
}
}
catch
(
Exception
e
)
{
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java
View file @
b9d175da
...
...
@@ -10,13 +10,14 @@ import lcsb.mapviewer.common.comparator.StringSetComparator;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical
;
import
lcsb.mapviewer.model.LogMarker
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.*
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.*
;
import
lcsb.mapviewer.model.map.species.field.UniprotRecord
;
import
lcsb.mapviewer.model.user.AnnotatorParamDefinition
;
import
lcsb.mapviewer.model.user.annotator.*
;
import
lcsb.mapviewer.modelutils.map.ElementUtils
;
/**
* Interface that allows to annotate {@link BioEntity elements} in the system.
...
...
@@ -132,7 +133,7 @@ public abstract class ElementAnnotator extends CachableInterface {
AnnotatorData
parameters
)
throws
AnnotatorException
;
public
boolean
annotateElement
(
BioEntityProxy
element
,
String
name
,
AnnotatorData
parameters
)
public
boolean
annotateElement
(
BioEntityProxy
element
,
String
name
,
AnnotatorData
parameters
)
throws
AnnotatorException
{
throw
new
NotImplementedException
();
}
...
...
@@ -353,8 +354,10 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
return
originalBioEntity
.
getMiriamData
().
contains
(
copy
)
||
originalBioEntity
.
getMiriamData
().
contains
(
copy2
);
}
public
String
getElementTag
()
{
return
new
ElementUtils
().
getElementTag
(
originalBioEntity
,
ElementAnnotator
.
this
);
public
LogMarker
getLogMarker
(
ProjectLogEntryType
type
)
{
LogMarker
result
=
new
LogMarker
(
type
,
originalBioEntity
);
result
.
getEntry
().
setSource
(
ElementAnnotator
.
this
.
getClass
().
getSimpleName
());
return
result
;
}
public
boolean
isElement
()
{
...
...
@@ -408,7 +411,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
set2
.
addAll
(
oldCollection
);
if
(
stringSetComparator
.
compare
(
set1
,
set2
)
!=
0
)
{
logger
.
warn
(
getElementTag
()
+
field
.
getCommonName
()
+
" don't match: \""
+
set1
+
"\", \""
+
set2
+
"\""
);
logger
.
warn
(
getLogMarker
(
ProjectLogEntryType
.
ANNOTATION_CONFLICT
),
field
.
getCommonName
()
+
" don't match: \""
+
set1
+
"\", \""
+
set2
+
"\""
);
return
false
;
}
return
true
;
...
...
@@ -440,7 +444,8 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
if
(
oldValue
==
null
||
oldValue
.
trim
().
equals
(
""
)
||
oldValue
.
equals
(
newValue
))
{
return
true
;
}
else
{
logger
.
warn
(
getElementTag
(
field
)
+
" doesn't match: \""
+
newValue
+
"\", \""
+
oldValue
+
"\""
);
logger
.
warn
(
getLogMarker
(
ProjectLogEntryType
.
ANNOTATION_CONFLICT
),
field
.
getCommonName
()
+
" doesn't match: \""
+
newValue
+
"\", \""
+
oldValue
+
"\""
);
return
false
;
}
}
...
...
@@ -455,15 +460,12 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
if
(
oldValue
==
null
||
oldValue
==
0
||
oldValue
.
toString
().
equals
(
newValue
))
{
return
true
;
}
else
{
logger
.
warn
(
getElementTag
(
field
)
+
" doesn't match: \""
+
newValue
+
"\", \""
+
oldValue
+
"\""
);
logger
.
warn
(
getLogMarker
(
ProjectLogEntryType
.
ANNOTATION_CONFLICT
),
field
.
getCommonName
()
+
" doesn't match: \""
+
newValue
+
"\", \""
+
oldValue
+
"\""
);
return
false
;
}
}
private
String
getElementTag
(
BioEntityField
field
)
{
return
getElementTag
()
+
" "
+
field
.
getCommonName
();
}
public
void
setFormerSymbols
(
Collection
<
String
>
formerSymbols
)
{
if
(
originalBioEntity
instanceof
Element
)
{
Element
element
=
(
Element
)
originalBioEntity
;
...
...
@@ -521,7 +523,7 @@ public boolean annotateElement(BioEntityProxy element, String name, AnnotatorDat
try
{
md
=
MiriamType
.
getMiriamByUri
(
"urn:miriam:"
+
generalIdentifier
);
}
catch
(
InvalidArgumentException
e1
)
{
logger
.
warn
(
get
ElementTag
()
+
"Unknown miriam uri: "
+
generalIdentifier
);
logger
.
warn
(
get
LogMarker
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
),
"Unknown miriam uri: "
+
generalIdentifier
);
}
}
addMiriamData
(
md
);
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java
View file @
b9d175da
...
...
@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.services.*;
import
lcsb.mapviewer.common.XmlParser
;
import
lcsb.mapviewer.common.exception.InvalidXmlSchemaException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.species.*
;
...
...
@@ -134,7 +135,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
if
(
node
.
getNodeName
().
equals
(
"data"
))
{
String
error
=
XmlParser
.
getNodeAttr
(
"error"
,
node
);
if
(
error
!=
null
&&
!
error
.
isEmpty
())
{
logger
.
warn
(
element
.
get
ElementTag
()
+
error
);
logger
.
warn
(
element
.
get
LogMarker
(
ProjectLogEntryType
.
OTHER
),
error
);
}
String
dbname
=
XmlParser
.
getNodeAttr
(
"dbname"
,
node
);
...
...
@@ -188,8 +189,8 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
}
return
true
;
}
catch
(
WrongResponseCodeIOException
e
)
{
logger
.
warn
(
element
.
getElementTag
()
+
"Cannot find information for ensembl: "
+
identifier
.
getResource
());
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"Cannot find information for ensembl: "
+
identifier
.
getResource
());
return
false
;
}
catch
(
Exception
e
)
{
throw
new
AnnotatorException
(
e
);
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java
View file @
b9d175da
...
...
@@ -16,6 +16,8 @@ import lcsb.mapviewer.annotation.data.EntrezData;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.XmlParser
;
import
lcsb.mapviewer.common.exception.*
;
import
lcsb.mapviewer.model.LogMarker
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.species.*
;
...
...
@@ -125,8 +127,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
public
boolean
annotateElement
(
BioEntityProxy
element
,
MiriamData
identifier
,
AnnotatorData
parameters
)
throws
AnnotatorException
{
if
(
identifier
.
getDataType
().
equals
(
MiriamType
.
ENTREZ
))
{
String
prefix
=
element
.
getElementTag
();
EntrezData
data
=
getEntrezForMiriamData
(
identifier
,
prefix
);
EntrezData
data
=
getEntrezForMiriamData
(
identifier
,
element
.
getLogMarker
(
ProjectLogEntryType
.
OTHER
));
if
(
data
!=
null
)
{
element
.
setSymbol
(
data
.
getSymbol
());
...
...
@@ -185,7 +186,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
* thrown when there is a problem with obtaining data from entrez
* database
*/
EntrezData
getEntrezForMiriamData
(
MiriamData
entrezMiriamData
,
String
prefix
)
throws
AnnotatorException
{
EntrezData
getEntrezForMiriamData
(
MiriamData
entrezMiriamData
,
LogMarker
marker
)
throws
AnnotatorException
{
EntrezData
result
=
entrezSerializer
.
xmlToObject
(
super
.
getCacheNode
(
ENTREZ_DATA_PREFIX
+
entrezMiriamData
.
getResource
()));
if
(
result
==
null
)
{
...
...
@@ -199,13 +200,15 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
if
(
response
!=
null
)
{
Node
errorNode
=
XmlParser
.
getNode
(
"Error"
,
response
.
getChildNodes
());
if
(
errorNode
!=
null
)
{
logger
.
warn
(
prefix
+
" Invalid "
+
MiriamType
.
ENTREZ
+
" identifier: \""
+
entrezMiriamData
.
getResource
()
+
"\""
);
LogMarker
m
=
new
LogMarker
(
marker
);
m
.
getEntry
().
setType
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
);
logger
.
warn
(
m
,
" Invalid "
+
MiriamType
.
ENTREZ
+
" identifier: \""
+
entrezMiriamData
.
getResource
()
+
"\""
);
return
null
;
}
}
else
{
logger
.
warn
(
prefix
+
"Problematic entrez response for identifier: \""
+
entrezMiriamData
.
getResource
()
+
"\""
);
LogMarker
m
=
new
LogMarker
(
marker
);
m
.
getEntry
().
setType
(
ProjectLogEntryType
.
OTHER
);
logger
.
warn
(
m
,
"Problematic entrez response for identifier: \""
+
entrezMiriamData
.
getResource
()
+
"\""
);
return
null
;
}
...
...
@@ -294,7 +297,9 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic
setCacheValue
(
ENTREZ_DATA_PREFIX
+
entrezMiriamData
.
getResource
(),
entrezSerializer
.
objectToString
(
result
));
}
catch
(
WrongResponseCodeIOException
e
)
{
if
(
e
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_BAD_REQUEST
)
{
logger
.
warn
(
prefix
+
" Invalid "
+
MiriamType
.
ENTREZ
.
getCommonName
()
+
" identifier found"
);
LogMarker
m
=
new
LogMarker
(
marker
);
m
.
getEntry
().
setType
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
);
logger
.
warn
(
m
,
" Invalid "
+
MiriamType
.
ENTREZ
.
getCommonName
()
+
" identifier found"
);
}
else
{
throw
new
AnnotatorException
(
e
);
}
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java
View file @
b9d175da
...
...
@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.XmlParser
;
import
lcsb.mapviewer.common.exception.*
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.species.*
;
...
...
@@ -96,7 +97,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
if
(
count
==
null
||
count
.
equals
(
""
)
||
count
.
equals
(
"0"
))
{
// print warn info when we have only hgnc identifiers (or no
// identifiers at all)
logger
.
warn
(
element
.
getElementTag
()
+
"Cannot find information for element."
);
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"Cannot find information for element."
);
return
false
;
}
else
{
Node
entry
=
XmlParser
.
getNode
(
"doc"
,
result
.
getChildNodes
());
...
...
@@ -173,7 +175,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
return
true
;
}
}
catch
(
WrongResponseCodeIOException
e
)
{
logger
.
warn
(
element
.
getElementTag
()
+
"Cannot find information for element."
);
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"Cannot find information for element."
);
return
false
;
}
catch
(
Exception
e
)
{
throw
new
AnnotatorException
(
e
);
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/PdbAnnotator.java
View file @
b9d175da
...
...
@@ -16,6 +16,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.*
;
import
lcsb.mapviewer.model.map.species.*
;
import
lcsb.mapviewer.model.map.species.field.Structure
;
...
...
@@ -107,7 +108,8 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
try
{
Collection
<
Structure
>
structures
=
uniProtToPdb
(
identifier
);
if
(
structures
.
size
()
==
0
)
{
logger
.
warn
(
bioEntity
.
getElementTag
()
+
" No PDB mapping for UniProt ID: "
+
identifier
.
getResource
());
logger
.
warn
(
bioEntity
.
getLogMarker
(
ProjectLogEntryType
.
OTHER
),
" No PDB mapping for UniProt ID: "
+
identifier
.
getResource
());
return
false
;
}
else
{
// add the annotations to the set of annotation irrespective on
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java
View file @
b9d175da
...
...
@@ -15,6 +15,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.MinervaLoggerAppender
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
...
...
@@ -286,17 +287,19 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService
unknown
=
true
;
}
if
(
unknown
)
{
logger
.
warn
(
element
.
get
ElementTag
()
+
"Unknown field in recon annotation: \""
+
key
+
"\" (value: "
+
value
+
")"
);
logger
.
warn
(
element
.
get
LogMarker
(
ProjectLogEntryType
.
OTHER
),
"Unknown field in recon annotation: \""
+
key
+
"\" (value: "
+
value
+
")"
);
}
}
return
true
;
}
else
{
logger
.
warn
(
element
.
getElementTag
()
+
"No recon annotations \""
+
identifier
.
getResource
()
+
"\""
);
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"No recon annotations \""
+
identifier
.
getResource
()
+
"\""
);
return
false
;
}
}
else
{
logger
.
warn
(
element
.
getElementTag
()
+
"No recon annotations \""
+
identifier
.
getResource
()
+
"\""
);
logger
.
warn
(
element
.
getLogMarker
(
ProjectLogEntryType
.
CANNOT_FIND_INFORMATION
),
"No recon annotations \""
+
identifier
.
getResource
()
+
"\""
);
return
false
;
}
}
catch
(
IOException
e
)
{
...
...
@@ -370,8 +373,8 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService
}
else
if
(
value
.
startsWith
(
"K"
))
{
md
=
new
MiriamData
(
MiriamType
.
KEGG_ORTHOLOGY
,
value
);
}
else
{
logger
.
warn
(
element
.
get
ElementTag
()
+
"Unknown Kegg identifier type (only Kegg compounds and reactions are supported): \""
+
value
+
"\""
);
logger
.
warn
(
element
.
get
LogMarker
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
),
"Unknown Kegg identifier type (only Kegg compounds and reactions are supported): \""
+
value
+
"\""
);
}
return
md
;
}
...
...
annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java
View file @
b9d175da
...
...
@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import
lcsb.mapviewer.annotation.services.*
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.species.*
;
...
...
@@ -106,7 +107,8 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
}
else
{
// this means that entry with a given uniprot id doesn't exist
if
(
object
.
contains
(
identifier
))
{
logger
.
warn
(
object
.
getElementTag
()
+
" Invalid uniprot id: "
+
identifier
);
logger
.
warn
(
object
.
getLogMarker
(
ProjectLogEntryType
.
INVALID_IDENTIFIER
),
" Invalid uniprot id: "
+
identifier
);
}
return
false
;
}
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotatorTest.java
View file @
b9d175da
...
...
@@ -192,7 +192,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
nullable
(
String
.
class
))).
thenReturn
(
response
);
entrezAnnotator
.
setWebPageDownloader
(
mockDownloader
);
EntrezData
data
=
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
""
);
EntrezData
data
=
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
null
);
boolean
ensembl
=
false
;
boolean
hgnc
=
false
;
for
(
MiriamData
md
:
data
.
getMiriamData
())
{
...
...
@@ -223,7 +223,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
WebPageDownloader
mockDownloader
=
Mockito
.
mock
(
WebPageDownloader
.
class
);
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
nullable
(
String
.
class
))).
thenReturn
(
response
);
entrezAnnotator
.
setWebPageDownloader
(
mockDownloader
);
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
""
);
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
null
);
}
finally
{
entrezAnnotator
.
setWebPageDownloader
(
downloader
);
entrezAnnotator
.
setCache
(
cache
);
...
...
@@ -241,7 +241,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions {
when
(
mockDownloader
.
getFromNetwork
(
anyString
(),
anyString
(),
nullable
(
String
.
class
)))
.
thenThrow
(
new
WrongResponseCodeIOException
(
null
,
404
));
entrezAnnotator
.
setWebPageDownloader
(
mockDownloader
);
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
""
);
entrezAnnotator
.
getEntrezForMiriamData
(
new
MiriamData
(),
null
);
}
finally
{
entrezAnnotator
.
setWebPageDownloader
(
downloader
);
entrezAnnotator
.
setCache
(
cache
);
...
...
commons/src/main/java/lcsb/mapviewer/common/exception/NotImplementedException.java
View file @
b9d175da
...
...
@@ -3,7 +3,7 @@ package lcsb.mapviewer.common.exception;
/**
* Exception that should be thrown when application/class/method entered to the
* part of code that wasn't implemented (for instance the class is not abstract,
* but method should be considered abstrac...).
* but method should be considered abstrac
t
...).
*
* @author Piotr Gawron
*
...
...
model/src/main/java/lcsb/mapviewer/model/LogMarker.java
View file @
b9d175da
...
...
@@ -14,7 +14,7 @@ public class LogMarker implements Marker {
private
ProjectLogEntry
entry
;
public
LogMarker
(
String
type
,
BioEntity
bioEntity
)
{
public
LogMarker
(
ProjectLogEntryType
type
,
BioEntity
bioEntity
)
{
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
type
);
if
(
bioEntity
!=
null
)
{
...
...
@@ -26,6 +26,10 @@ public class LogMarker implements Marker {
}
}
public
LogMarker
(
LogMarker
marker
)
{
entry
=
new
ProjectLogEntry
(
marker
.
getEntry
());
}
@Override
public
Marker
addParents
(
Marker
...
markers
)
{
throw
new
NotImplementedException
();
...
...
model/src/main/java/lcsb/mapviewer/model/ProjectLogEntry.java
View file @
b9d175da
...
...
@@ -20,7 +20,8 @@ public class ProjectLogEntry implements Serializable {
private
String
severity
;
@Column
(
nullable
=
false
)
private
String
type
;
@Enumerated
(
EnumType
.
STRING
)
private
ProjectLogEntryType
type
;
private
String
objectIdentifier
;
...
...
@@ -28,6 +29,8 @@ public class ProjectLogEntry implements Serializable {
private
String
mapName
;
private
String
source
;
@Column
(
nullable
=
false
)
private
String
content
;
...
...
@@ -35,6 +38,17 @@ public class ProjectLogEntry implements Serializable {
}
public
ProjectLogEntry
(
ProjectLogEntry
entry
)
{
this
.
project
=
entry
.
getProject
();
this
.
severity
=
entry
.
getSeverity
();
this
.
type
=
entry
.
getType
();
this
.
objectIdentifier
=
entry
.
getObjectIdentifier
();
this
.
objectClass
=
entry
.
getObjectClass
();
this
.
mapName
=
entry
.
getMapName
();
this
.
source
=
entry
.
getSource
();
this
.
content
=
entry
.
getContent
();
}
public
String
getContent
()
{
return
content
;
}
...
...
@@ -75,14 +89,6 @@ public class ProjectLogEntry implements Serializable {
this
.
severity
=
severity
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Project
getProject
()
{
return
project
;
}
...
...
@@ -91,4 +97,20 @@ public class ProjectLogEntry implements Serializable {
this
.
project
=
project
;
}
public
String
getSource
()
{
return
source
;
}
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
}
public
ProjectLogEntryType
getType
()
{
return
type
;
}
public
void
setType
(
ProjectLogEntryType
type
)
{
this
.
type
=
type
;
}
}
model/src/main/java/lcsb/mapviewer/model/ProjectLogEntryType.java
0 → 100644
View file @
b9d175da
package
lcsb.mapviewer.model
;
public
enum
ProjectLogEntryType
{
OTHER
,
CANNOT_FIND_INFORMATION
,
INVALID_IDENTIFIER
,
ANNOTATION_CONFLICT
,
OUT_OF_MEMORY
,
DATABASE_PROBLEM
}
persist/src/main/resources/db/migration/15.0.0/V15.0.1.20191025_3__structured_log.sql
View file @
b9d175da
...
...
@@ -29,3 +29,4 @@ insert into project_log_entry_table (content, project_id, severity, type) SELECT
insert
into
project_log_entry_table
(
content
,
project_id
,
severity
,
type
)
SELECT
s
.
token
,
id
,
'ERROR'
,
'OTHER'
from
project_table
t
,
unnest
(
string_to_array
(
t
.
errors
,
E
'
\n
'
))
s
(
token
);
alter
table
project_table
drop
column
warnings
;
alter
table
project_table
drop
column
errors
;
alter
table
project_log_entry_table
add
column
source
varchar
;
persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java
View file @
b9d175da
...
...
@@ -7,8 +7,7 @@ import org.apache.logging.log4j.Logger;
import
org.junit.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.ProjectLogEntry
;
import
lcsb.mapviewer.model.*
;
import
lcsb.mapviewer.model.map.OverviewImage
;
import
lcsb.mapviewer.model.map.OverviewModelLink
;
import
lcsb.mapviewer.model.map.layout.*
;
...
...
@@ -205,7 +204,7 @@ public class ProjectDaoTest extends PersistTestFunctions {
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setContent
(
"content"
);
entry
.
setSeverity
(
"WARN"
);
entry
.
setType
(
"
OTHER
"
);
entry
.
setType
(
ProjectLogEntryType
.
OTHER
);
project
.
addLogEntry
(
entry
);
project
.
setOwner
(
userDao
.
getUserByLogin
(
ADMIN_BUILT_IN_LOGIN
));
assertEquals
(
1
,
project
.
getLogEntries
().
size
());
...
...
service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java
View file @
b9d175da
...
...
@@ -23,6 +23,7 @@ import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator;
import
lcsb.mapviewer.commands.*
;
import
lcsb.mapviewer.common.*
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.converter.*
;
import
lcsb.mapviewer.converter.graphics.DrawingException
;
import
lcsb.mapviewer.converter.graphics.MapGenerator
;
...
...
@@ -407,7 +408,7 @@ public class ProjectService implements IProjectService {
logger
.
error
(
"Out of memory"
,
oome
);
if
(
project
!=
null
)
{
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
"
OUT_OF_MEMORY
"
);
entry
.
setType
(
ProjectLogEntryType
.
OUT_OF_MEMORY
);
entry
.
setSeverity
(
"ERROR"
);
entry
.
setContent
(
"Out of memory: "
+
oome
.
getMessage
());
project
.
addLogEntry
(
entry
);
...
...
@@ -608,7 +609,7 @@ public class ProjectService implements IProjectService {
Project
project
=
getProjectByProjectId
(
originalProject
.
getProjectId
());
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
"
OTHER
"
);
entry
.
setType
(
ProjectLogEntryType
.
OTHER
);
entry
.
setSeverity
(
"ERROR"
);
entry
.
setContent
(
"Severe problem with removing object. Underlaying eror:\n"
+
exception
.
getMessage
()
+
"\nMore information can be found in log file."
);
...
...
@@ -1073,7 +1074,7 @@ public class ProjectService implements IProjectService {
Project
project
=
getProjectByProjectId
(
params
.
getProjectId
());
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
"
DATABASE_PROBLEM
"
);
entry
.
setType
(
ProjectLogEntryType
.
DATABASE_PROBLEM
);
entry
.
setSeverity
(
"ERROR"
);
entry
.
setContent
(
"Problem with uploading to database. "
+
"You might violated some unhandled constraints or you run out of memory. Underlaying eror:\n"
...
...
@@ -1107,7 +1108,7 @@ public class ProjectService implements IProjectService {
Project
p
=
projectDao
.
getProjectByProjectId
(
params
.
getProjectId
());
if
(
p
!=
null
)
{
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
"
OTHER
"
);
entry
.
setType
(
ProjectLogEntryType
.
OTHER
);
entry
.
setSeverity
(
"ERROR"
);
entry
.
setContent
(
"Problem with uploading map: "
+
e
.
getMessage
()
+
". More details can be found in log file."
);
p
.
addLogEntry
(
entry
);
...
...
@@ -1187,7 +1188,7 @@ public class ProjectService implements IProjectService {
}
if
(
entry
==
null
)
{
entry
=
new
ProjectLogEntry
();
entry
.
setType
(
"
OTHER
"
);
entry
.
setType
(
ProjectLogEntryType
.
OTHER
);
}
entry
.
setSeverity
(
severity
);
entry
.
setContent
(
event
.
getMessage
().
getFormattedMessage
());
...
...
service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java
View file @
b9d175da
...
...
@@ -665,12 +665,12 @@ public class ProjectServiceTest extends ServiceTestFunctions {
appender
.
append
(
Log4jLogEvent
.
newBuilder
()
.
setLevel
(
Level
.
WARN
)
.
setMessage
(
new
SimpleMessage
(
"Hello world"
))
.
setMarker
(
new
LogMarker
(
"type"
,
protein
))
.
setMarker
(
new
LogMarker
(
ProjectLogEntryType
.
OTHER
,
protein
))
.
build
());
appender
.
append
(
Log4jLogEvent
.
newBuilder
()
.
setLevel
(
Level
.
ERROR
)
.
setMessage
(
new
SimpleMessage
(
"Hello world 2"
))
.
setMarker
(
new
LogMarker
(
"type2"
,
protein
))
.
setMarker
(
new
LogMarker
(
ProjectLogEntryType
.
OTHER
,
protein
))
.
build
());
appender
.
append
(
Log4jLogEvent
.
newBuilder
()
.
setLevel
(
Level
.
ERROR
)
...
...
web/src/main/java/lcsb/mapviewer/web/bean/utils/StartupBean.java
View file @
b9d175da
...
...
@@ -137,7 +137,7 @@ public class StartupBean {
if
(!
ProjectStatus
.
DONE
.
equals
(
project
.
getStatus
())
&&
!
ProjectStatus
.
FAIL
.
equals
(
project
.
getStatus
()))
{
ProjectLogEntry
entry
=
new
ProjectLogEntry
();
entry
.
setSeverity
(
"ERROR"
);
entry
.
setType
(
"
OTHER
"
);
entry
.
setType
(
ProjectLogEntryType
.
OTHER
);
entry
.
setContent
(
"Project uploading was interrupted by application restart (at the stage: "
+
project
.
getStatus
()
+
")."
);
project
.
setStatus
(
ProjectStatus
.
FAIL
);
...
...
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