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 use of changed data type properties at run time

Timothy Redmond tredmond at stanford.edu
Mon Jan 25 13:47:30 PST 2010


When I  read your note I suspected

	((JenaOWLModel)owlmodel).save(new File(fileName).toURI());

would save the imported ontologies (if they had changed).  I did a test
of this (attached) and indeed verified that this is the case.  If you
want to run the attached file yourself you will have to change several
constants in the java file but it seems to work.

The one situation that would not be covered by this is the case where
the import is a database project.  In this case you could simply read
the database project in and save it to a  file.  I could send you code
if you need an example of this case.

-Timothy



On Sat, 2010-01-23 at 03:41 -0800, Zhang Weishan wrote:
> (again i corrected the bad grammer in my message title) 
> 
> As a follow up on this question, I got some help from Timothy, thanks.
> Now I am trying to save the updated ontology in order to pin point the
> real problems. 
> 
> But it seems that i can only save the importing ontology, but not the
> one that should be updated. I use the following simple code to save
> the updated ontology, where 'owlmodel' is the model loaded by an
> importing ontology. And before i save the updated ontology, i switched
> the triple store to the ontology to be updated and have checked that
> the active triple store is the ontology to be updated.
> 
>  String fileName = "c:/test.owl"; 
> try { 
>                ((JenaOWLModel)owlmodel).save(new
> File(fileName).toURI()); 
>            } catch (URISyntaxException e) { 
>                // TODO Auto-generated catch block 
>                e.printStackTrace(); 
>            } catch (Exception e) { 
>                // TODO Auto-generated catch block 
>                e.printStackTrace(); 
>            } 
> 
> 
> Do you have any idea on this?
> 
> Best,
> Weishan
> 
> 
> ______________________________________________________________________
> From: Zhang Weishan <dr_zhangws at yahoo.com>
> To: User support for the Protege-OWL editor
> <protege-owl at lists.stanford.edu>
> Sent: Tue, January 12, 2010 12:00:26 AM
> Subject: Re: [protege-owl] making of changed data type properties at
> run time (in SWRL rule)
> 
> Hello Timothy,
>   Thanks for your reply. Sorry for the incomplete code. I have sent
> you (to your university email) a link on all the code (OSGi bundles
> with felix, which are going to be released to the public) including
> the ontologies. 
>   In my tests, i only have one swrl rule which will not generate large
> number of events, and i also filtered out the properties listened. The
> workflow: make changes to a property value, listen for changes, and
> inferring swrl rules worked well in my former prototypes running wiht
> plain JSE.
> 
>   Thanks for taking a look at it,
> 
>   Best regards,
>   Weishan
> 
> 
> 
> 
> ______________________________________________________________________
> From: Timothy Redmond <tredmond at stanford.edu>
> To: User support for the Protege-OWL editor
> <protege-owl at lists.stanford.edu>
> Sent: Sun, January 10, 2010 2:16:18 PM
> Subject: Re: [protege-owl] making of changed data type properties at
> run time (in SWRL rule)
> 
> 
> I am sorry.  I haven't actually succeeding in understanding the issue
> precisely.  It is possible that your issue is related to the fact that
> if you are listening for events during swrl processing you will no
> longer hear them during swrl inference.  This was done because swrl
> inference can generate a large number of events and for the most part
> event listeners are doing gui style work.  It is quicker to reset the
> gui after the swrl inferencing than to pay the overhead of event
> processing.
> 
> I tried to compile your code and had trouble with the
> OWLModelFromRepository, OWLModelHandler classes and the setProperty
> method.
> 
> -Timothy
> 
> Zhang Weishan wrote:
> > Sorry to have to post and rename the title, but there is no response
> regarding my question?
> > 
> > Thanks,
> > Weishan
> > 
> >
> ------------------------------------------------------------------------
> > *From:* Zhang Weishan <dr_zhangws at yahoo.com>
> > *To:* protege-owl at lists.stanford.edu
> > *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?
> > 
> > Best,
> > Weishan
> > 
> >
> ------------------------------------------------------------------------
> > *From:* Zhang Weishan <dr_zhangws at yahoo.com>
> > *To:* protege-owl at lists.stanford.edu
> > *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!
> > 
> > Best,
> > Weishan
> > 
> > 
> > 
> >
> ------------------------------------------------------------------------
> > 
> > _______________________________________________
> > protege-owl mailing list
> > protege-owl at lists.stanford.edu
> > https://mailman.stanford.edu/mailman/listinfo/protege-owl
> > 
> > Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
> >  
> 
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
> 
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03
> 
> 
> 
> 
> _______________________________________________
> protege-owl mailing list
> protege-owl at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
> 
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SaveChangedImport.java
Type: text/x-java
Size: 2281 bytes
Desc: not available
URL: <http://mailman.stanford.edu/pipermail/protege-owl/attachments/20100125/19530413/attachment.java>


More information about the protege-owl mailing list