Correct way to use #Version - couchbase

Can someone please tell me how exactly this #Version works for locking? Because I don't see the version field is saved in the Couchbase, but when I retrieve it, this field is populated with some random value.
Should I manually set this value when save? For example, I have a POST and PUT endpoint. if I don't set the version with the existing version number, I will get a DocumentAlready exist error. But for the POST, it is ok the save without setting the version (I guess it will automatically generate the new random value for the new record).

In couchbase, each document has some metadata associated with it, ex:
"cas": 1571854188210290688,
"expiration": 0,
"flags": 0,
"id": "path::3c23b8a1-55ca-4cd9-a3cc-d6641abf1adc",
"type": "json"
This data is usually transparent to you if you are using Couchbase with Spring Data, but you can inject it in a field if you need to. That is exactly what happens with the #Id annotation. You don't need to worry with the #Version unless you want to do some optmistic/pessimistic locking.

Related

Nifi LookupAttribute processor with SimpleCsvFileLookupService doesn't work

I'd like to use a CSV file as a lookup table to update some attributes.
So I figured the LookUpAttribute processor was what I needed. I configured it with as SimpleCsvFileLookupService as the Lookup Service, but I can't get it to work yet.
My SimpleCsvFileLookupService is configured but stays in a "enabling" state, and the LookUpAttribute processor still tells me it's "invalid because performing validation depends on referencing a Controller Service that is currently disabled".
I dont understand why it doesn't enable. Has somebody used these components ? Thx
Edit :
I didn't see the message in the left. It says the mapping for "1" is not found ("1" is set as the lookup key column and in the csv the header row is "1;2;3;4;5;6;7;8".
What am I missing ? I can't find any explanation as to how to use this controller service.
Edit2 : The SimpleCsvFileLookupService properties
Edit3 : Extract of the csv file

What is the URL when I DELETE an object

I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

Getting the value of a particular cell with AJAX

My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.

Deleting entity in a Fiware-ServicePath, deletes entities with the same id in subpaths

Should this be normal? I've got a Fiware-ServicePath:
/user/home/room
I've set an entity with an id "table1" under path /user/home and under /user/home/room. When trying to delete "table1" id
Fiware-ServicePath: /user
{
"contextElements": [
{
"type": "table",
"isPattern": "false",
"id": "table1"
}
],
"updateAction": "DELETE"
}
under /user, is it normal for the rest of the entities with id "table1" to get deleted (under scopes /user/home and /user/home/room)?
Also, is there any chance to get the path of an already existing entity, if for example someone forgot it? I am able to receive entities with .* under default path /#, but if an entity is just ONE path under the main, I can't delete it.
A "scope" works in an inclusive way. This means that when you perform a search or any kind of update, including delete operations, in a specific path you are actually targeting all entities in that path and all paths hanging from it.
So you were actually deleting both tables.
For the second part, there is no discovery of service paths. You can know the path of a given entity by looking at the header, though.
EDIT
This is actually a behavior that is not what was planned to happen. There was a bug report made at the project's github. I'm referring to the deletion of entities in different service paths. Thanks for the input!!