Fetch the process instances by passing the multiple business key[processBusinessKey] values - alfresco

I have one process which has task and form fields. And I have one field "location" which I am considering as business key. For example, I have 2 locations as: India and UK. I want to fetch the process instances of these two locations. Means I need to pass the multiple business key values. Is it possible to pass the multiple business key values and fetch the process instances of these 2 business key values [multiple business key values]?
Thanks & Regards
Shilpa Kulkarni

There's no out of the box functionality for this. but you can always query process instances based on variable values. e.g. create a service which takes multiple keys as argument and query them separately with runtimeService.createProcessInstanceQuery().variableValueLike("location", "yourKey").list(); this will return all process instances with having location as yourKey entered.

An Activiti process instance can only have a single associated Business key. However you can retrieve a list of instaces based on a list of buisiness keys and other properties by using a process instance query.

Related

How to handle commands for aggregates with IDs assigned after command?

I know the subject line doesn't make sense given the way Axon works, but here is my problem:
I need to create a new instance of aggregate, "Quote", that is tied to a backend system of record. That is, the aggregate ID must eventually match the ID assigned in the backend system.
So, my uiServer app is calling commandGateway and sending it a CreateQuoteCmd, but I don't know what to pass as the target aggregate ID, since the ID will come from a backend system called by the command handler. The uiServer cannot assign the quoteId. The command handler for CreateQuoteCmd contacts our backend system to get the new quoteId. The backend system also supplies several default values which will be placed in the aggregate.
So, how do I make that quoteId the ID for the aggregate?
What do I pass as the target aggregate ID in the command object?
Is it true that I must pass a target aggregate ID in CreateQuoteCmd instead of allowing the object to set its own ID in the command handler after communication with the backend system?
Thanks for your help.
The Command which will create an Aggregate is not inclined to have a #TargetAggregateIdentifier annotated field. This holds as the field which is the 'target aggregate identifier', cannot point to an existing aggregate, as that command will be the starting point of an aggregate.
The creation of the Aggregate Identifier can happen at several points in your system, and is really up to you.
The important part here though is that the #CommandHandler annotated constructor within an Aggregate has a return value, which is the Aggregate Identifier you have assigned to that Aggregate.
You should thus handle the result given to you from the CommandGateway/CommandBus when dispatching your CreateQuoteCmd. This should contain the QuoteId you have assigned to your (I assume) Quote Aggregate.
You need to get the aggregate ID from the external system before sending the command (at domain or application service layer)

to get data from table without using reference of state

am trying to get the value from db without using serviceHub and vault.but i couldn't. what my logic is, when i pass the country name, it should return the id's(PK)of that country which is in one table.using those id's, it should return the values related to those id's from other table.it could be possible in flow class.but am trying to do in api class where servicehub couldn't import. Please help me out.
Only the node has access to the ServiceHub. The API runs outside of the node in a separate process, so it is limited to interacting with the node via the operations offered by CordaRPCOps.
Either you need to store the data you want to access in a separate database outside of the node, or you need to find some way to programatically log into the node's database from the API, using JDBC as described here: https://docs.corda.net/node-database.html.

How to store only node specific off-ledger custom data in corda?

I created custom table in corda using QueryableState. e.g. IOUStates table.
I can able to see the custom information getting stored in this kind of table.
but i observed that if party A and Party B is doing the transaction then this
custom information gets stored at both the places , e.g. IOUStates
table getting created at nodeA ledger as well as nodeB's ledger.
and custom information is stored in partyA's and PartyB's ledger.
My Question is :-
If some Transaction is getting processed from PartyA's node , then
I want to store part of the transaction's data i.e. custom data ONLY at partyA's Ledger.* level . i.e. off-Ledger of partA only.
It should not be shared with partyB.
In simple case , how to store Only node specific off ledger custom data ?
Awaiting for some reply...
Thanks.
There's a number of ways to achieve this:
Don't use Corda at all! If the data is truly off-ledger then why are you using Corda? Instead, store it in a separate database. Of course you can "JOIN" it with on-ledger data if required, as the on-ledger data is stored in a SQL database.
Similar to point one except you can use the jdbcSession() functionality of the ServiceHub to create a custom table in the node's database. This table can easily be accessed from within your flows.
Create a ContractState object that only has one participant: the node that wants to store the data. I call this a "unilateral" state, i.e. a state that only one party ever stores.
Most importantly, if you don't want to share some data with a counter-party then it should never be disclosed inside a corda state object or attachment that another party might see. Instead:
inside your flows, you can use the data encapsulated within the shared state object (e.g. the IOU) to derive the private data
alternatively if the data is supplied when the flow begins then store the private data locally using one of the methods above

Whats the most efficient way to create an orchestration which updates an Oracle database?

I am creating my first orchestration in Biztalk and am having trouble coming up with an efficient way to update a database (specifically, up to 3 different tables).
The user calls our service with an inbound message matching a schema which contains emplid (unique id) and then a bunch of name-value pairs (see source schema in this picture). The "name" corresponds to a column in a table (e.g. if the name is "employeename" it corresponds to the NAME column of the EMPLOYEE table). The value of course is the new value that the user wants that column to be updated to.
So they could pass in an update message which only applies to 1 table, 2 tables, or all 3, depending on the fields they want to update for the passed in employee.
I am currently approaching it as 3 separate updates with 3 table adapters (one for each table, one of which is pictured above) but Im having trouble working with the different cases of if they pass in updateValuePairs for all 3 tables, versus only one or only for two tables (the other queries still attempt to run and fail). Am I approaching this right? Or is there a better way to accomplish what I am trying to do?
i would try i different way in order to implement cleaner solution,
create a Store-Procedure that handle the logic to which table to go
than you will need only on mapping and one LOB adapter instead of the 3 you got now
over view solution
1.receive input in the orchestration
2.mapping the input to the Stored procedure generated schema
3.sending the mapped data to the DB/LOB adapter into the DB
here is a link that can help you (im assuming you use biztalk 2010):
How to use Oracle Stored Procedure

how to generate unique id per user?

I have a webpage Default.aspx which generate the id for each new user after that the id will be subbmitted to database on button click on Default.aspx...
if onother user is also entering the same time the id will be the same ... till they press button on default.aspx
How to get rid of this issue...so that ... each user will be alloted the unique id ...
i m using the read write code to generate unique id ..
You could use a Guid as ids. And to generate an unique id:
Guid id = Guid.NewGuid();
Another possibility is to use an automatically incremented primary column in the database so that it is the database that generates the unique identifiers.
Three options
Use a GUID: Guid.NewGuid() will generate unique GUIDs. GUIDs are, of course, much longer than an integer.
Use intelocked operations to increment a shared counter. Interlocked.Increment is thread safe. This will only work if all the requests happen in the same AppDomain: either process cycling on a refresh of the code will create a new AppDomain and restart the count.
Use an IDENTITY column in the database. The database is designed to handle this, within the request that inserts the new row, use SCOPE_IDENTITY to select the value of the identity to update in memory data (ORMs should handle this for you). (This is SQL Server, other databases have equivalent functionality.)
Of there #3 is almost certainly best.
You could generate a Guid:
Guid.NewGuid()
Or you could let the database generate it for you upon insert. One way to do this is via a Sequence. See the wikipedia article for Surrogate Keys
From the article:
A surrogate key in a database is a unique identifier for either an entity in the modeled world or an object in the database. The surrogate key is not derived from application data.
The Sequence/auto-incremented column option is going to be simpler, and easier to remember when manually querying your DB (during debugging), but the DBA at my work says he's gotten 20% increases in performance by switching to Guids. He was using Oracle, and his database was huge, though :)
I use a utility static method to generate id's, basically use the full datetime(including seconds) and generate a random number of say 3 or 4 characters and return the whole thing, then you can save it to the database.

Resources