problem with setTemplateSlotAllowsMultipleValues

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with setTemplateSlotAllowsMultipleValues

Aditi Pandit

Hi,

  I am trying to create a string slot ( with multiple values ) using the
following function. Boolean isMultipleValued is set to true when calling
this function.However, I am never able to get a string slot that allows
multiple values. Please could you let me know what I am doing wrong or any
other api that I should use ?

public void addStringSlot(String className, String slotName, boolean
isMultipleValued) {


  Cls cls = getCls(className);
        Slot slot = getSlot(slotName);
        cls.addDirectTemplateSlot(slot);
        cls.setTemplateSlotAllowsMultipleValues(slot, isMultipleValued);
        cls.setTemplateSlotValueType(slot, ValueType.STRING);

}

Thanks,
Aditi
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: problem with setTemplateSlotAllowsMultipleValues

Tania Tudorache

Hi Aditi,

when you create a new slot in Protege, it is created with the default
type String and default cardinality single at top level. When you
override it at class level, you can only restrict the values from the
top-level. So if your slot is defined at top-level with cardinality
single, you cannot set its cardinality to multiple at class level.

If you want to make it multiple cardinality, you will have to change its
cardinality at top-level. You can do this with the following API call:

        slot.setAllowsMultipleValues(true);

The same applies for the type: you cannot change the type of a slot at
class level (unless it is defined as "Any" at top-level).
So, instead of using the class level method to change the type, use the
top-level method:

        slot.setValueType(ValueType.STRING);

Tania


Aditi Pandit wrote:

>Hi,
>
>  I am trying to create a string slot ( with multiple values ) using the
>following function. Boolean isMultipleValued is set to true when calling
>this function.However, I am never able to get a string slot that allows
>multiple values. Please could you let me know what I am doing wrong or any
>other api that I should use ?
>
>public void addStringSlot(String className, String slotName, boolean
>isMultipleValued) {
>
>
> Cls cls = getCls(className);
>        Slot slot = getSlot(slotName);
>        cls.addDirectTemplateSlot(slot);
>        cls.setTemplateSlotAllowsMultipleValues(slot, isMultipleValued);
>        cls.setTemplateSlotValueType(slot, ValueType.STRING);
>
>}
>
>Thanks,
>Aditi
>-------------------------------------------------------------------------
>To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>
>  
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html