Hello Jena mailing list,

we have a problem concerning the update of datatype property values.
Let's say we have an individual with a datatype property 'age' set to 1
(xsd:int).
If we want to update this property to 2, we Datatype.listRange() to
check if the value type is supported
and update the value with Individual.setPropertyValue()

Without a reasoner in the background this assignment succeeds or if we
don't use listRange, everything runs smoothly, too.
If we bind our model to a pellet reasoner instance, use listRange() and
perform the update, the new value can be seen in
the xml-data of the ontology but if we later try to retrieve this new
value, always the old one is returned.

A SSCCE reproducing our problem is attached.
Jena: 2.10.0, Pellet 2.3.1

    public void sscce() {
        System.out.println(" === SSCCE ===");
        String URI = "http://anarxim.net#";;

        OntModel model =
ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
        // the code will work without Pellet
        // OntModel model = ModelFactory.createOntologyModel();

        model.setNsPrefix("anarxim", URI);
        
        // Create class, individual and datatype property
        OntClass testClass = model.createClass(URI + "Person");
        Individual individual = model.createIndividual(URI + "Jane",
testClass);
        DatatypeProperty property = model.createDatatypeProperty(URI +
"age");
        property.addDomain(testClass);
        property.setRange(XSD.xint);

        // Set property value to 1
        final Literal oldAgeLiteral =
ResourceFactory.createTypedLiteral(new Integer(1));
        individual.setPropertyValue(property, oldAgeLiteral);
        
        // if the next line is removed, the code will work too
        property.listRange();
        
        // Update property value to 2
        final Literal newAgeLiteral =
ResourceFactory.createTypedLiteral(new Integer(2));
        individual.setPropertyValue(property, newAgeLiteral);

        // this will fail
        assertEquals("Value not chaned", newAgeLiteral,
individual.getPropertyValue(property).asLiteral());

        // Output to check property value in model, value is 2 as expacted
        model.write(System.out);
    }

Reply via email to