Updating value to NULL using Spring Data REST and PUT Method - spring

I am using Spring Data REST using a CRUD repository, some values should be optionally NULL, however if I try to set them to null, the fields in question get ignored. If I send non-NULL data it works as expected
Is there are a way to allow this functionality?
Here is a sample PUT request body
{
"name": "Ash Test",
"distance": null,
"paid": null,
"startDate": null,
"tags": [ ],
"position": 3,
"creator": true,
"memberId": 55
}

This appears to be a known issue at the time of this writing:
https://jira.springsource.org/browse/DATAREST-130
It affects both SDR 1.0.0.RELEASE and SDR 1.1.0.M1. I just tried it with 2.0.0.BUILD-SNAPSHOT and the nulls don't currently go through there either.

Related

Is there an API that shows the user task histroy on the Camunda side?

I have a Camunda flow, there are 2-3 user tasks in this flow. I want to see their history after completing these tasks. There are a couple of methods, but I just want to get both the label and the entered value with rest-api.
I can't get them directly with rest-api.
The following method returns variables with the processInstanceId.
List<HistoricVariableInstance> instances = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(processIntanceId)
.list();
but I need to call another rest-api to get the labels. GET /process-definition/{id}/xml with this api.
Other topics have been opened for this, but it does not meet exactly what I want.
similar question
I think you are right, you need 2 steps. I would combine the following requests:
First get all User Tasks:
GET /history/task -see API Reference
From its result Array you need the id and the name (which is the label):
[{"id":"anId",
...
"name":"aName",
...
}]
Now you can get the variables for each UserTask, like
GET /history/variable-instance?taskIdIn=YourTaskId see API Reference
https://docs.camunda.org/manual/7.16/reference/rest/history/variable-instance/post-variable-instance-query/
returns the name (label) and the value of the process variables
[
{
"id": "someId",
"name": "someVariable",
"type": "Integer",
"variableType": "integer",
"value": 5,
"valueInfo": {},
"processDefinitionKey": "aProcessDefinitionKey",
"processDefinitionId": "aProcessDefinitionId",
"processInstanceId": "aProcInstId",
"executionId": "aExecutionId",
"activityInstanceId": "aActivityInstId",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"taskId": null,
"tenantId": null,
"errorMessage": null,
"state": "CREATED",
"createTime":"2017-02-10T14:33:19.000+0200",
"removalTime": "2018-02-10T14:33:19.000+0200",
"rootProcessInstanceId": "aRootProcessInstanceId"
}
]

Couchbase return null value after save and read document using n1ql

I insert a document in couchbase using repository.save()
and after that, I make a query to find duplicates on another document.
query is:
SELECT ARRAY_AGG(i.serialnumber) serialNumbers
FROM default tempItem
UNNEST items i
WHERE tempItem.class = "com.inventory.model.item.TempItem"
AND META(tempItem).id = '4390dd9e-e392-4432-939f-ebf046570086'
and i.serialnumber in (select raw serialnumber from default where class = 'com.inventory.model.item.Item'
AND status != 'DELETED' and serialnumber is not missing)
the result of the query is:
[
{
"serialNumbers": [
"9121945901",
"9121955901",
"9211965901"
]
}
]
The document that saved is like below:
[
{
"tempItem": {
"class": "com.inventory.model.item.TempItem",
"items": [
{
"categoryId": "67aaca7b-90b1-43e4-a6c6-0e9567bf283e",
"clientIds": [
"919d0ca7-c8d4-4283-8b0a-b6f2a7b39753"
],
"description": "bla bla",
"initial": 1,
"productId": "db5c81c4-0fec-407e-8703-6f5fb69a070c",
"serialnumber": "9121945901",
"simType": "PREPAID",
"status": "ACTIVE",
"stock": 1,
"title": "bla bla"
}
]
}
}
]
and another document to check is :
{
"categoryId": "67aaca7b-90b1-43e4-a6c6-0e9567bf283e",
"class": "com.inventory.model.item.Item",
"clientIds": [
"919d0ca7-c8d4-4283-8b0a-b6f2a7b39753"
],
"createdts": 1601801989176,
"creator": "919d0ca7-c8d4-4283-8b0a-b6f2a7b39753",
"description": "bla bla",
"initial": 1,
"prefix1": "912",
"prefix2": "194",
"productId": "db5c81c4-0fec-407e-8703-6f5fb69a070c",
"serialnumber": "9121945901",
"simType": "PREPAID",
"status": "ACTIVE",
"stock": 1,
"title": "bla bla"
}
in spring boot when I run the query immediately after seve the document its return null result
and if I make some milliseconds sleep after save and before the run query returns the value
what is that problem?
can anybody help this issue?
This is probably because of ScanConsistency. Indexes in Couchbase are built asynchronously. So if you are using the default "NOT_BOUNDED" consistency and query the data with N1QL immediately after you write it, it may not be indexed yet.
I don't know how to change this in Spring, but the other options are:
REQUEST_PLUS - will likely take a bit longer to return the results but the query engine will make sure that it is as up-to-date as possible.
consistentWith(MutationState) a.k.a AT_PLUS - for a more narrowed-down scan consistency, depending on the index update rate this might provide a speedier response.
Again, not sure about Spring, but you don't have to set this globally. Each query can use a different scan consistency. So, if you value maximum performance over up-to-the-second accuracy, you can go with the default. If you value up-to-the-second accuracy over maximum performance, you can go to with REQUEST_PLUS or AT_PLUS.
Using the CouchbaseRepository then it is possible to annotate every query using the annotation #ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS) to enforce the desidered Scan consistency on each query. Have a look at the official documentation Querying with consistency

Query specific value in array from a metadata entity in Dynamics 365

I'm trying to avoid iterating through this array, but I imagine that is the only way to handle this. Just seeing if there is a way to directly query this value in the array from the Web API URI.
This is the URI example:
https://example.crm.dynamics.com/api/data/v9.0/GlobalOptionSetDefinitions(f4a9de67-1d00-ea11-a811-000d3a33f702)
And this is an example of the response:
{
"#odata.context": "https://example.crm.dynamics.com/api/data/v9.0/$metadata#GlobalOptionSetDefinitions/Microsoft.Dynamics.CRM.OptionSetMetadata/$entity",
"MetadataId": "f4a9de67-1d00-ea11-a811-000d3a33f702",
"Options": [
{
"Value": 799680006,
"Color": "#0000ff",
"IsManaged": false,
"ExternalValue": "",
"ParentValues": [],
"MetadataId": null,
"HasChanged": null,
"Label": {
"LocalizedLabels": [
{
"Label": "ABC123",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "b4eb2c69-b500-ea11-a811-000d3a33fe19",
"HasChanged": null
}
],
"UserLocalizedLabel": {
"Label": "ABC123",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "b4eb2c69-b500-ea11-a811-000d3a33fe19",
"HasChanged": null
}
}
}
]
}
Basically, I have the "Value": 799680006 which is what I want to somehow add to the URI query parameters, so that I can ultimately get "Label": "ABC123".
Any suggestions or is iterating through the array of objects with if Value = x really the only option?
Let me clarify two things:
Querying metadata like you are using GlobalOptionSetDefinitions to get all the localized labels if you have multiple language packs or for verifying customizations or for Devops deployment purpose is one thing
Getting the label for the selected picklist value in one of the transaction database record is another purpose
If you simply need for second purpose, you can get it by selecting the Formatted value, after adding a header in web api request. Read more in my SO answer
Another way to inspect the label is using stringmap entity.
https://crmdev.crm.dynamics.com/api/data/v9.1/stringmaps?$filter=objecttypecode eq 'account' and attributename eq 'accountclassificationcode' and attributevalue eq 1

Streamsets Data Collector: Replace a Field With Its Child Value

I have a data structure like this
{
"id": 926267,
"updated_sequence": 2304899,
"published_at": {
"unix": 1589574240,
"text": "2020-05-15 21:24:00 +0100",
"iso_8601": "2020-05-15T20:24:00Z"
},
"updated_at": {
"unix": 1589574438,
"text": "2020-05-15 21:27:18 +0100",
"iso_8601": "2020-05-15T20:27:18Z"
},
}
I want to replace the updated_at field with its unix field value using Streamsets Data Collector. As far as I know, it can be done using field replacer. But I'm still didn't get it how to make a mapping expression. How can I achieve that?
In Field Replacer, set Fields to /rec/updated_at and New value to ${record:value('/rec/updated_at/unix')} and it will replace the value. See below.
Cheers,
Dash

SonarQube 5.5 API - componentKey convention

I'm trying to extract coverage data from our SonarQube instance using the 'api/measures/component' endpoint. This is for a multi module java project. Using POSTMAN i can query for a single java file using a 'componentKey' which is build up of string like this
[maven-groupId]:[maven-artifactId]:[path to java file]
which generates a string like
com.i.pc.e.components.o:om-wf-e:src/main/java/com/i/e/o/wf/actions/Xxxx.java
and returns this json response
{
"component": {
"id": "AVci_6G7elHqFlTqG_OC",
"key": "com.i.pc.e.components.o:om-wfl-e:src/main/java/com/i/e/o/wf/actions/Xxxx.java",
"name": "Xxxx.java",
"qualifier": "FIL",
"path": "src/main/java/com/i/e/om/wf/actions/Xxxxx.java",
"language": "java",
"measures": []
},
"metrics": [
{
"key": "coverage",
"name": "Coverage",
"description": "Coverage by unit tests",
"domain": "Coverage",
"type": "PERCENT",
"higherValuesAreBetter": true,
"qualitative": true,
"hidden": false,
"custom": false,
"decimalScale": 1,
"bestValue": "100.0",
"worstValue": "0.0"
}
]
}
This is fine for a one-off request but I need to do this for a number of Java source files and I won't have the Maven details to hand.
Is there a convention or documentation on the format of the 'componentKey'?
Ideally i'd like to define the full package and java source file name in the 'compomentKey' or is there a way to look up the 'componentId' via some other REST API call?
Use the components service to iterate through your tree (or sub-trees within your tree) starting from your project and feeding your sonar.projectKey value into the baseComponentKey parameter. Pay particular attention to the strategy parameter, which determines what sub-set of children a call retrieves.
Once you have the data on each child, it should be simple to iterate through them to get their measures.

Resources