Re: Getting multiple classes for an Individual
My individual employee is a type of Technical, Manager and Programmer. I want to replace all these classes with only one class Worker. I used the following code, it supposed to replace it but it does not. All these classes are defined in the code. if ((employee.hasOntClass(technical)) && (employee.hasOntClass(programmer)) && (employee.hasOntClass(manager))) { employee.setOntClass(worker); JOptionPane.showMessageDialog(null, "here are the three classes"); } Though it display the message in the Dialog. On Fri, Jan 27, 2017 at 12:57 PM, Lorenz B. < buehm...@informatik.uni-leipzig.de> wrote: > Why should a method called "listOntClasses" just return a single class? > The usage of the plural form should be clear enough. And Javadoc Javadoc > Javadoc,... > > Dave, I have read some where that Individual#listOntClasses will only > list > > one class at one time. > > > > And yes employee is individual and programmer, manager and worker are > class > > variables. > > > > On Fri, Jan 27, 2017 at 12:23 AM, Dave Reynolds < > dave.e.reyno...@gmail.com> > > wrote: > > > >> On 26/01/2017 21:08, tina sani wrote: > >> > >>> Hi Dave, Will this work? > >>> > >>> if ((employee1.hasOntClass(programmer)) && > >>> ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) > >>> { > >>> > >>> } > >>> > >> Try it and see! > >> > >> There's not enough there for us to tell for sure. If the variable > >> employee1 is an Individual and if variables programmer, manager and > worker > >> are all Resources correctly corresponding to your classes then that will > >> test if that Individual has all three of those classes in the model > >> (whether asserted or inferred by rules). > >> > >> To add to my earlier answer, if you have an Individual rather than just > >> and OntResource then Individual#listOntClasses will enable you to > enumerate > >> the classes conveniently. > >> > >> Dave > >> > >> > >> On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynolds < > dave.e.reyno...@gmail.com > >>> wrote: > >>> > >>> On 26/01/2017 15:20, tina sani wrote: > How can I get all the classes of which an individual is a type? After > > Jena > > rules executed, my individual has multiple class like: > > Employee001 is of type: Worker, Programmer, Manager. > > > > So can I get all these three classes in Jena ? I have read somewhere > > that > > getOntClass() only return one class at a time and that is on random > > basis. > > > > See OntResource#listRDFTypes or, if you just have a Resource then > > > Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. > > Dave > > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > > > > >> --- > >> This email has been checked for viruses by Avast antivirus software. > >> https://www.avast.com/antivirus > >> > >> > -- > Lorenz Bühmann > AKSW group, University of Leipzig > Group: http://aksw.org - semantic web research center > >
Re: Getting multiple classes for an Individual
Why should a method called "listOntClasses" just return a single class? The usage of the plural form should be clear enough. And Javadoc Javadoc Javadoc,... > Dave, I have read some where that Individual#listOntClasses will only list > one class at one time. > > And yes employee is individual and programmer, manager and worker are class > variables. > > On Fri, Jan 27, 2017 at 12:23 AM, Dave Reynolds> wrote: > >> On 26/01/2017 21:08, tina sani wrote: >> >>> Hi Dave, Will this work? >>> >>> if ((employee1.hasOntClass(programmer)) && >>> ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) >>> { >>> >>> } >>> >> Try it and see! >> >> There's not enough there for us to tell for sure. If the variable >> employee1 is an Individual and if variables programmer, manager and worker >> are all Resources correctly corresponding to your classes then that will >> test if that Individual has all three of those classes in the model >> (whether asserted or inferred by rules). >> >> To add to my earlier answer, if you have an Individual rather than just >> and OntResource then Individual#listOntClasses will enable you to enumerate >> the classes conveniently. >> >> Dave >> >> >> On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynolds >> wrote: >>> >>> On 26/01/2017 15:20, tina sani wrote: How can I get all the classes of which an individual is a type? After > Jena > rules executed, my individual has multiple class like: > Employee001 is of type: Worker, Programmer, Manager. > > So can I get all these three classes in Jena ? I have read somewhere > that > getOntClass() only return one class at a time and that is on random > basis. > > See OntResource#listRDFTypes or, if you just have a Resource then > Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. Dave --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus >> --- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus >> >> -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center
Re: Getting multiple classes for an Individual
On 26/01/17 21:28, tina sani wrote: Dave, I have read some where that Individual#listOntClasses will only list one class at one time. No idea what you mean. It's an Iterator which will iterate over all of the OntClasses, and since it's also an ExtendedIterator it has convenience methods to gather all of the results into a Set or List for you. Dave And yes employee is individual and programmer, manager and worker are class variables. On Fri, Jan 27, 2017 at 12:23 AM, Dave Reynoldswrote: On 26/01/2017 21:08, tina sani wrote: Hi Dave, Will this work? if ((employee1.hasOntClass(programmer)) && ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) { } Try it and see! There's not enough there for us to tell for sure. If the variable employee1 is an Individual and if variables programmer, manager and worker are all Resources correctly corresponding to your classes then that will test if that Individual has all three of those classes in the model (whether asserted or inferred by rules). To add to my earlier answer, if you have an Individual rather than just and OntResource then Individual#listOntClasses will enable you to enumerate the classes conveniently. Dave On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynolds
Re: Getting multiple classes for an Individual
Dave, I have read some where that Individual#listOntClasses will only list one class at one time. And yes employee is individual and programmer, manager and worker are class variables. On Fri, Jan 27, 2017 at 12:23 AM, Dave Reynoldswrote: > On 26/01/2017 21:08, tina sani wrote: > >> Hi Dave, Will this work? >> >> if ((employee1.hasOntClass(programmer)) && >> ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) >> { >> >> } >> > > Try it and see! > > There's not enough there for us to tell for sure. If the variable > employee1 is an Individual and if variables programmer, manager and worker > are all Resources correctly corresponding to your classes then that will > test if that Individual has all three of those classes in the model > (whether asserted or inferred by rules). > > To add to my earlier answer, if you have an Individual rather than just > and OntResource then Individual#listOntClasses will enable you to enumerate > the classes conveniently. > > Dave > > > On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynolds > > >> wrote: >> >> On 26/01/2017 15:20, tina sani wrote: >>> >>> How can I get all the classes of which an individual is a type? After Jena rules executed, my individual has multiple class like: Employee001 is of type: Worker, Programmer, Manager. So can I get all these three classes in Jena ? I have read somewhere that getOntClass() only return one class at a time and that is on random basis. See OntResource#listRDFTypes or, if you just have a Resource then >>> Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. >>> >>> Dave >>> >>> >>> >>> --- >>> This email has been checked for viruses by Avast antivirus software. >>> https://www.avast.com/antivirus >>> >>> >>> >> > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > >
Re: Getting multiple classes for an Individual
On 26/01/2017 21:08, tina sani wrote: Hi Dave, Will this work? if ((employee1.hasOntClass(programmer)) && ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) { } Try it and see! There's not enough there for us to tell for sure. If the variable employee1 is an Individual and if variables programmer, manager and worker are all Resources correctly corresponding to your classes then that will test if that Individual has all three of those classes in the model (whether asserted or inferred by rules). To add to my earlier answer, if you have an Individual rather than just and OntResource then Individual#listOntClasses will enable you to enumerate the classes conveniently. Dave On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynoldswrote: On 26/01/2017 15:20, tina sani wrote: How can I get all the classes of which an individual is a type? After Jena rules executed, my individual has multiple class like: Employee001 is of type: Worker, Programmer, Manager. So can I get all these three classes in Jena ? I have read somewhere that getOntClass() only return one class at a time and that is on random basis. See OntResource#listRDFTypes or, if you just have a Resource then Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. Dave --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Re: Getting multiple classes for an Individual
Hi Dave, Will this work? if ((employee1.hasOntClass(programmer)) && ((employee1.hasOntClass(manager)) &&((employee1.hasOntClass(worker)) { } On Thu, Jan 26, 2017 at 11:32 PM, Dave Reynoldswrote: > On 26/01/2017 15:20, tina sani wrote: > >> How can I get all the classes of which an individual is a type? After Jena >> rules executed, my individual has multiple class like: >> Employee001 is of type: Worker, Programmer, Manager. >> >> So can I get all these three classes in Jena ? I have read somewhere that >> getOntClass() only return one class at a time and that is on random basis. >> >> See OntResource#listRDFTypes or, if you just have a Resource then > Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. > > Dave > > > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > >
Re: Getting multiple classes for an Individual
On 26/01/2017 20:58, Olatunde Ayanleye wrote: Hello Dave, Thanks for the prompt reply, but i have tried this approach but i only get the Super classes inferred.I can't get the subclass which i was expecting jena to infer based on data property restriction. That will depend on how you have inference set up, whether your model includes the ontology declarations and whether your declarations are correct. In particular you said you were running your own rule. To get OWL inference on top of those you will either need to include the OWL rules in your rule set (and set the reasoner config accordingly) or you will need to layer an OWL InfModel on top of your GenericReasoner InfModel. Dave Kind regards,Olatunde On Thursday, 26 January 2017, 20:32, Dave Reynoldswrote: On 26/01/2017 15:20, tina sani wrote: How can I get all the classes of which an individual is a type? After Jena rules executed, my individual has multiple class like: Employee001 is of type: Worker, Programmer, Manager. So can I get all these three classes in Jena ? I have read somewhere that getOntClass() only return one class at a time and that is on random basis. See OntResource#listRDFTypes or, if you just have a Resource then Resource#listProperties(RDF.type) or, as Charles says, use SPARQL. Dave --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus