Retrieving a process Instance diagram in Camunda - camunda

I have been trying to retrieve a process instance diagram from Camunda engine. All the JAVA and REST methods deal with retrieving the deployed process diagram. So, the closest I am is this method.
InputStream getProcessDiagram(String processDefinitionId)
But its of no use to me as I want to be able to get the current state of the particular process instance.
The process diagram representing the current state can be viewed in Camunda Tasklist but I have no clue as to how to retrieve it.
Thanks!

The diagram with its state does not simply come from the REST API as is. Instead, data from two sources is collected:
GET /process-definition/{id}/xml provides the BPMN diagram (which you have already found) [1]
GET /process-instance/{id}/activity-instances provides the state of a process instance in a tree structure [2]
The tasklist has some client-side logic that renders the BPMN XML with bpmn.io and places markers on top of it based on the activity instance tree.

Related

gcp create_notification_channel creates a duplicate channel

GCP Python client method to Create Monitoring Notification channel is not idempotent.
Duplicate Channels under same Project are getting created.
Is there a way to avoid duplication?
create_notification_channel
According the documentation it's not possible to handle duplicates directly but you can solve your issue with the following actions :
List the existing notification channels in GCP via the list_notification_channels
Loop on the actual notifications channels (maybe configured in your code), if the element exist in GCP (check from the list retrieved previously), update it via update_notification_channel function, otherwise create it with create_notification_channel function.

Designing RESTful API for Invoking process methods

I would like to know how do design the RESTful web service for process methods. For example I want to make a REST Api for ProcessPayroll for given employee id. Since ProcessPayroll is time consuming job, I don't need any response from the method call but just want to invoke the ProcessPayroll method asynchronously and return. I can't use ProcessPayroll in the URL since it is not a resource and it is not a verb. So I thought that, I can go with the below approach
Request 1
http://www.example.com/payroll/v1.0/payroll_processor POST
body
{
"employee" : "123"
}
Request 2
http://www.example.com/payroll/v1.0/payroll_processor?employee=123 GET
Which one of the above approach is correct one? Is there any Restful API Design guidelines to make a Restful service for process methods and functions?
Which one of the above approach is correct one?
Of the two, POST is closest.
The problem with using GET /mumble is that the specification of the GET method restricts its use to operations that are "safe"; which is to say that they don't change the resource in any way. In other words, GET promises that a resource can be pre-fetched, just in case it is needed, by the user agent and the caches along the way.
Is there any Restful API Design guidelines to make a Restful service for process methods and functions?
Jim Webber has a bunch of articles and talks that discuss this sort of thing. Start with How to GET a cup of coffee.
But the rough plot is that your REST api acts as an integration component between the process and the consumer. The protocol is implemented as the manipulation of one or more resources.
So you have some known bookmark that tells you how to submit a payroll request (think web form), and when you submit that request (typically POST, sometimes PUT, details not immediately important) the resource that handles it as a side effect (1) starts an instance of ProcessPayroll from the data in your message, (2) maps that instance to a new resource in its namespace and (3) redirects you to the resource that tracks your payroll instance.
In a simple web api, you just keep refreshing your copy of this new resource to get updates. In a REST api, that resource will be returning a hypermedia representation of the resource that describes what actions are available.
As Webber says, HTTP is a document transport application. Your web api handles document requests, and as a side effect of that handling interacts with your domain application protocol. In other words, a lot of the resources are just messages....
We've come up with the similar solution in my project, so don't blame if my opinion is wrong - I just want to share our experience.
What concerns the resource itself - I'd suggest something like
http://www.example.com/payroll/v1.0/payrollRequest POST
As the job is supposed to be run at the background, the api call should return Accepted (202) http code. That tells the user that the operation will take a lot time. However you should return a payrollRequestId unique identifier (Guid for example) to allow users to get the posted resource later on by calling:
http://www.example.com/payroll/v1.0/payrollRequest/{payrollRequestId} GET
Hope this helps
You decide the post and get on the basis of the API work-
If your Rest API create any new in row DB(means new resource in DB) , then you have to go for POST. In your case if your payroll process method create any resource then you have to choose to POST
If your Rest API do both, create and update the resources. Means ,if your payroll method process the data and update it and create a new data , then go for PUT
If your Rest API just read the data, go for GET. But as I think from your question your payroll method not send any data.So GET is not best for your case.
As I think your payroll method is doing both thing.
Process the data , means updating the data and
Create new Data , means creating the new row in DB
NOTE - One more thing , the PUT is idempotent and POST is not.Follow the link PUT vs POST in REST
So, you have to go for PUT method.

How can I write data about process assignees to database

