How to set the ProcessFlowLaneHeader state with JSON-model? - sapui5

i'm currently working on an SAPUI5 app which includes a Process Flow control.
I want to set the state of the ProcessFlowLaneHeader according to values in my JSON-model but it keeps changing to a state represting each existing state of the nodes.
So I want the "donut" to show 2/3 of green, 1/12 of grey and 1/4 of red color(see JSON below). Instead it shows me 1/3 of each. When I look at the properties of the ProcessFlowLaneHeader through the UI5 Inspector while the app is running it shows me:
state: {
0: {
"state": "Positive",
"value": 1
}
1: {
"state": "Negative",
"value": 1
}
2: {
"state": "Neutral",
"value": 1
}
3: {
"state": "Planned",
"value": 0
}
4: {
"state": "Critical",
"value": 0
}
Did i make a mistake or is SAUPUI5 just overwriting my state?
How can I set the state of the ProcessFlowLaneHeade?(onInit on controller?)
My JSON:
...
"lanes": [{
"id": "0",
"icon": "sap-icon://sales-quote",
"label": "MoBe",
"position": 0,
"state": [{
"state": "Positive",
"value": 8
}, {
"state": "Negative",
"value": 1
}, {
"state": "Neutral",
"value": 3
}, {
"state": "Planned",
"value": 0
}, {
"state": "Critical",
"value": 0
}]
},
...
My View:
<ProcessFlow id="processflow1" foldedCorners="false" wheelZoomable="false" class="PFLayoutSpec" nodes="{Monitor1>/nodes}" lanes="{Monitor1>/lanes}">
<nodes>
<ProcessFlowNode laneId="{Monitor1>lane}" nodeId="{Monitor1>id}" title="{Monitor1>title}" children="{Monitor1>children}" state="{Monitor1>state}" value="{Monitor1>value}" stateText="{Monitor1>stateText}" texts="{Monitor1>texts}" highlighted="{Monitor1>highlighted}" focused="{Monitor1>focused}" titleAbbreviation="{Monitor1>titleAbbreviation}"/>
</nodes>
<lanes>
<ProcessFlowLaneHeader laneId="{Monitor1>id}" iconSrc="{Monitor1>icon}" text="{Monitor1>label}" position="{Monitor1>position}" state="{Monitor1>state}" press="onChangeDonut"/>
</lanes>
</ProcessFlow>
Thank you for your help!

Because you are showing documents in the nodes aggregation, the ProcessFlowLaneHeader state is automatically calculated from the states of the documents.
See documentation:
This type is used in the 'state' property of the ProcessFlowLaneHeader. For example, app developers can set the status of the lane header if lanes are displayed without documents. If the complete process flow is displayed (that is, if the lane header is displayed with documents underneath), the given state values of the lane header are ignored and will be calculated in the ProcessFlow according to the current state of the documents.

Related

Autocomplete: Read LAT/LON

Is there an easy way to obtain the geolocation data of an autocomplete reply?
Currently only text is returned in a query. How would one read the GPS coordinates for an entry?
https://autocomplete.search.hereapi.com/v1/autocomplete?apiKey=xxx&q=k%C3%B6ln%20&in=countryCode:DEU&lang=de&limit=20&resultType=city,postalCode
{
"title": "Deutschland, Köln, Anschlussstelle Köln-Messe",
"id": "here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD",
"resultType": "street",
"address": {
"label": "Anschlussstelle Köln-Messe, 50679 Köln, Deutschland",
"countryCode": "DEU",
"countryName": "Deutschland",
"stateCode": "NW",
"state": "Nordrhein-Westfalen",
"countyCode": "K",
"county": "Köln",
"city": "Köln",
"street": "Anschlussstelle Köln-Messe",
"postalCode": "50679"
},
"highlights": {
"title": [
{
"start": 35,
"end": 39
}
],
"address": {
"label": [
{
"start": 16,
"end": 20
}
],
"street": [
{
"start": 16,
"end": 20
}
]
}
}
},
The idea of autocomplete is to provide key-by-key input completion for the end user. We believe the end user can decide based on the text response and does not need to show the position on the map. Only for the result that the user clicks on a lookup needs to be requested from the application which then shows the complete address including position.
So to get the geolocation, you need to use lookup endpoint while the user clicks, e.g: https://lookup.search.hereapi.com/v1/lookup?id=here:af:street:kXSoQ5Ilp2fEnS-ifyMsXD&apiKey={{YOUR_API_KEY}}
In addition, you can evalaute the autosuggestion endpoint (which contains the position info) and see if it can meet your requirement: https://developer.here.com/documentation/geocoding-search-api/dev_guide/topics/endpoint-autosuggest-brief.html

MongoDB - MongoImport of JSON (jsonl) - Rename, change types and add fields

i'm new to the topic MongoDB and have 4 different problems importing a big (16GB) file (jsonl) into my MongoDB (simple PSA-Cluster).
Below attached you will find a sample entry from the mentiond JSON-Dump.
With this file which i get from an external provider I actually have 4 problems.
"hotel_id" is the key and should normally be (re-)named as "_id"
"hotel_id" should not be treated as string rather than as Number
"location" is not properly formatted (if i understood correctly the MongoDB Manual) as GeoJSON as it should be like
"location": {
"type": "Point",
"coordinates": [-93.26838,37.15845]
}
instead of
"location": {
"coordinates": {
"latitude": 37.15845,
"longitude": -93.26838
}
}
"dates" can this be used to efficiently update just the records which needs to be updated?
So my challenge is now to transform the data according to my needs before importing the data or at time of import, but in both cases of course as quickly as possible.
Therefore i searched a lot for hints and best practices, but i was not able to find a solution yet, maybe due to the fact that i'm a beginner with MongoDB.
I played around with "jq" to adjust the data and for example add the type which seems to be necessary for the location (point 3), but wasn't really successful.
cat dump.jsonl | ./bin/jq --arg typeOfField Point '.location + {type: $typeOfField}'
Beside that i was injecting a sample dump of round-about 500MB which took 1,5 mins when importing it the first time (empty database). If i run it in "upsert" mode it will take round-about 12 hours. So i was also wondering what is the best practice to import such a big JSON-dump?
Any help is appreciated!! :-)
Kind regards,
Lumpy
{
"hotel_id": "12345",
"name": "Test Hotel",
"address": {
"line_1": "123 Test St",
"line_2": "Apt A",
"city": "Test City",
},
"ratings": {
"property": {
"rating": "3.5",
"type": "Star"
},
"guest": {
"count": 48382,
"average": "3.1"
}
},
"location": {
"coordinates": {
"latitude": 22.54845,
"longitude": -90.11838
}
},
"phone": "555-0153",
"fax": "555-7249",
"category": {
"id": 1,
"name": "Hotel"
},
"rank": 42,
"dates": {
"added": "1998-07-19T05:00:00.000Z",
"updated": "2018-03-22T07:23:14.000Z"
},
"statistics": {
"11": {
"id": 11,
"name": "Total number of rooms - 220",
"value": "220"
},
"12": {
"id": 12,
"name": "Number of floors - 7",
"value": "7"
}
},
"chain": {
"id": -2,
"name": "Test Hotels"
},
"brand": {
"id": 2,
"name": "Test Brand"
}
}

A good example of using the Mapbox distance API

I am trying to use Mapbox to calculate the duration between two locations however the examples here are incomplete (at least with my limited experience). I would like to connect to this API using server-side Java, however I can't even get a basic example working in javaScript, Python or simply in the address bar in my browser.
I can get an example working in my browser using this url and substituting in my API key:
https://api.mapbox.com/geocoding/v5/mapbox.places/Chester.json?country=us&access_token=pk.my-token-value
However I can't get a similar example working with the distance API. The best I can manage is something like this:
https://api.mapbox.com/distances/v1/driving/[13.41894,52.50055],[14.10293,52.50055]&access_token=pk.my-token-value.
But I have no idea how to format my coordinates as I can't find a single example.
Has anyone been able to get this working. Ideally in Java, but client-side JavaScript or a valid url would be a great start.
I should also add that I can't get the JavaScript or Python ones working as they rely on external librarys that aren't referenced anywhere in the documentation!.
Thanks in advance.
Looks like you can provide a list of 2 or more semi-colon separated coordinates:
https://api.mapbox.com/optimized-trips/v1/mapbox/driving/13.41894,52.50055;14.10293,52.50055?access_token=pk.your_token
returns:
{
"code":"Ok",
"waypoints":[
{"distance":9.0352511932471,"name":"","location":[13.418991,52.500625],"waypoint_index":0,"trips_index":0},
{"distance":91.0575241567836,"name":"Berliner Chaussee","location":[14.103096,52.499738],"waypoint_index":1,"trips_index":0}
],
"trips":
[
{"geometry":"}_m_Iu{{pA}ZuQ}Iad#}cAk^jr#etOdE_iGtTqoAxBkoGnOkiCjR_s#wJ_v#b#}aN|aBogRyVucBiEw_C~r#_eB`Fc`NtP_bAshBorHa#}dCkOe~AmPmrGlPlrGjOd~A`#|dCrhBnrHuP~aAaFb`N_s#~dBhEv_CxVtcBkbBbeRo#l`NzJ`z#mRpr#qOpjCwBpnGoT~lAeEdkGsr#jtOtp#dQ~UjTtDfZf]jS",
"legs":[
{"summary":"","weight":4198.3,"duration":3426.4,"steps":[],"distance":49487},
{"summary":"","weight":7577.8,"duration":3501.3,"steps":[],"distance":49479.7}
],
"weight_name":"routability",
"weight":11776.1,
"duration":6927.700000000001,
"distance":98966.7}
]
}
I don't know if this is better now, but I had to work through it right now and can give you this example
curl "https://api.mapbox.com/directions-matrix/v1/mapbox/driving/9.51416,54.47004;13.5096410,50.0716190;6.8614070,48.5206360;14.1304840,51.0856060?sources=0&access_token={token}"`
This will return the following json for driving durations. I made use of the sources attribute, which is my search lng/lat and all other points are places in my database.
{
"code": "Ok",
"durations": [
[0.0, 29407.9, 34504.7, 24163.5]
],
"destinations": [{
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}, {
"distance": 34.636975593,
"name": "",
"location": [13.509868, 50.071344]
}, {
"distance": 295.206928933,
"name": "",
"location": [6.863566, 48.52287]
}, {
"distance": 1186.975749670,
"name": "",
"location": [14.115694, 51.080408]
}],
"sources": [{
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}]
}
Adding the annotations=distance parameter to the url will return the distances instead of the durations if you need that.
{
"code": "Ok",
"distances": [
[0.0, 738127.3, 902547.6, 616060.8] // distances in meters
],
"destinations": [{ // destinations including the source
"distance": 131.946157371, // result 0
"name": "",
"location": [9.514914, 54.468939]
}, {
"distance": 34.636975593, // result 1
"name": "",
"location": [13.509868, 50.071344]
}, {
"distance": 295.206928933, // result 2
"name": "",
"location": [6.863566, 48.52287]
}, {
"distance": 1186.975749670, // result 3
"name": "",
"location": [14.115694, 51.080408]
}],
"sources": [{ // source where we start from
"distance": 131.946157371,
"name": "",
"location": [9.514914, 54.468939]
}]
}

facebook real-time page api response analysis

i'm getting callbacks from facebook and response like this ;
{
"object": "page",
"entry": [
{
"id": "2407411660blabla",
"time": 1450266812,
"changes": [
{
"field": "feed",
"value": {
"item": "comment",
"verb": "add",
"comment_id": "787904161316072_blabla",
"post_id": "240741166032377_blabla",
"parent_id": "240741166032377_blabla",
"sender_id": 1020447568blabla,
"created_time": 1450266812,
"message": "blalba lba lba bla",
"sender_name": "Mehmet Tubay Saban"
}
}
]
}
As you can see , there are two array in this json;
1- entry[]
2- changes[]
Sometimes "entry array" has 1 or more items and some times "changes array" has 1 or more items , what is different between entry and changes array of objects ?
It seems to be based on the "time" value.
If several actions has the same "time" value they will appear in the changes[] array.

Is there a way to get recent video.watches activity for a specific app?

I want to give the user a UI to delete activity. I'm aware of it, but I'd rather not use the Activity social plugin. I know that it is possible to get activity using Graph API:
me/video.watches
example response:
{ "data": [ {
"id": "10101573590568760",
"from": {
"id": "123546",
"name": "John Doe"
},
"start_time": "2012-02-01T18:53:34+0000",
"end_time": "2012-02-01T18:53:34+0000",
"publish_time": "2012-02-01T18:53:34+0000",
"application": {
"id": "123456789123",
"name": "test_app"
},
"data": {
"movie": {
"id": "123456789123456789",
"url": "http://example.com/movie/My-Movie-Title",
"type": "video.movie",
"title": "My Movie Title"
}
}, "likes": {
"count": 0
}, "comments": {
"count": 0
}
}
However, for global action types, this may return other apps as well. I am only interested in my app specifically. Is there a way to limit returned data to my app only?
Appears that video.watches only returns activity items for the current app.