Trying to update a graph using an Active Data Shape service

113 views
Skip to first unread message

Steve Ray

unread,
Mar 31, 2021, 8:27:10 PM3/31/21
to TopBraid Suite Users
Hi, I have a question about accomplishing the above.

1. How do I make my graph not a "read-only" graph?
image.png
I have set "Enable SPARQL updates" to true in Server Configuration.
The graph in question is the focus graph in my local EDG.
I have ensured Administrator is listed as both Manager and Editor for the graph in EDG Permissions Management.
I am using the default settings in Rights Management

Here's the code I'm trying to run in the Script Editor:
graph.update(`DELETE {
?qk qudt:applicableUnit ?unit .
}
INSERT {
?newqk qudt:applicableUnit ?newunit .
}
WHERE {
{
?qk a qudt:QuantityKind .
?qk qudt:applicableUnit ?unit .
}
UNION
{
?newqk a qudt:QuantityKind .
?newqk qudt:inferredApplicableUnit ?newunit .
} .
} `)

I get the same error when invoking the service from a web browser:


yields:

Cannot evaluate Script:org.topbraid.core.servlet.HttpErrorException: Failed service request /qudt_quantitykind/qudt/refreshApplicableUnits: Attempt to change a read-only graph rejected

Here's my service definition code:
qudt:refreshApplicableUnits
  rdf:type dash:GraphService ;
  dash:js """graph.update(`
DELETE {
    ?qk qudt:applicableUnit ?unit .
}
INSERT {
    ?newqk qudt:applicableUnit ?newunit .
}
WHERE {
{
    ?qk a qudt:QuantityKind .
    ?qk qudt:applicableUnit ?unit .
}
UNION
{
    ?newqk a qudt:QuantityKind .
    ?newqk qudt:inferredApplicableUnit ?newunit .
} .
}
`)
""" ;
  dash:responseContentType "void" ;
  rdfs:label "Refresh the applicableUnits property" ;
.

There must be a setting I'm missing!
Thanks in advance for your help.

Steve


Holger Knublauch

unread,
Apr 2, 2021, 12:11:47 AM4/2/21
to topbrai...@googlegroups.com
Hi Steve,

On 1 Apr 2021, at 10:26 am, Steve Ray <st...@steveray.com> wrote:

Hi, I have a question about accomplishing the above.

1. How do I make my graph not a "read-only" graph?
<image.png>

The Script Editor panel has an unlock button/setting in the upper right corner. This toggles between read-only and writable APIs. The writable APIs have additional functions etc.
To enable updates, add dash:canWrite true.

Holger



There must be a setting I'm missing!
Thanks in advance for your help.

Steve



--
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/CAGUep84svBqwK9G7545srJ5FziguTvK3JhUuUN8ztVgi5ZOkug%40mail.gmail.com.

Steve Ray

unread,
Apr 3, 2021, 1:05:49 PM4/3/21
to TopBraid Suite Users
Thanks for your always informative help. I did get this to work, only to realize that I now have a web service that will update the graph living in the EDG database, but not a web service that will update the Turtle file on my local machine, which is ultimately my goal.

So, I have learned about dash:GraphService and dash:ResourceService, and now am starting to learn about dash:ModifyAction as something I may need to use. However, is ModifyAction designed more for creating ui actions in EDG? Should I just be using dash:GraphService and use a call to graph.uploadedFile? If so, after modifying the graph, is there some sort of graph.saveFile (which I cannot find). Also, why is graph.uploadedFile crossed out in the script editor pull-down?
image.png

I'm hoping these questions are of general interest. Basically I'm trying to use web services to maintain local files, and I call these web services from shell scripts. That's how we publish all our web pages.

Steve




Holger Knublauch

unread,
Apr 3, 2021, 6:52:59 PM4/3/21
to topbrai...@googlegroups.com

On 4 Apr 2021, at 3:05 am, Steve Ray <st...@steveray.com> wrote:

Thanks for your always informative help. I did get this to work, only to realize that I now have a web service that will update the graph living in the EDG database, but not a web service that will update the Turtle file on my local machine, which is ultimately my goal.

ADS scripts are designed to operate on the graph variable, which by default is the graph in the EDG database that the service is called for. While there is a way to temporarily switch to other graphs via graph.withDataGraph(), the focus of the design has been to operate on EDG graphs. For example, performing updates assumes that the changes go into the database without also having to save a file.

I don’t have enough background to give you sound advice here, but you may know that in 7.0 EDG is able to directly “open” files from your workspace, edit them and save them back. See the Files item in the main menu on the left hand side to get started. The workflow there is that “open” will create a local copy in the EDG database, and that graph is then under the usual control of EDG, with a urn:x-evn-master:XY URI. So if you have a bunch of files that you want to manage with EDG, you can now “open" them, execute scripts on them and then occasionally save them back to their original files. The ADS API doesn’t have a built-in convenience method to perform this save step, but it can be reliably called from ADS via graph.swp() and the SWP module teamwork:saveFileProject. I can provide details if needed.

Maybe you can explain the bigger picture though before we go down that route.


So, I have learned about dash:GraphService and dash:ResourceService, and now am starting to learn about dash:ModifyAction as something I may need to use. However, is ModifyAction designed more for creating ui actions in EDG?

The types dash:ModifyAction and dash:ExploreAction are used to define UI extensions, i.e. items that will appear in the Modify or Explore menus of EDG. Scripts may be both dash:ResourceServices and dash:XYActions, for cases where the same feature should be available manually and programmatically.

Should I just be using dash:GraphService and use a call to graph.uploadedFile? If so, after modifying the graph, is there some sort of graph.saveFile (which I cannot find).

Also, why is graph.uploadedFile crossed out in the script editor pull-down?
<image.png>

That function has been marked deprecated in 7.0 because we have moved it into its own class: IO.uploadedFile()


I'm hoping these questions are of general interest. Basically I'm trying to use web services to maintain local files, and I call these web services from shell scripts. That's how we publish all our web pages.

Let’s see if this is the right technology for this particular job…

Holger


Irene Polikoff

unread,
Apr 3, 2021, 8:24:12 PM4/3/21
to topbrai...@googlegroups.com
Yes, I agree with Holger. We need to better understand the full workflow you are trying to implement in order to give meaningful advice. Otherwise, we could all waste time going around in circles.

If your data is in EDG because you want to make it easy for multiple users to collaborate on evolving it, then what is in EDG is a ‘master’. You can deliver this information as files to other processes or distribution channels as you ‘cut releases’ - which could happen as often as you need. Files are then are simply ‘point in time snapshots’ and you do not change them directly. Instead, you re-create them on export.

If you have a different workflow in mind, then there could be some other design. 

I don’t think that this forum is the right vehicle for this discussion. Fell free to reach out directly so we can talk through what you are trying to accomplish.


On Apr 3, 2021, at 6:53 PM, Holger Knublauch <hol...@topquadrant.com> wrote:


Reply all
Reply to author
Forward
0 new messages