Auto-populate required fields for new instance in EDG

78 views
Skip to first unread message

Rebecca Jackson

unread,
Dec 7, 2023, 3:59:48 PM12/7/23
to TopBraid Suite Users
In EDG - is it possible to auto-populate required fields (rdfs:label, skos:notation) for a new instance based on the constructed URI?

Specifically, when a user creates a new instance of class X, the URI is constructed using acronym + counter: http://example.com/FOO_1

We would like to auto-populate the skos:notation with the value "1" and rdfs:label with "FOO_1", instead of having the user fill these values in when they create the new instance.

I understand that we can create property value rules, but it does not seem that these are executed on instantiation.

Thank you!
Rebecca

Holger Knublauch

unread,
Dec 7, 2023, 4:22:10 PM12/7/23
to 'Bohms, H.M. (Michel)' via TopBraid Suite Users
Hi Rebecca,

See if this meets your use case


I can elaborate when needed, tomorrow.

Regards,
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/d4ae0274-0fb7-416d-960f-b786e5e2a7f4n%40googlegroups.com.

Rebecca Jackson

unread,
Dec 7, 2023, 4:33:27 PM12/7/23
to TopBraid Suite Users
This is a great starting point - exactly what I needed. Is there a way to access the auto-generated instance URI from this? It looks like the 'focusNode' is for the class, is that correct?

Holger Knublauch

unread,
Dec 7, 2023, 4:36:58 PM12/7/23
to topbrai...@googlegroups.com
You can generate the URI yourself from whatever input parameter(s) you define. For example use the default namespace of the asset collection and append the number that was entered or whatever is shown in the example.

Holger


Rebecca Jackson

unread,
Dec 8, 2023, 11:41:58 AM12/8/23
to TopBraid Suite Users
Thanks again for your help. I've got the constructor set up in an ontology asset (TTL attached, based on the example provided), and then I am including this in a Data Graph asset. When I try to create a new instance, I get the following error:
ReferenceError: lab is not defined

How does that prefix get generated for use in ADS? I thought it would be handled in the ontology header with 'dash:generatePrefixConstants "lab"' but it seems that it is still missing something.

When I import and tested the example, "ex" works just fine.
lab.ttl

Holger Knublauch

unread,
Dec 8, 2023, 12:41:54 PM12/8/23
to topbrai...@googlegroups.com
It works for me

PastedGraphic-1.png

maybe use the Refresh button on the Script Editor panel to have it regenerated? During development
this is often necessary as the editor does not generate the APIs after each change for performance reasons.

Alternatively, this should always work, regardless of prefixes:

let neo = graph.namedNode(uri);
neo.add(rdfs.label, 'CIR 0');
neo.add(skos.notation, '0');
neo

Holger


Reply all
Reply to author
Forward
0 new messages