> On 17 Apr 2024, at 1:38 PM, 'Luis Enrique Ramos García' via TopBraid Suite 
> Users <topbraid-users@googlegroups.com> wrote:
> 
> I am working with version Version: 7.5.1 (20230316-1531).

Ok then the script may not work, assuming the RDFNodeUtil object was introduced 
later.

In that case source code editing may be your best solution, unless you know how 
to use this


    createList: (nodes) => {
        let nil = graph.namedNode(rdf.NS + 'nil');
        if(nodes.length == 0) {
            return nil;
        }
        let root = graph.blankNode();
        let current = root;
        nodes.forEach((node, index) => {
            current.add(rdf.first, node);
            let rest = index < nodes.length - 1 ? graph.blankNode() : nil;
            current.add(rdf.rest, rest);
            current = rest;
        })
        return root;
    },


> 
> I included an script panel, refreshed it, and I have this view:
> <image.png>
> When I run the script I can see my class, the one for which I want to create 
> the enum, is the result of focusNode.
> 
> But, when I click in "Declare enumerations from instances" I get the same 
> result again:
> 
> <image.png>
> I have a question:
> 
> how does my script know from which class I do want to get my instances for 
> the enum list?.

The infrastructure around the ModifyAction will make sure that the variable 
focusNode points at the asset that
the action was called from (in the Modify menu).


> 
> Because I think you are using the same class color?, how do I relate the 
> class traffic light there?
> 
> What I want to say is something like this:
> 
> Product hasSize oneof  Size (short, medium, large)
> 
> And at this moment my focus is in Product, not in Size.

In SHACL you can either add sh:in to a class/node shape or to a property shape. 
If you just want to add it to a specific property then a different script would 
be needed.

Holger


