Multiple Optional Parameters

19 views
Skip to first unread message

Marie Valadez

unread,
Jul 11, 2024, 11:36:59 AMJul 11
to TopBraid Suite Users
Hello!

I am working in TopBraid EDG 7.8. I have a Modify Action group where I would like the option of having multiple optional parameters (attribute and map). 

ex:ExampleModifyAction
sh:parameter ex:ExampleModifyAction-attribute ;
sh:parameter ex:ExampleModifyAction-map.

Is there a way for the user to add multiple attributes and maps without having to create a new parameter for each (example below)? 

Would prefer not to have to do this:

ex:ExampleModifyAction
sh:parameter ex:ExampleModifyAction-attribute1 ;
sh:parameter ex:ExampleModifyAction-map1; 
sh:parameter ex:ExampleModifyAction-attribute2 ;
sh:parameter ex:ExampleModifyAction-map2 ;
sh:parameter ex:ExampleModifyAction-attribute3 ;
sh:parameter ex:ExampleModifyAction-map3.

So instead of having to add all the optional parameters like above, the user could select multiples within the popup itself. I see a "+" button, but this only seems to allow the user to create a new Attribute itself and not a new mapping in the Modify Action.  Is there possibly a property I can add to the parameter that declares it as repeatable or something? 

Thanks for any help!

Marie

  

Holger Knublauch

unread,
Jul 12, 2024, 2:52:21 AMJul 12
to 'Luis Enrique Ramos García' via TopBraid Suite Users
Normally the number of sh:parameters for ModifyActions is fixed.

If you are on 8.0 (onwards), you can however use Wizard-based Actions. See

These would allow you to ask the user for the number of groups on the first wizard page and then, on the second page, present a dynamic list of arguments.

I am not sure though if that approach would then allow you to query those arguments with regular JS variables on the final step. For that you MAY need to wait for 8.1 where the paramsObject is supported. 8.1 may be available in a few weeks.

A completely different approach would be to have a single large text field as input field, with some domain-specific language of your choice where you parse in the script for the value pairs. If users are geeky enough, this could even be rdf:JSON.

HTH
Holger


--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@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-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/d324408d-e3c5-41dd-809a-c2f393d72c45n%40googlegroups.com.

Marie Valadez

unread,
Jul 12, 2024, 9:37:48 AMJul 12
to TopBraid Suite Users
Thanks Holger. We are still on 7.8, but hopefully getting moved to the newer version in the next couple of weeks. Does the ModifyAction wizard also work with BatchActions?

Holger Knublauch

unread,
Jul 12, 2024, 9:46:43 AMJul 12
to 'Luis Enrique Ramos García' via TopBraid Suite Users

On 12 Jul 2024, at 3:37 PM, Marie Valadez <meval...@gmail.com> wrote:

Thanks Holger. We are still on 7.8, but hopefully getting moved to the newer version in the next couple of weeks. Does the ModifyAction wizard also work with BatchActions?

Yes, also with BatchActions, and even in 8.0 the BatchActions already support the paramsObject field.

Holger


Marie Valadez

unread,
Jul 12, 2024, 11:45:29 AMJul 12
to TopBraid Suite Users
Good to know will have to look into it after the 8.0 update. Thank you Holger!

Marie Valadez

unread,
Jul 24, 2024, 10:53:08 AM (3 days ago) Jul 24
to TopBraid Suite Users
I was able to accomplish it with the ModifyAction in its current state. Adding in the code I used in case it is helpful to anyone else. 

    dash:js """
      /*The first page that is displayed to the user*/
      function begin() {
        return DataViewers.createNextPageJSON({
          title: 'Concept Attribute Map',
          message: `Enter in an integer for the number of attributes you want to map to the selected concept: ${focusNode}.`,
          params: [
              {
                 varName: 'AttributeCount',
                 label: 'Attribute Count',
                 description: 'Number of Attributes to Map to the selected concepts',
                 datatype: xsd.integer,
               }
          ],
          callback: handleFirstPage,
        })
      }

      /*The second page that asks the user to select the attributes to map to the concept*/
      function handleFirstPage(state) {
        // The AttributeCount is the parameter defined on the first page.
        let vals = [];
        for (let i =1; i <= AttributeCount; i++) {
          let attrdict = {
            'varName':`Attribute${i}`,
            'label':`Attribute ${i}`,
            'class': graph.node({qname: 'ex:Attribute'}),
            'description': 'Select the Attribute to Map to the Concept'
          };
          vals.push(attrdict);
          let mapdict = {
            'varName':`MapType${i}`,
            'label': `Map Type ${i}`,
            'class': graph.node({qname: 'ex:Map'}),
            'description': 'Select the Map Type for the Concept Attribute.'
          };
          vals.push(mapdict)
        }
        return DataViewers.createNextPageJSON({
          title: 'Select Attributes and Attribute Map Type' ,
          message: `Select the Attributes to Map to the selected concept: ${focusNode}.`,
          last: true,  // Last Page, allow Ok and Preview
          params:
            vals,
          state: {
            attrCnt: AttributeCount,
          },
          callback: handleOk,
        })
      }

      /*This is called when the user clicks OK on the second page. This is where the modifications are added to the graph.*/
      function handleOk(state) {

        let vals = [];
        for (let i =1; i <= state.attrCnt; i++) {
          let uuid = graph.eval(`spif:generateUUID()`);
          let camNode = graph.node({qname: `ex:CAM_${uuid}`});
          let map = eval(`MapType${i}`);
          let attr = eval(`Attribute${i}`);
          let label = `${map} ${attr}`;

          /****Not showing all values below. Just an example of how to use the wizard***/
          focusNode.add(ex:property, graph.node(camNode));
          camNode.add(ex:attribute, attr);
          camNode.add(ex:map, map);

        };
      }""" .

Holger Knublauch

unread,
Jul 24, 2024, 1:34:12 PM (3 days ago) Jul 24
to 'Luis Enrique Ramos García' via TopBraid Suite Users
Thanks for sharing!

Holger



Reply all
Reply to author
Forward
0 new messages