Commit 4a0f61a4 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

Concept restrictions partially implemented

parent 535ef3b6
......@@ -23,7 +23,8 @@
:TestEnumConcept a skos:Concept;
skos:inScheme :TestData;
dwh:valueRestriction [ a owl:Restriction ;
dwh:restriction [ a owl:Restriction ;
owl:onProperty rdf:value;
owl:oneOf ([rdf:value "1"^^xsd:string; skos:prefLabel "1_de"@de; skos:prefLabel "1_en"@en ]
[rdf:value "2"^^xsd:string; skos:prefLabel "2_de"@de; skos:prefLabel "2_en"@en ])
] ;
......@@ -31,9 +32,13 @@
skos:prefLabel "Enum_label_en"@en;
skos:notation "Enum"^^:TestCS .
dwh:IntegerRestriction a owl:Restriction ;
owl:onProperty rdf:value ;
owl:allValuesFrom xsd:integer .
:TestIntegerConcept a skos:Concept;
skos:inScheme :TestData ;
dwh:valueType xsd:integer ;
dwh:restriction dwh:IntegerRestriction ;
skos:prefLabel "Integer_label_en"@en ;
skos:prefLabel "Integer_label_de"@de ;
dc:description "Description_de"@de ;
......@@ -48,7 +53,8 @@
:TestDecimalConcept a skos:Concept;
skos:inScheme :TestData ;
dwh:valueRestriction [ a owl:Restriction ;
dwh:restriction [ a owl:Restriction ;
owl:onProperty rdf:value ;
owl:allValuesFrom [a rdfs:Datatype;
owl:onDatatype xsd:decimal;
owl:withRestrictions( [ xsd:minInclusive 200 ]
......
......@@ -30,7 +30,7 @@ public class ConceptImpl implements Concept {
return store.getNarrower(this);
}
public Resource getResource(){
Resource getResource(){
return res;
}
......@@ -81,9 +81,29 @@ public class ConceptImpl implements Concept {
}
@Override
public ValueRestriction getValueRestriction() {
// TODO implement
return null;
public ValueRestriction getValueRestriction() throws OntologyException {
try {
RepositoryResult<Statement> rs = store.getConnection().getStatements(getResource(), HIStreamOntology.DWH_RESTRICTION, null, true);
try{
if( !rs.hasNext() )
return null; // no restriction
Value o = rs.next().getObject();
// TODO: load restriction
RestrictionImpl ret = new RestrictionImpl();
if( rs.hasNext() ){
throw new OntologyException("More than one dwh:restriction for "+res);
}
return ret;
}finally{
rs.close();
}
} catch (RepositoryException e) {
throw new OntologyException(e);
}
}
......
package de.sekmi.histream.ontology.skos;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.impl.ValueFactoryImpl;
public class HIStreamOntology {
public static final String DWH_NAMESPACE = "http://sekmi.de/histream/dwh#";
public static final URI DWH_RESTRICTION;
static {
final ValueFactory f = ValueFactoryImpl.getInstance();
DWH_RESTRICTION = f.createURI(DWH_NAMESPACE, "restriction");
}
}
package de.sekmi.histream.ontology.skos;
import java.util.regex.Pattern;
import de.sekmi.histream.ontology.EnumValue;
import de.sekmi.histream.ontology.ValueRestriction;
public class RestrictionImpl implements ValueRestriction {
@Override
public Class<?> getType() {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumValue[] getEnumeration() {
// TODO Auto-generated method stub
return null;
}
@Override
public Number minInclusive() {
// TODO Auto-generated method stub
return null;
}
@Override
public Number maxInclusive() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer minLength() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer maxLength() {
// TODO Auto-generated method stub
return null;
}
@Override
public Pattern getPattern() {
// TODO Auto-generated method stub
return null;
}
}
......@@ -11,6 +11,7 @@ import org.junit.Test;
import de.sekmi.histream.ontology.Concept;
import de.sekmi.histream.ontology.OntologyException;
import de.sekmi.histream.ontology.ValueRestriction;
import de.sekmi.histream.ontology.skos.Store;
public class OntologyTest {
......@@ -28,6 +29,9 @@ public class OntologyTest {
Assert.assertNotNull(c);
Assert.assertEquals(1, c.getIDs().length);
Assert.assertEquals("T:type:int", c.getIDs()[0]);
ValueRestriction rest = c.getValueRestriction();
Assert.assertNotNull(rest);
}
@Test
public void getNarrowerTest() throws OntologyException{
......
......@@ -78,5 +78,5 @@ public interface Concept {
* Get restrictions for the values of this concept.
* @return value restrictions or {@code null} if no restrictions are provided
*/
ValueRestriction getValueRestriction();
ValueRestriction getValueRestriction() throws OntologyException;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment