about Hyperledger Fabric, how is the data passed to my Chaincode? - hyperledger

1:When I call the "Invoke" method, how is the data passed to my Chaincode?Can you post some primary functions?
{
"jsonrpc": "2.0",
"method": "invoke",
"params": {
"type": 1,
"chaincodeID":{
"name":"mycc"
},
"ctorMsg": {
"args":["invoke", "a", "b", "10"]
}
},
"id": 3
}
2:How and when the consensus service put data to database?

The invoke is part of your chaincode. You have to deploy your chaincode You can call your chaincode via a REST API or I recommend you take a look at learn-chaincode.
1: https://github.com/IBM-Blockchain/learn-chaincode and from there the marbles example here: Marbles Example

Related

AWS Lex Python Codehook references

I am still pretty new to Python (and coding) but I am trying to build my own Lex bot with a Lambda function. I have been following the tutorials and I can understand how it all works. Problem is when I am trying to write my own Lambda functions for Lex, I cannot find any references to help me write my code for example looking at the code below.
def get_slots(intent_request):
return intent_request['currentIntent']['slots']
What is "(intent_request)" and where would I find reference to this? Same for "['currentIntent'], how can I find out what it is and why it is there??
Sorry if this seems stupid to most people on here but I can't start writing code and continue to learn if I can't find any documentation to suggest what these are and why they are needed in order to write code for my own Lex bots.
Thanks in advance!!!
The intent_request is the incoming "request" or "event" from Lex to your Lambda Function. It holds all the necessary information about the user's input and your Lex bot's processing of that input (trigger certain intent, fill certain slots, confirmations, etc.)
This should be the documentation you are looking for.
Lambda Function Input Event and Response Format:
This section describes the structure of the event data that Amazon Lex provides to a Lambda function. Use this information to parse the input in your Lambda code. It also explains the format of the response that Amazon Lex expects your Lambda function to return.
And here is the Event/Request format:
{
"currentIntent": {
"name": "intent-name",
"slots": {
"slot name": "value",
"slot name": "value"
},
"slotDetails": {
"slot name": {
"resolutions" : [
{ "value": "resolved value" },
{ "value": "resolved value" }
],
"originalValue": "original text"
},
"slot name": {
"resolutions" : [
{ "value": "resolved value" },
{ "value": "resolved value" }
],
"originalValue": "original text"
}
},
"confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)"
},
"bot": {
"name": "bot name",
"alias": "bot alias",
"version": "bot version"
},
"userId": "User ID specified in the POST request to Amazon Lex.",
"inputTranscript": "Text used to process the request",
"invocationSource": "FulfillmentCodeHook or DialogCodeHook",
"outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request",
"messageVersion": "1.0",
"sessionAttributes": {
"key": "value",
"key": "value"
},
"requestAttributes": {
"key": "value",
"key": "value"
}
}
The slots data is found inside currentIntent and that is inside of this whole intent_request object. That is why you are seeing the code: intent_request['currentIntent']['slots']
So to get session attributes you can find them here: intent_request['sessionAttributes']
Also extremely useful is the exact user input text:
intent_request['inputTranscript']

SAPUI5, Datasource from 2 different URL

I am new in SAPUI5, currently I am building a SAPUI5 application and consumes ODATA services from backend. When I am creating an application and select service URL.
Service URL as following attachment.
However, now in my application I have to add another data source with totally url. In my manifest.json. I just can change different navigation of the same url as following
"dataSources": {
"mainService": {
"uri": "/sap/opu/odata/sap/SEPMRA_SHOP/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
},
"mainService2": {
"uri": "/odata/V2/OData/OData.svc/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
How can I add different url of datasource for SAPUI5 application?
You need to create a Destination in your SAP Cloud Platform cockpit.
You are already using one called "odata - odata" as per your screenshot.
You have the documentation here
And a screenshot below.
Fuertheremore, if you want to access a NW system in your private network from the cloud, you need to set up a Cloud connector. Check the documentation here
SAP Cloud Platform configuration
Once you have your destinations configured and you dataSource block already there (as you have in the screenshot), you need to create 2 OData models. So in your metadata.json file, go to the bottom, and there is a node called 'models' where you probably have something like this:
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
...
}
},
"": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request"
},
"dataSource": "mainService",
"preload": true
},
"dataModel2": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request"
},
"dataSource": "mainService2",
"preload": true
}
}
You need to add the block "dataModel2":{ ... }
Where:
"dataModel2" is the name of your second model (choose the one you like, it doesn't need to be dataModel2).
Make sure that "dataSource": "mainService2" so this model points to your second data source
In the settings you can set the model as you want. Probably the most important is the "defaultBindingMode". Set it as "OneWay" if it is only readable, or "TwoWay" if it is read/write-able.
Then you just need to define all your bindings to this model with the modelName you choose as described in the first bullet point. For instance:
<Text text="{dataModel2>/path/to/my/property"}"></Text>
But be careful with this architecture, as per SAP Best Practices, you should try always to use only one OData service. Having more than one could be a nightmare to maintain, specially if you suscribe to model change/dataRequested/dataReceived events or for error handling with metadataFailed/metadataLoaded events, because you will have to manage them for both models and they are asynchronous...

Bluemix blockchain: How can i query out this?

I need to know how to query the following invoke(AC(123456A)or (user_type1_c19a5f0b7e) when i have init this:
{
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 1,
"chaincodeID": {
"path": "https://github.com/johndoe/learn-chaincode/finished"
},
"ctorMsg": {
"function": "init",
"args": [
"hi there"
]
},
"secureContext": "user_type1_191b8c2993"
},
"id": 1
}
Here is my (successful) invoke:
{
"jsonrpc": "2.0",
"method": "invoke",
"params": {
"type": 1,
"chaincodeID": {
"name": "b42b506c13fg1157520d585841a691f4b598d9aac53adc95277ed710c7f1f5aaa59a89a8dca8ddf3e46d5241562f3316956a04ad8a33181d30cb01b1c4c9adb2f"
},
"ctorMsg": {
"function": "AC(123456A)",
"args": [
"AcctId:949392949233 ","Year2015 Sem1 ", "IT1234:A ", " IT2345:B+ ", "IT3456:A ", "Year 2015 Sem2 ", "IT4567:B ", "IT5678: B", "IT5678:A ","Year 2016 Sem1 ", "IT6789:C ", "IT7890:C ", "Cumulative GPA: 3"
]
},
"secureContext": "user_type1_c19a5f0b7e"
},
"id": 4
}
Here is the query that I am trying and I can't get the results that I want:
{
"jsonrpc": "2.0",
"method": "query",
"params": {
"type": 1,
"chaincodeID": {
"name": "b42b506c13fg1157520d585841a691f4b598d9aac53adc95277ed710c7f1f5aaa59a89a8dca8ddf3e46d5241562f3316956a04ad8a33181d30cb01b1c4c9adb2f"
},
"ctorMsg": {
"function": "AC(123456A)",
"args": [
"AcctId:949392949233 "
]
},
"secureContext": "user_type1_c19a5f0b7e"
},
"id": 2
}
Here's the response for the query.
{
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "Query failure",
"data": "Error when querying chaincode: Error:Transaction or query returned with failure: Received unknown function query"
},
"id": 2
}
Right now, I am trying out this tutorial, which is provided by IBM Bluemix:
https://github.com/IBM-Blockchain/learn-chaincode.
I have tried an init using their example and do invoke(successful) to suit my needs. I tried the Bluemix tutorial, which I mentioned earlier, and I am able to achieve what is stated in the documentation. Therefore, I decided to invoke something to suit my own needs. However, i am unable to query the person AC(123456A) or user_type1_c19a5f0b7e with showing of items such as "Year2015 Sem1", "IT1234:A", "IT3456:B+ " and etc . How can I query (the invoke) to suit my own needs?
Our understanding is that you are using an IBM Blockchain Starter Developer Network on IBM Bluemix. Using this environment, the "Learn Chaincode" tutorial (https://github.com/IBM-Blockchain/learn-chaincode) has been followed. We would like to confirm our understanding of your results when following the tutorial. Our understanding is that when following the tutorial, the Init, Invoke, and Query chaincode functions all operated as expected. Is the understanding correct that the tutorial as written could be followed successfully?
Then we understand that the example chaincode was modified to apply different logic. The Invoke for this modified chaincode that uses the AC(123456A) function with a user of user_type1_c19a5f0b7e appears to have been successful. However, a query that also used the AC(123456A) function was not successful. Is this understanding correct?
Could some additional details be provided so this can be considered further?
Did you write your own customized chaincode? If so, could this chaincode (including the AC(123456A) function definition) be provided?
Is the AC(123456A) function located in the same Go source file as the rest of the chaincode?
We imagine that the user named user_type1_c19a5f0b7e was registered since the Invoke did work. Were steps to register this user followed as noted in the "Secure Enrollment" section of the "Learn Chaincode" tutorial?
Can the AC(123456A) function both write values to the ledger (through the Invoke) and read values from the ledger (as is being attempted through the Query)?

Query for all tasks in specific workspace that are not completed

I have the following cURL cmd running which returns all tasks for a specific userID within a specific workspaceID, but the "completed=false" part of the cmd doesn't influence the data returned. I am trying to exclude all "completed" tasks. Everything else is working as I expected. Below is the current cmd string and a snippet of the data returned back. As you can see one of the returned tasks indicates "completed" is true while the other indicates false.
Anyone see what I may be missing? Thanks in advance for your help.
cURL cmd:
curl -u <api-key>: "https://app.asana.com/api/1.0/tasks?workspace=<workspace>&assignee=<teamMemberId>&completed=false&opt_fields=name,assignee,assignee_status,notes,created_at,modified_at,completed_at,due_on,completed&opt_pretty"
output (partial)
{
"data": [
{
"id": <ID>,
"created_at": "2014-03-11T03:34:52.002Z",
"modified_at": "2014-03-11T23:33:07.544Z",
"name": "<nameoftask>",
"notes": "",
"assignee": {
"id": <ID>
},
"completed": true,
"assignee_status": "upcoming",
"completed_at": "2014-03-11T23:33:06.729Z",
"due_on": "2014-03-11"
},
{
"id": <ID>,
"created_at": "2014-03-11T23:33:07.196Z",
"modified_at": "2014-03-11T23:33:07.196Z",
"name": "<nameoftask>",
"notes": "",
"assignee": {
"id": ID>
},
"completed": false,
"assignee_status": "upcoming",
"completed_at": null,
"due_on": "2014-03-14"
},
TL;DR: You want completed_since=now, not completed=false.
The GET /tasks endpoint doesn't take a parameter completed - it does however take completed_since, which can take a timestamp (as provided by JS's .toISOString()) or the string "now". It always includes incomplete tasks. This is documented in the API Docs on Tasks (specifically the section on "Querying for tasks").
We're looking to improve the way you can filter tasks, but for right now what's documented there is all there is.

Activiti - Get Process Instance Details" Java API

I am using Activiti 5.12. As provided, in its user guide, REST API to get he details of a process instance is :
GET /process-instance/{processInstanceId}
Its response is something like this :
{
"id": "2",
"processDefinitionId": "financialReport:1",
"businessKey": "55",
"startTime": "2010-10-13T14:54:26.750+02:00",
"startActivityId": "startFinancialAnalysis",
"startUserId": "kermit",
"completed": false,
"tasks": [
{
"taskId": "3",
"taskName": "Analyze report",
"owner": null,
"assignee": "Kermit",
"startTime": "2010-10-13T14:53:26.750+02:00",
"completed": false
}
],
"activities": [
{
"activityId": "4",
"activityName": "Get report",
"activityType": "ServiceTask",
"startTime": "2010-10-13T14:53:25.950+02:00",
"completed": true,
"duration": 200
}
],
"variables": [
{
"variableName": "reportName",
"variableValue": "classified.pdf"
}
],
"historyVariables": [
{
"variableName": "reportName",
"variableValue": "classified.pdf",
"variableType": "String",
"revision": 1,
"time": "2010-10-13T14:53:26.750+02:00"
}
]
}
A JAVA API for the same is also provided, which is :
ProcessEngines.getProcessEngine(configuredProcessEngineName).getHistoryService().createHistoricProcessInstanceQuery().processInstanceId("somevalue").singleResult()
This Java API does not work, as teh return type HistoricProcessInstance does not have the method to get the task list.
My objective is to get the current state of a process instance, i.e which task it's presently at.
The REST API lists all tasks that process instance has carried out and the last task of the list is the one it's currently executing, as its property completed is false.
I want to achieve the same from java code.
Can you please help me out. Any alternative way to get to my objective is also fine with me.
You can use another query of HistoricService API:
List<HistoricTaskIntance> taskList = getHistoryService()
.createHistoricTaskInstanceQuery()
.processInstanceId(processInstanceId)
.list()
The current task status can be defined by HistoricTaskInstance.getEndTime() that will return null for open tasks.
I have tried this way out.
SELECT NAME_ FROM act_hi_taskinst where PROC_INST_ID_= 1000 and END_TIME_ IS NULL;"
act_hi_taskinst contains history tasks for each and every instance.
If the process with instance id is completed then you wont get any result, so you can check that condition before moving forward.
I have run this piece of SQL Statement to get the required task name.
The answer given by #Mike also meets the objective. Even here also you have to check whether process is incomplete.

Resources