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
Raphael
histream
Commits
247cf35f
Commit
247cf35f
authored
Jul 21, 2015
by
rwm
Browse files
scheme support for concepts/ontologies
parent
10f3c337
Changes
6
Hide whitespace changes
Inline
Side-by-side
HIStream-SKOS/examples/test-ontology.ttl
View file @
247cf35f
...
...
@@ -84,6 +84,7 @@ dwh:String a owl:Restriction ;
:
OtherSub
a
skos:
Concept
;
skos:inScheme :
OtherScheme
;
skos:inScheme :
TestScheme
;
skos:broader :
OtherTop
;
skos:
prefLabel
"OtherSub_label_en"
@en
;
skos:
notation
"other"
.
HIStream-SKOS/src/main/java/de/sekmi/histream/ontology/skos/ConceptImpl.java
View file @
247cf35f
...
...
@@ -120,6 +120,17 @@ public class ConceptImpl implements Concept {
throw
new
OntologyException
(
e
);
}
}
@Override
public
String
[]
getSchemes
()
throws
OntologyException
{
ArrayList
<
String
>
ids
=
new
ArrayList
<>();
try
{
store
.
forEachObject
(
this
.
res
,
SKOS
.
IN_SCHEME
,
scheme
->
ids
.
add
(
scheme
.
stringValue
()));
}
catch
(
RepositoryException
e
)
{
throw
new
OntologyException
(
e
);
}
return
ids
.
toArray
(
new
String
[
ids
.
size
()]);
}
...
...
HIStream-SKOS/src/main/java/de/sekmi/histream/ontology/skos/Store.java
View file @
247cf35f
...
...
@@ -170,8 +170,10 @@ public class Store implements Ontology, Plugin {
// if this.scheme is null, top concepts of all schemes are returned
return
getRelatedConcepts
(
this
.
scheme
,
SKOS
.
HAS_TOP_CONCEPT
);
}
public
Concept
[]
getTopConcepts
(
String
schemeURI
)
throws
OntologyException
{
return
getRelatedConcepts
(
repo
.
getValueFactory
().
createURI
(
schemeURI
),
SKOS
.
HAS_TOP_CONCEPT
);
@Override
public
Concept
[]
getTopConcepts
(
String
scheme
)
throws
OntologyException
{
return
getRelatedConcepts
(
repo
.
getValueFactory
().
createURI
(
scheme
),
SKOS
.
HAS_TOP_CONCEPT
);
}
private
Concept
[]
getRelatedConcepts
(
Resource
subject
,
URI
predicate
)
throws
OntologyException
{
RepositoryResult
<
Statement
>
rr
;
...
...
HIStream-SKOS/src/test/java/de/sekmi/histream/ontology/skos/OntologyTest.java
View file @
247cf35f
...
...
@@ -24,6 +24,16 @@ public class OntologyTest {
store
.
setConceptScheme
(
NS_PREFIX
+
"TestScheme"
);
}
@Test
public
void
testGetSchemes
()
throws
OntologyException
{
Concept
c
=
store
.
getConceptByNotation
(
"other"
);
Assert
.
assertNotNull
(
c
);
String
[]
schemes
=
c
.
getSchemes
();
Assert
.
assertNotNull
(
schemes
);
Assert
.
assertEquals
(
2
,
schemes
.
length
);
// TODO verify scheme set (order is irrelevant)
}
@Test
public
void
getConceptByIdTest
()
throws
OntologyException
{
Assert
.
assertNull
(
store
.
getConceptByNotation
(
"notfound"
));
...
...
@@ -126,7 +136,6 @@ public class OntologyTest {
Concept
c
=
store
.
getConceptByNotation
(
"Type"
);
System
.
out
.
println
(
"Concept:"
+
c
);
}
}
}
histream-core/src/main/java/de/sekmi/histream/ontology/Concept.java
View file @
247cf35f
...
...
@@ -41,6 +41,14 @@ public interface Concept {
*/
String
[]
getIDs
()
throws
OntologyException
;
/**
* Get the schemes to which this concept belongs.
* A concept may belong to no scheme. In this case an empty array is returned.
* @return scheme URIs
* @throws OntologyException on error
*/
String
[]
getSchemes
()
throws
OntologyException
;
/**
* Get the concept's preferred label for a given locale.
*
...
...
histream-core/src/main/java/de/sekmi/histream/ontology/Ontology.java
View file @
247cf35f
...
...
@@ -23,6 +23,13 @@ public interface Ontology extends Closeable{
* @throws OntologyException for ontology errors
*/
public
Concept
[]
getTopConcepts
()
throws
OntologyException
;
/**
* Return the top concepts of this ontology in the specified scheme
* @param scheme scheme to which all returned top concepts belong
* @return top concepts
* @throws OntologyException for ontology errors
*/
public
Concept
[]
getTopConcepts
(
String
scheme
)
throws
OntologyException
;
/**
* Returns the time when this ontology was last modified.
...
...
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