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] Copying an Object

Tania Tudorache tudorache at stanford.edu
Thu May 29 18:16:24 PDT 2008


Hi Elena,

In build 500, the setName method was removed. Instead you should use the 
rename method:

OWLIndividual i = ...;
i = (OWLIndividual) i.rename("http://a.com#abc");

Rename will create a clone of the old individual and delete the old one. 
Please see more information about renaming on the wiki:

http://protegewiki.stanford.edu/index.php/Database_Inclusion_Plugin_Devlopers_Notes#Renaming_Frames_or_OWL_Entities

Tania


Antonenko, Elena wrote:
> Hello everyone,
>
> When I used build 130 to copy an object, I did it with the following code:
>
> RDFIndividual copy = (RDFIndividual)individual.shallowCopy(toOwlModel, null);
> copy.setName(individual.getName());
>
> In build 500 class RDFIndividual doesn't have a method "setName", so if I comment
> the second line, the copy gets another name as the initial individual, which is not suitable for me.
>
> Does anybody have suggestions, how can I copy an object using build 500?
>
> Thank you very much in advance.
>
> Regards,
> Elena
>
>
> -----Ursprüngliche Nachricht-----
> Von: protege-owl-bounces at mailman.stanford.edu im Auftrag von Ralf Weinand
> Gesendet: Sa 24.05.2008 02:23
> An: User support for the Protege-OWL editor
> Betreff: Re: [protege-owl] [POSSIBLE VIRUS:###] Re: Copying an Object
>  
> Hi Tania,
>
> what a pity you couldn´t fix this error for this beta.
> Did you find out what causes the problem, so that I can try to avoid
> this situation somehow?
> Can I use the JenaCreator at all, or would you suggest I should copy
> all individuals into an empty model?
>
> Another issue: When I use jenaOwlModel.getOntModel().writeAll(...)
> not all the inferred types are written to the file. For example if the
> following type hierarchy is defined
>      OrderedItem subClassOf Item
> then, if an individual is asserted to be of type OrderedItem (via a
> SWRl consequent),
> then calling the writeAll(...)-method after DL-reasoning just writes
> the individual with the type OrderedItem and
> not also with the type Item. Is this a bug, or is the
> writeAll()-method not supposed to write all inferred knowledge?
>
> Cheers,
> Ralf
>
>
> On Sat, May 24, 2008 at 2:10 AM, Tania Tudorache <tudorache at stanford.edu> wrote:
>   
>> Hi Ralf,
>>
>> I did have a look at the problem, but I did not have time to fix it for
>> the P3.4 b500 release. Sorry about that. I suggest that you use the
>> workaround, and meanwhile I will try to solve it for the next beta.
>>
>> Tania
>>
>>
>> Ralf Weinand wrote:
>>     
>>> Hi Tania,
>>>
>>> you all seam to be very busy working on the new beta, right?
>>> Just a quick question: Will the bug described in this thread be fixed
>>> with the next beat release?
>>> Because if not, I have to find a workaround myself, since I need a
>>> working method for serializing
>>> only OWL-individuals of a model urgently (beginning of next week) to
>>> get my program working
>>> for a conference.
>>>
>>> Thanks a lot,
>>> Ralf
>>>
>>>
>>> On Tue, May 6, 2008 at 9:42 PM, Tania Tudorache <tudorache at stanford.edu> wrote:
>>>
>>>       
>>>> Ralf,
>>>>
>>>> Thank you very much for sending the code. I was able to reproduce the
>>>> error, but I did not have time to fix it yet. I just wanted to let you
>>>> know that we are working on it.
>>>>
>>>> Tania
>>>>
>>>>
>>>> Ralf Weinand wrote:
>>>>
>>>>         
>>>>> Hi Tania,
>>>>>
>>>>> thanks for your reply!
>>>>>
>>>>> Here is the code that I use. I also attached the ontologies that I import.
>>>>> The last lines (for writing via JenaCreator) are commented out,
>>>>> because they produce an exception.
>>>>>
>>>>> Cheers,
>>>>> Ralf
>>>>>
>>>>>
>>>>>
>>>>>             // write rule model (Dataflow_Source_ABox2Target_ABox.owl)
>>>>> to temporary file
>>>>>             Node ruleModelRoot = SemanticUtils.findRdfNode((Element)
>>>>> ruleContainer);
>>>>>             File ruleModelFile =
>>>>> SemanticUtils.writeOntologyToTempFile(ruleModelRoot);
>>>>>
>>>>>             // write target model (Target_ABox.rdf-xml.owl - ABox
>>>>> only, TBox is imported within ABox model) to temporary file
>>>>>             Node targetModelRoot = SemanticUtils.findRdfNode((Element)
>>>>> targetContainer);
>>>>>             File targetModelFile =
>>>>> SemanticUtils.writeOntologyToTempFile(targetModelRoot);
>>>>>
>>>>>             // write source model (Source_ABox.rdf-xml.owl - ABox
>>>>> only, TBox is imported within ABox model) to temporary file
>>>>>             Node sourceModelRoot = SemanticUtils.findRdfNode((Element)
>>>>> sourceContainer);
>>>>>             File sourceModelFile =
>>>>> SemanticUtils.writeOntologyToTempFile(sourceModelRoot);
>>>>>
>>>>>             // create empty model to import all the knowledge
>>>>>             dataflowModel = ProtegeOWL.createJenaOWLModel();
>>>>>
>>>>>             // create and set repositories
>>>>>             RepositoryManager repositoryManager =
>>>>> dataflowModel.getRepositoryManager();
>>>>>
>>>>>             LocalFileRepository localRepository = new
>>>>> LocalFileRepository(ruleModelFile);
>>>>>             localRepository.setForceReadOnly(true);
>>>>>             repositoryManager.addProjectRepository(localRepository);
>>>>>
>>>>>             localRepository = new LocalFileRepository(targetModelFile);
>>>>>             localRepository.setForceReadOnly(true);
>>>>>             repositoryManager.addProjectRepository(localRepository);
>>>>>
>>>>>             localRepository = new LocalFileRepository(sourceModelFile);
>>>>>             localRepository.setForceReadOnly(true);
>>>>>             repositoryManager.addProjectRepository(localRepository);
>>>>>
>>>>>             // load the target model (ABox)
>>>>>             dataflowModel.load(new FileInputStream(targetModelFile),
>>>>> FileUtils.langXML);
>>>>>
>>>>>             // import source and rule model
>>>>>             ImportHelper importHelper = new ImportHelper(dataflowModel);
>>>>>             importHelper.addImport(sourceModelFile.toURI());
>>>>>             importHelper.addImport(ruleModelFile.toURI());
>>>>>             importHelper.importOntologies();
>>>>>
>>>>>             // create the reasoner for an initial check of the bridging model
>>>>>             ProtegeReasoner reasoner =
>>>>> SemanticUtils.createProtegeReasoner(dataflowModel);
>>>>>
>>>>>             // perform owl reasoning
>>>>>             reasoner.computeInconsistentConcepts();
>>>>>             reasoner.classifyTaxonomy();
>>>>>             reasoner.computeInferredIndividualTypes();
>>>>>
>>>>>             // Create Jess rule engine and the bridge
>>>>>             // to copy swrl-rules and owl-facts to Jess.
>>>>>             Rete rete = new Rete();
>>>>>             SWRLJessBridge bridge = null;
>>>>>
>>>>>             // create the bridge from SWRL to Jess-Rules
>>>>>             bridge = new SWRLJessBridge(dataflowModel, rete);
>>>>>
>>>>>             // 1. copy swrl-rules and owl-facts to Jess
>>>>>             // 2. fire the SWRL-rules
>>>>>             // 3. updates the Protege-OWL-model with new facts
>>>>>             bridge.importSWRLRulesAndOWLKnowledge();
>>>>>             bridge.run();
>>>>>             bridge.writeInferredKnowledge2OWL();
>>>>>
>>>>>             // delete the rules, since we do not want to safe them into the
>>>>>             // resulting ontology
>>>>>             swrlFactory.deleteImps();
>>>>>
>>>>>             // after the semantic bridge was executed,
>>>>>             // perform owl reasoning
>>>>>             reasoner.computeInconsistentConcepts();
>>>>>             reasoner.classifyTaxonomy();
>>>>>             reasoner.computeInferredIndividualTypes();
>>>>>
>>>>>             // write the resulting ontology model
>>>>>             ByteArrayOutputStream bout = new ByteArrayOutputStream();
>>>>>             dataflowModel.getOntModel().writeAll(bout, FileUtils.langXML, null);
>>>>>
>>>>> //            // only individuals of user defined classes should be saved
>>>>> //            Collection clses = dataflowModel.getUserDefinedOWLNamedClasses();
>>>>> //            JenaCreator jenaCreator = new JenaCreator(dataflowModel,
>>>>> false, true, clses, null);
>>>>> //
>>>>> //            OntModelSpec oms = new OntModelSpec(OntModelSpec.OWL_DL_MEM);
>>>>> //            OntDocumentManager dm = new OntDocumentManager();
>>>>> //            oms.setDocumentManager(dm);
>>>>> //
>>>>> //            OntModel resultingModel = jenaCreator.createOntModel(oms);
>>>>> //            JenaOWLModel.saveModel(bout, resultingModel,
>>>>> FileUtils.langXML, null);
>>>>>
>>>>>             output = bout.toString();
>>>>>             bout.close();
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>
>>>
>>>       
>> _______________________________________________
>> 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 
>   




More information about the protege-owl mailing list