Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
libraries
Normalizer Service Configuration
Commits
18c00ddc
Commit
18c00ddc
authored
Nov 02, 2020
by
Jonas Waeber
Browse files
Catch resource without type error!
parent
4e2f5c34
Pipeline
#16451
passed with stage
in 2 minutes and 24 seconds
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
src/main/kotlin/ch/memobase/rdf/InvalidInputException.kt
0 → 100644
View file @
18c00ddc
package
ch.memobase.rdf
class
InvalidInputException
(
message
:
String
)
:
Exception
(
message
)
src/main/kotlin/ch/memobase/rdf/MemobaseModel.kt
View file @
18c00ddc
...
...
@@ -24,8 +24,12 @@ class MemobaseModel : ModelCom(Factory.createGraphMem()) {
fun
listRicoResourceSubjects
():
Iterable
<
RicoResource
>
{
return
this
.
listSubjects
().
mapWith
{
try
{
RicoResource
(
it
)
}.
toList
()
}
catch
(
ex
:
InvalidInputException
)
{
null
}
}.
toList
().
filterNotNull
()
}
override
fun
toString
():
String
{
...
...
src/main/kotlin/ch/memobase/rdf/RicoResource.kt
View file @
18c00ddc
...
...
@@ -8,6 +8,7 @@ import org.apache.jena.rdf.model.RDFNode
import
org.apache.jena.rdf.model.Statement
import
org.apache.jena.riot.RDFDataMgr
import
org.apache.jena.riot.RDFFormat
import
org.apache.logging.log4j.LogManager
import
org.memobase.rdf.RDF
import
org.memobase.rdf.RICO
...
...
@@ -17,9 +18,21 @@ class RicoResource(val resource: Resource) {
resource
.
addProperty
(
RDF
.
type
,
rdfType
).
addProperty
(
RICO
.
type
,
ricoType
)
)
private
var
rdfType
=
resource
.
getProperty
(
RDF
.
type
).
resource
private
val
log
=
LogManager
.
getLogger
(
"RicoResource"
)
private
var
rdfType
=
retrieveRdfType
(
resource
)
private
val
ricoType
:
String
?
=
resource
.
getProperty
(
RICO
.
type
)
?.
string
private
fun
retrieveRdfType
(
resource
:
Resource
):
Resource
{
return
try
{
resource
.
getProperty
(
RDF
.
type
).
resource
}
catch
(
ex
:
IllegalStateException
)
{
val
message
=
"Resource without a ricoType: $resource."
+
ex
.
localizedMessage
log
.
error
(
message
)
throw
InvalidInputException
(
message
)
}
}
private
fun
getLabel
():
String
{
return
when
(
rdfType
)
{
RICO
.
Identifier
->
getStringLiteral
(
RICO
.
identifier
).
orEmpty
()
...
...
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