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-discussion] getting "view slot at class"

Jonathan Carter jonathan.carter at
Tue Jan 13 03:54:18 PST 2009

Hi Laszlo,

I've had a look through the source code for the Protege GUI in the  
subversion repository and it's not quite clear to me how this is  
achieved. However, I've been doing some experiments in the Script  
Console with some simple slot overrides (e.g. default values  
overridden in the class) and I think it may actually be an issue with  
how you are processing your Slots in your TraverseSlots.process()  

I've been using the Cls.getTemplateSlots() to get all the slots  
defined for that class (but I also noted that using  
getVisibleTemplateSlots() worked too).
Then I went through each slot in the Collection that is returned and  
called getTemplateSlotDefaultValues() to get the defaults that are set  
for that slot in this class. These are returned correctly as the  
overridden settings.

There are number of such methods on the Slot class for setting things  
like the allowed Cls (for Instance slots), the default values etc.

For example, the following code has worked as per the "View at class"  
dialog to set an override for the ':FROM' slot on the class that the  
variable 'aClass' represents:

	aClass.setTemplateSlotAllowedClses(kb.getSlot(":FROM"), anAllowedList)

There are getters for all these setters, so you can query how the Cls  
has its Slots configured - the "View at Class".

Therefore, I think you will need to pass the Cls that you are  
interrogating into your TraverseSlot.process() method and in there,  
use the getTemplateSlotxxxx() methods to get the true view of the  
slots at this class level:

private static void extractSlots(Cls cls) {
      Iterator<Slot> it = cls.getVisibleTemplateSlots().iterator();
      Slot slot;
      while (it.hasNext()) {
         slot =;
         TraverseSlot.process(cls, slot); // <------- Note the 'cls'  

Hope this helps


Jonathan Carter - Head of Technical Architecture
Enterprise Architecture Solutions Ltd

Assess your EA maturity at:

On 12 Jan 2009, at 20:42, Laszlo Szathmary wrote:

>> If you use the getDirectTemplates() method on the class instead of
>> getVisibleTemplateSlots(), then you get the slots as they are  
>> defined at
>> that class - the "view at class" level that you describe. This  
>> works for
>> getting and setting the slot at the class.
> Hi,
> Thanks for the answer, but it still doesn't work as I expect.
> getDirectTemplateSlots() doesn't show the inherited slots, and it
> still accesses the global properties (top-level view) of the slot. For
> all slots I would need the local view ("view slot at class" in the
> GUI).
> Thanks,
> Laszlo
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at
> Instructions for unsubscribing:

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

More information about the protege-discussion mailing list