Comments (3)
Some ideas:
Looking at JSONPATCH, it seems like a plausible way, using the replace operation, to apply a change to a specific path in the json. It does not provide an ability to replace in the php sense of str_replace or preg_replace. Nor does it support wildcards in the path parameter. So it could only be used once we know the exact path to the value that we know we need to overwrite. The function of finding the values that need to replaced and returning the paths to them would need come from somewhere else.
My thinking is that this would be driven from a custom VBO operation that is the strawberryfield analog to the VBO "Change Values" operation. I'd maybe take it further to add "Add Values" and "Delete Values" options, and call it "Strawberryfield CRUD".
In a view which has our custom vbo action enabled, you select the ADOs for which you intend to perform the find/replace/add/delete, select the "Strawberryfield CRUD" operation, and click "Apply to Selected Objects". On the confirmation screen, a form would let you define
- a JMES path (or possibly multiple JMESPaths, separated by commas), or something along those lines, to identify where the values are in the sbf json that you want to perform the find/replace/add/delete on.
- A select list with the options: "Find and Replace", "Add", "Delete".
- If Find/Replace or Delete is selected, show a field where you can define an optional find pattern, literal text or regex, perhaps with a checkbox indicating which.
- If "Find/Replace" or "Add" is selected, show a new value string (with possibility for capture group token indicating where any capture groups from the find regex pattern would go).
I think these fields should be in a container labeled "Strawberryfield CRUD Operation", and it should be possible to instantiate additional copies of it on the form, so that you can perform multiple find and replace operations in the same bulk operation, as you can do with VBO's "Change Value" operation.
I can't think of a way to make this as user-friendly as VBO's change value operation, where the confirmation form lists all the available fields, with checkboxes that, when checked, expose a form for that field. I'm thinking, at least for a minimally viable product, that we simply provide instructions for use the ADO Tools tab on an object to find a JMESPath to the value you wish to CRUD.
The submit method for this form would loop as follows:
- Through each ADO
- Through each Strawberryfield CRUD Operation, return the JSON pointers to each value that needs to be added, replaced, or deleted.
- Through each JSON path, invoke JSONPatch with the appropriate operation and value on the JSON. (I think these can be batched into a single JSONPath json file and executed at once.)
- Save the JSON when done with each ADO.
- Through each Strawberryfield CRUD Operation, return the JSON pointers to each value that needs to be added, replaced, or deleted.
from ami.
One question I have is whether JMESPath supports returning JSON Pointers. From what I can find, it doesn't. It only returns an array of values. So bridging between JMESPath and JSONPatch could be a challenge. I like the idea of using JMESPath because it's used in numerous places in Archipelago, but maybe it won't work for this application?
from ami.
@patdunlavey sorry, late to this. There is a lot good stuff and some of this already is coded and can be tested, other things we may need to figure out how to implement. I would love to show you some of this with screenshots next week and share some code too.
Re: JMESPath supports returning JSON Pointers
This is a thing I have been planning on adding. As you correctly detected JSON Pointers depend a lot on knowing exactly where something is. A lot can be refined with the current search and replace view we ship (means you can pre filter using facets and search) but not all.
So, the way I see JMESPATH integration with JSON Pointers would be to either
1.- Extend the provided JSONPATCH syntax to take a finer JMESPATH query. Do the query internally using the JMESPATH and based on the response JSON, convert the query into multiple fixed JSONPOINTERS and execute them without user interaction. The good thing here is that we could do finer grained queries. The bad is we need to process them of course and also make sure only a subset of JMESPATH is possible (by either stripping parts or not allowing them), since JMESPATH can also "cast" results into arbitrary structures after the query and with that we could not build ourselves the JSONPOINTERS anymore
2.- Second option would be to allow a Pre JMESPATH query and apply pointers on the result, not the whole thing.
I'm confident that once I get over the Form API issue I have with adding Webform Elements as an option, that last one will be the preferred one for users. Graphical and more intuitive. Right now it renders the webform elements (one for selecting the source, another for the replacement) but it fails to pass the values in the form state, mostly because VBO wraps the config form in a strange way but also because I do not know better
better with screenshots and code next week, thanks!
from ami.
Related Issues (20)
- Undefined array key "#description_display" in Ami Row Preview Controller HOT 3
- Cap the File URL to 255 chars HOT 2
- VBO facets can't run on an anonymous session because of Private Store HOT 1
- AMI Set Validation HOT 1
- AMI Sets Analysis Overview
- Ensure ZIP sanity before trying to access it
- Autogenerate sequence_id for `ispartof` as an Admin Option HOT 1
- Allow multi ADO relationships on AMI CSVs HOT 1
- Add alternate mimetype mappings HOT 2
- CSV Column/Header Sort HOT 4
- Improve/fix AMI set Access Control/Permissions for AMI Set lists, Operations, etc HOT 4
- Add an additional data_lod twig context that includes the original label used to reconciliate against. HOT 1
- Ingest Failsafe on low Space HOT 1
- Owning user deletion and errors on default formatters (and others)
- Owning user deletion and errors on default formatters (and others) HOT 1
- Clean leading dots from remote downloaded files
- AMI CSV export fails when an ADO has a missing `type` key HOT 1
- Modern JS (latest 112.0.5615.121 (Official Build) (x86_64)) and our wonky #states bug HOT 1
- Remove check for getMasterRequest() HOT 1
- Provide Twig variables for Ajax Preview in Twig templates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ami.