Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] making of changed data type properties at run time (in SWRL rule)

Zhang Weishan dr_zhangws at
Sat Jan 9 16:19:43 PST 2010

Sorry to have to post and rename the title, but there is no response regarding my question?


From: Zhang Weishan <dr_zhangws at>
To: protege-owl at
Sent: Wed, January 6, 2010 10:26:05 PM
Subject: Re: reading changed properties in memory and then used to reason using SWRL rule

Any ideas on my problem?


From: Zhang Weishan <dr_zhangws at>
To: protege-owl at
Sent: Tue, December 29, 2009 10:42:45 PM
Subject: reading changed properties in memory and then used to reason using SWRL rule

Dear All,
  I was using the property change listener before to listen for the changed value for a property, and then make use of the changed value to reason using SWRL rules. It was working well before (using protege before V3.4). But now i got a problem with this working flow: the property value change listener can detect the changes in the property value, the problem is that the SWRL rule can not get the updated value to make decisions.

public void propertyValueChanged(RDFResource resource,
                RDFProperty property, Collection oldValues) {

            HashSet<String> inferred = new HashSet<String>();
    //        System.out.println(" notified for properties changed"+property.getBrowserText());
/*            System.out.println("Resource = " + resource.getBrowserText());
            System.out.println("Property = " + property.getBrowserText());
            System.out.println("oldValues = " + oldValues);*/
//execution of a swrl rule to make use of the new value

I also tried to see whether the property is updated correctly and can be used after a change, something also a bit strange: i got a null from the update (but in setProperty(hardware, property, level), i can see that the property is changed ).

public class BatteryLevelUpdate{
    private OWLModel protocolModel=null;
    public BatteryLevelUpdate(OWLModel model, String hardwareURI){
        OWLModelHandler.swapTripleStore(model, hardwareURI);
     * Sets the property to the instance in the related TripleStore
     * @param owlmodel The core OWLModel.
     * @param deviceURI The device URI.
     * @param level The level of device battery.
    public void updateBatteryLevel(OWLModel owlmodel, String deviceURI, float level){
        String uri=owlmodel.getURIForResourceName("Battery");

        String prefixedNameDevice=owlmodel.getResourceNameForURI(deviceURI);
          OWLIndividual device=owlmodel.getOWLIndividual(prefixedNameDevice);
        String uriPropHardware=deviceURI.substring(0, deviceURI.indexOf("#")+1)+owlmodel.getResourceNameForURI("hasHardware");
        OWLProperty propertyHardware = owlmodel.getOWLProperty(uriPropHardware);
        OWLIndividual hardware=(OWLIndividual)device.getPropertyValue(propertyHardware);

        String uriPropBatteryLevel=hardware.getURI().substring(0, hardware.getURI().indexOf("#")+1)+owlmodel.getResourceNameForURI("batteryLevel");

        OWLProperty property = owlmodel.getOWLProperty(uriPropBatteryLevel);

        setProperty(hardware, property, level);
//        System.out.println( "setting to: "+hardware.getPropertyValue(property));
  /*      System.out.println("time taken to update battery level "+ (System.currentTimeMillis()-current));
        inferred = ruleGroupP.inferRuleGroup(protocolModel, "protocol" );
        System.out.println(" inferred "+inferred.size());*/
       System.out.println("time taken to update battery level "+ (System.currentTimeMillis()-current));

        public static void main(String[] args) throws URISyntaxException {
              long current = System.currentTimeMillis(); 
              OWLModel owlModelCore = OWLModelFromRepository.getOntologyModel( new URI("file:/C:/Users/zhang/workspace/os/sdk/flamenco/flamenco_semaps/semaps/repository/ProtocolAdaptation.owl")).getOWLModel();
              BatteryLevelUpdate u=new BatteryLevelUpdate(owlModelCore, "http://localhost:9999/hydra/ontologies/Hardware.owl");
              u.updateBatteryLevel( owlModelCore, "http://localhost:9999/hydra/ontologies/Device.owl#motionSensor0_protocolAdaptation", 0.1f);
                OWLIndividual hardware=owlModelCore.getOWLIndividual("http://localhost:9999/hydra/ontologies/Hardware.owl#Battery_motionSensor0_protocolAdaptation");
                OWLProperty property = owlModelCore.getOWLProperty("http://localhost:9999/hydra/ontologies/Hardware.owl#batteryLevel");
                System.out.println("updated "+hardware+ " battery level "+ hardware.getPropertyValue(property));

 Did i make any mistakes?

 Thanks for reading and wish you a Happy New Year!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the protege-owl mailing list