> 
> 
> Luis
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> El mié, 17 abr 2024 a las 11:50, Holger Knublauch (<hol...@topquadrant.com 
> <mailto:hol...@topquadrant.com>>) escribió:
>> 
>> 
>>> On 17 Apr 2024, at 11:29 AM, 'Luis Enrique Ramos García' via TopBraid Suite 
>>> Users <topbraid-users@googlegroups.com 
>>> <mailto:topbraid-users@googlegroups.com>> wrote:
>>> 
>>> I added the code at the end of the code of the target class, and got this 
>>> result:
>>> 
>>> <image.png>
>>> When I click in "Declare enumeration from instances, I get this view:
>>> 
>>> <image.png>
>> 
>> This looks unexpected. What version are you on? The RDFNodeUtil object 
>> should be there. Maybe try the Refresh button in the Script Editor panel.
>> 
>>> 
>>> <image.png>
>>> Then, I wonder how to make the system know where my list of enum values are?
>> 
>> It will simply look at the already-existing instances of the currently 
>> selected class, see graph.every(focusNode) where focusNode is the current 
>> class.
>> 
>> Holger
>> 
>> 
>> 
>>> 
>>> 
>>> Luis 
>>> 
>>> 
>>> 
>>> El mié, 17 abr 2024 a las 10:51, Luis Enrique Ramos García 
>>> (<luisenriqueramos1...@googlemail.com 
>>> <mailto:luisenriqueramos1...@googlemail.com>>) escribió:
>>>> Hi Holger, 
>>>> Thanks for your answer, but to be frank I find these procedures very 
>>>> complicated. 
>>>> In my opinion the enum is a very common pattern, and I understand when to 
>>>> use it. 
>>>> 
>>>> Anyway, let's try to solve the issue
>>>> 
>>>> 1. I tried to add the code by myself, but it seems there is something 
>>>> wrong with the code:
>>>> sh:in (
>>>>       myontology:value1
>>>>        myontology _:value2
>>>>       myontology :value3
>>>>     ) ;
>>>> myontology:property1;
>>>> myontology:property2;
>>>> myontology:enumproperty;
>>>> 
>>>> Please, take in account that I edited the enum property just after the 
>>>> sh:in, but the editor put it at the end
>>>> of the list of properties.
>>>> 
>>>> Part of the result was this black datatype property in properties list
>>>> 
>>>> <image.png>
>>>> 
>>>> and in the undeclared property there is a list with these values:
>>>> 
>>>> in                                          [myontology:property1;
>>>>                                           myontology:property1;
>>>>                                           myontology:enumproperty;]
>>>> 
>>>> is thát the expected result?
>>>> 
>>>> if not, for the second option,
>>>> 
>>>> where do I have to insert this code:
>>>> 
>>>> focusNode.add(sh.in, RDFNodeUtil.createList(graph.every(focusNode)))
>>>> 
>>>> 
>>>> do I have to add this code at the beginning of the code of my ontology?
>>>> 
>>>> 
>>>> myontology:ClassActionsGroup
>>>>   a dash:ActionGroup ;
>>>>   rdfs:label "Class actions group" ;
>>>> .
>>>> myontology:DeclareEnumerationFromInstances
>>>>   a dash:ModifyAction ;
>>>>   dash:actionGroup myontology:ClassActionsGroup ;
>>>>   dash:js "focusNode.add(sh.in <http://sh.in/>, 
>>>> RDFNodeUtil.createList(graph.every(focusNode)))" ;
>>>>   rdfs:comment "Adds a sh:in declaration that enumerates all (current) 
>>>> instances of the selected class." ;
>>>>   rdfs:label "Declare enumeration from instances" ;
>>>> .
>>>> rdfs:Class
>>>>   dash:resourceAction myontology:DeclareEnumerationFromInstances ;
>>>> 
>>>> I have not done this before, if you have a tutorial or some document I 
>>>> could read, I would really appreciate 
>>>> if you can share it with me.
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Best regards
>>>> 
>>>> 
>>>> 
>>>> Luis Ramos
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> El mié, 17 abr 2024 a las 10:00, Holger Knublauch (<hol...@topquadrant.com 
>>>> <mailto:hol...@topquadrant.com>>) escribió:
>>>>> Hi Luis,
>>>>> 
>>>>> declaring an enumerated class is achieved in SHACL via sh:in. There is no 
>>>>> dedicated user interface for creating those quickly, as this isn't 
>>>>> anything that we have seen used much so far. I guess this is because the 
>>>>> user interface for entering instance data is already a drop down box 
>>>>> anyway, typically deemed good enough.
>>>>> 
>>>>> The main reason for creating enumerations would be to make sure that ONLY 
>>>>> those enumerated values will ever be permitted. For example, the colors 
>>>>> of a traffic light must only be red, green, yellow, but never blue even 
>>>>> if someone adds such an instance later.
>>>>> 
>>>>> To create those, you have various options. Advanced users would use the 
>>>>> source code panel to enter the sh:in expression. However, similar to what 
>>>>> we had in TBC, I think this can be automated easily. Basically the 
>>>>> following ADS script produces an sh:in enumeration for the selected class:
>>>>> 
>>>>>   focusNode.add(sh.in, RDFNodeUtil.createList(graph.every(focusNode)))
>>>>> 
>>>>> We can wrap this into a Modify Action (feel free to add the below to your 
>>>>> Ontology or a file that is included into your ontology):
>>>>> 
>>>>> 
>>>>> myontology:ClassActionsGroup
>>>>>   a dash:ActionGroup ;
>>>>>   rdfs:label "Class actions group" ;
>>>>> .
>>>>> myontology:DeclareEnumerationFromInstances
>>>>>   a dash:ModifyAction ;
>>>>>   dash:actionGroup myontology:ClassActionsGroup ;
>>>>>   dash:js "focusNode.add(sh.in <http://sh.in/>, 
>>>>> RDFNodeUtil.createList(graph.every(focusNode)))" ;
>>>>>   rdfs:comment "Adds a sh:in declaration that enumerates all (current) 
>>>>> instances of the selected class." ;
>>>>>   rdfs:label "Declare enumeration from instances" ;
>>>>> .
>>>>> rdfs:Class
>>>>>   dash:resourceAction myontology:DeclareEnumerationFromInstances ;
>>>>> .
>>>>> 
>>>>> With this in place, you can run it from the Modify menu of any class:
>>>>> 
>>>>> <PastedGraphic-1.png>
>>>>> 
>>>>> which will produce
>>>>> 
>>>>> myontology:Color
>>>>>   a owl:Class ;
>>>>>   a sh:NodeShape ;
>>>>>   rdfs:label "Color" ;
>>>>>   rdfs:subClassOf owl:Thing ;
>>>>>   sh:in (
>>>>>       myontology:Green
>>>>>       myontology:Yellow
>>>>>       myontology:Red
>>>>>     ) ;
>>>>>   sh:property myontology:Color-label ;
>>>>> .
>>>>> 
>>>>> Note that sh:in isn't displayed by default on the form of classes - again 
>>>>> because this isn't such a commonly used pattern. To make them visible, 
>>>>> switch the form to Also show undeclared properties.
>>>>> 
>>>>> If people find this useful, we could add improvements to this for 8.1.
>>>>> 
>>>>> Holger
>>>>> 
>>>>> 
>>>>> 
>>>>>> On 17 Apr 2024, at 9:32 AM, 'Luis Enrique Ramos García' via TopBraid 
>>>>>> Suite Users <topbraid-users@googlegroups.com 
>>>>>> <mailto:topbraid-users@googlegroups.com>> wrote:
>>>>>> 
>>>>>> I need to model an enum, 
>>>>>> 
>>>>>> and found this non uptodate tutorial:
>>>>>> 
>>>>>> https://topbraidcomposer.org/html/Create_an_enumeration.htm
>>>>>> 
>>>>>> Thus, I wonder if there is an uptodate procedure to create an enum in 
>>>>>> EDG?
>>>>>> 
>>>>>>  
>>>>>> Thanks
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Luis 
>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>> The topics of this mailing list include TopBraid EDG and related 
>>>>>> technologies such as SHACL.
>>>>>> To post to this group, send email to topbraid-users@googlegroups.com 
>>>>>> <mailto:topbraid-users@googlegroups.com>
>>>>>> --- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "TopBraid Suite Users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>> an email to topbraid-users+unsubscr...@googlegroups.com 
>>>>>> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/topbraid-users/6621d600-2195-4e9c-9b5d-58ce8172722bn%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/topbraid-users/6621d600-2195-4e9c-9b5d-58ce8172722bn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>>>> 
>>>>> 
>>>>> -- 
>>>>> The topics of this mailing list include TopBraid EDG and related 
>>>>> technologies such as SHACL.
>>>>> To post to this group, send email to topbraid-users@googlegroups.com 
>>>>> <mailto:topbraid-users@googlegroups.com>
>>>>> --- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "TopBraid Suite Users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to topbraid-users+unsubscr...@googlegroups.com 
>>>>> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/topbraid-users/4F0BE51C-54CE-4A52-9929-AC5FC29A26BE%40topquadrant.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/topbraid-users/4F0BE51C-54CE-4A52-9929-AC5FC29A26BE%40topquadrant.com?utm_medium=email&utm_source=footer>.
>>> 
>>> 
>>> -- 
>>> The topics of this mailing list include TopBraid EDG and related 
>>> technologies such as SHACL.
>>> To post to this group, send email to topbraid-users@googlegroups.com 
>>> <mailto:topbraid-users@googlegroups.com>
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "TopBraid Suite Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to topbraid-users+unsubscr...@googlegroups.com 
>>> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/topbraid-users/CABy94XnxaEsBD7ybryGTSRRBCHEMmPcac%3DkEJ9bhVkSkrerQDA%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/topbraid-users/CABy94XnxaEsBD7ybryGTSRRBCHEMmPcac%3DkEJ9bhVkSkrerQDA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> 
>> 
>> -- 
>> The topics of this mailing list include TopBraid EDG and related 
>> technologies such as SHACL.
>> To post to this group, send email to topbraid-users@googlegroups.com 
>> <mailto:topbraid-users@googlegroups.com>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to topbraid-users+unsubscr...@googlegroups.com 
>> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/B28AB52D-74C3-42E4-8E53-5E7162F79050%40topquadrant.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/B28AB52D-74C3-42E4-8E53-5E7162F79050%40topquadrant.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> The topics of this mailing list include TopBraid EDG and related technologies 
> such as SHACL.
> To post to this group, send email to topbraid-users@googlegroups.com
> --- 
> You received this message because you are subscribed to the Google Groups 
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to topbraid-users+unsubscr...@googlegroups.com 
> <mailto:topbraid-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/topbraid-users/CABy94XnEZxOr30t9e7v1nRKKHGiNBc36y9_AnGnzekM%2BAStt8g%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/CABy94XnEZxOr30t9e7v1nRKKHGiNBc36y9_AnGnzekM%2BAStt8g%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
The topics of this mailing list include TopBraid EDG and related technologies 
such as SHACL.
To post to this group, send email to topbraid-users@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to topbraid-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/944F246C-07CA-4390-9EDE-BCD018E00442%40topquadrant.com.
  • [topbraid-users] enu... 'Luis Enrique Ramos García' via TopBraid Suite Users
    • Re: [topbraid-u... Holger Knublauch
      • Re: [topbra... 'Luis Enrique Ramos García' via TopBraid Suite Users
        • Re: [to... Holger Knublauch
          • Re:... 'Luis Enrique Ramos García' via TopBraid Suite Users
            • ... Holger Knublauch
              • ... 'Luis Enrique Ramos García' via TopBraid Suite Users
                • ... Holger Knublauch
                • ... David Price
                • ... 'Luis Enrique Ramos García' via TopBraid Suite Users
                • ... 'Luis Enrique Ramos García' via TopBraid Suite Users
                • ... Holger Knublauch
                • ... 'Luis Enrique Ramos García' via TopBraid Suite Users
                • ... Holger Knublauch

Reply via email to