Search Mailing List Archives
[protege-discussion] Instances of a slot
Jonathan Carter
jonathan.carter at e-asolutions.com
Fri Oct 2 10:08:08 PDT 2009
Hi Marian,
Yes, you need to start with the Instance class. In this case, you get
an Instance object for the "Ball" instance, e.g. (assuming we have a
reference to the KnowledgeBase of the Project, 'knowledgebase')
aProductList = knowledgebase.getCls("Product").getDirectInstances()
// Iterate through aProductList to find "Ball" use getName() to find
the name of the instance and use this object, named 'aBall'
Instance aBall = // THE INSTANCE, aProduct, IN aProductList WHERE
aProduct.getName() = "Ball"
Slot aMadeOfSlot = knowledgebase.getSlot("madeOf")
Instance madeOf = aBall.getDirectOwnSlotValue(aMadeOfSlot)
As "madeOf" is an Instance slot, you will be returned an Instance
object that you can then interrogate:
String materialOfBall = madeOf.getName()
Sorry for the mix of psuedo code and narrative but hopefully this
makes sense
Let me know if you'd like more help
Regards
Jonathan
_______________________________________
Jonathan Carter - Head of Technical Architecture
Enterprise Architecture Solutions Ltd
_______________________________________
Proud sponsors of The Essential Project.
The free open-source Enterprise Architecture Management Platform
www.enterprise-architecture.org
_______________________________________
On 2 Oct 2009, at 17:50, Mariana Reyes Perez wrote:
> Hi all,
>
> I installed Protege 3.4.
> I am making a Plug-in. Is there a method or function to get the
> instances of a slot?
>
> I have 2 classes ("Product" and "Material") which are joined by the
> slot
> (Type:Instance) "madeOf"
> Product has the instance "Ball" and Material has the instance
> "Plastic"
> How do I traverse the slot from the instance "Ball" to get the value
> "plastic"?
>
> Thanks in advance
> Marian
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-discussion/attachments/20091002/09b5e145/attachment.html>
More information about the protege-discussion
mailing list