I use camunda 7.2.0 and i'm not very experienced with it. I'm trying to write data about users, who had done something with process instance to database (i'm using rest services) to get some kind of reports later. The problem is that i don't know how to trigger my rest(that sends information to datebase about current user and assignee) when user assignes task to somebody else or claims task to himself. I see that camunda engine sends request like
link: engine/engine/default/task/5f965ab7-e74b-11e4-a710-0050568b5c8a/assignee
post: {"userId":"Tom"}
As partial solution I can think about creating a global variable "currentUser" and on form load check if user is different from current, and if he is - run the rest and change variable. But this solution don't looks correct to me. So is there any better way to do it? Thanks in advance
You could use a task listener which updates your data when the assignee of a task is changed. If you want this behavior for every task you could define a global task listener.

Spring Data Neo4j + Spring Data Rest: Using a Natural Key for all CRUD operations instead of the Neo4J node Id

I'm writing writing a Spring Restful microservice that relies on Spring Data Rest and Spring Data Neo4J.
We don't want to expose the internal Neo4J node identifier in the HAL links of the JSON response. The reason being (as far as I understand) that these identifiers are reused by Neo4J in case of node deletion. If this is the case this will present us with data integrity problems. And so we'd rather use a natural key, for example, UUID. Please correct me if my assumption regarding the reuse of neo4J node Ids is wrong.
What we want to achieve is using a Natural Key for all CRUD operations instead of the node Id (ie: PUT http://localhost:8080/apiname/5448ae86-fe87-4daf-bfb5-985522a1cf14 with some body).
Our first approach was to extend NodeGraphRepositoryImp . E.g.
protected Node getById(UUID id) {
Node node = (Node) this.findByPropertyValue("uuid_id", id);
return template.getNode(node.getId());
}
And instantiate it by injecting a customized Neo4jTemplate in the Neo4J configuration.
However this approach doesn't work for the following reasons:
1) I cannot define any other idProperty different from the one annotated with #GraphId in the NodeEntity class. As a result Spring Data Rest ends up trying to assign the natural key (e.g. UUID) to the neo4j node id field (that is a Long) and fails on type conversion.
2) It seems that the Spring Data Neo4J is not using our custom class that extends NodeGraphRepositoryImpl but the original not extended NodeGraphRepositoryImpl class instead.
Maybe this approach is wrong. Could you please recommend a way to achieve it?
Thanks a lot for your help.
Spring Data Rest introduced a BackendIdConverter for overriding/customizing the field that gets exposed in the URIs.
Please have a look at DATAREST-155 (https://jira.spring.io/plugins/servlet/mobile#issue/DATAREST-155)
Can you give it a try?
You can also have a look at the following thread:
How can you customise self, parent, children links in spring data rest with neo4j

Get an audio session's volume level

Does anyone know how to get the current volume level of an audio session* in Vista or 7?
I've got the IAudioSessionControl2 and IAudioSessionManager2 instances you need to listen for volume changes, but actually getting the current volume is proving elusive.
*by audio session I mean (roughly) the per-application audio control, not the "master" one
Note that (so far as I can tell) IAudioSessionManager2->GetSimpleVolume() isn't the right answer here. The only thing that publishes a GUID in IAudioSessionControl2 is the Grouping parameter, and using it in GetSimpleVolume creates new sessions rather than giving you the control for an existing one.
GetSimpleVolume() is what I want, but where are the params coming from in this setup?
Actually IAudioSessionManager::GetSimpleAudioVolume IS what you're looking for.
An audio session is identified by two (or three) things: The session guid, the process ID and the cross process flag (if the cross process flag is specified when the stream is created, the process ID is ignored).
The simple audio volume controls the volume of all the streams within that audio session. It's fairly straightforward (most rendering frameworks specify NULL for the session GUID). If your application uses a specific session GUID, you should just specify the session GUID your application is using.
There's one other twist though. The volume control (sndvol.exe) combines all sessions with the same "grouping param" together in the UI - this isn't a part of the volume control, it's a UI convenience feature that exists only for web browsers like IE - it exists to allow 3rd party audio frameworks (which specify a GUID_NULL session GUID) and the WMP OCX (which specifies a cross process session with a specific session GUID) to share a single slider in the volume UI.
I think the ISimpleAudioVolume interface should do what you need.
It has a method called GetMasterVolume witch returns the volume for the audio session.
To obtain the interface you can call IAudioSessionManager::GetSimpleAudioVolume.
For the guid parameter you can use the one you specify when creating the audio streams with IAudioClient::Initialize. I honestly don't know if there are other ways to get the guid for a session.
The grouping parameter is the id of the group to witch the session belongs and not an id of a session.