how to set a map value in velocity - velocity

I tried to define a map in velocity template using the following syntax. It did not work, does anyone know how to declare a map of constant values in velocity?
#set ($mymap = {"key" : "value" , "key2" : "value"})
EDIT: I am using 1.6.3 version of velocity

It worked for me. Maybe you have very old version of Velocity?
#set ($mymap = {"key" : "value" , "key2" : "value2"})
get: ${mymap.key}
or: ${mymap.get("key")}

Related

Vue-Select reduce is not working - Showing ID instead of the label

I am using this vue select https://vue-select.org/guide/values.html#getting-and-setting for the dropdown countries. Here is the code:
<v-select
v-model="project_data.country"
:options="project_data.countries"
:reduce="country => country.value"
label="label"
:state="errors.length > 0 ? false : null"
/>
This project_data.country value is : 5
This project_data.countries value is array of object. Something like :
[
{ value : 1, label : Dhaka },
{ value : 2, label : India },
and so on ......
]
Now on my local, I can see the label on the dropdown BUT when I complied the code using :
npm run prod
and compressed the whole project and upload to live server then I can see the ID instead of the label. Something like this:
Does anyone know why? I am spending tooooo many hours to figure it out :( :( :(
My goal is to get the single ID value from the dropdown ( I can ) and save it to the database and then again show the label ( I can't ) based on the single ID value.
A common issue with that select and its in the Docs, its that you need to make sure that the value for v-model:
If options has by example only these 2:
[
{ value : 1, label : Dhaka },
{ value : 2, label : India }
]
and project_data.country is 3 the select will show the value 3 since the Vue Select searched for it and didnt find it.
So make sure in prod you have 5 in the list of countries.

what is the meaning of (=>) = (,)?

In the mouse drag example in Elm have defined (=>) = (,) so that a list is defined this way:
style [ "background-color" => "#67BF46" , "cursor" => "move" ]
I am more accustomed to:
style [ ( "background-color" , "#67BF46" ) , ( "cursor" , "move" ) ]
are these equivalent? This looks more like a record to me, but not even that.
Yes, they are equivalent. That library is merely defining an infix function => they deem prettier than using tuple syntax.

FIWARE-Orion Context Broker metadata updates trigger notifications

I'm using 3 FIWARE GEs: IDAS+Orion+CEP.
As reported in the Orion documentation (https://github.com/telefonicaid/fiware-orion/blob/develop/doc/manuals/user/metadata.md) "changing the metadata of a given attribute or adding a new metadata element is considered a change even if attribute value itself hasn't changed".
Is there a way to send notifications from Orion only if the value of the attribute specified in the subscription changes?
I've tried the solution proposed in the documentation, delete and re-create the attribute, in order to remove the metadata. But, since the messages to Orion are produced by IDAS, the metadata are created with the new communication.
Thanks.
UPDATE:
GEs Version:
- Orion - 0.26.1-next
- IoTAgent (IDAS) - 1.3.1
The metadata added by IDAS are:
"attributes" : [
{
"name" : "temperature",
"type" : "int",
"value" : "37",
"metadatas" : [
{
"name" : "TimeInstant",
"type" : "ISO8601",
"value" : "2015-12-29T12:46:04.421859"
}
]
}
]
Specifically, from mongodb query:
"temperature" : { "value" : "37", "type" : "int", "md" : [ { "name" : "TimeInstant", "type" : "ISO8601", "value" : "2015-12-29T12:46:04.421859" } ], "creDate" : 1450716887, "modDate" : 1451393164 }
As far as I know, TimeInstant metadata sending from IDAS/IoTAgent to Orion couldn't be disabled by the time being.
A possible workaround could be to have a proxy between IDAS and Orion ir order to remove the TimeInstant metadata (or the whole metadata field in JSON to prevent some other metadata could be causing a similar problem).

artifactory rest api fully qualified class search

Is there any way to use fully qualified class name to search from Artifactory(similar to class-searth in Artifactory web UI). Based on this Documentation , i know i can use wildcard(*) and .class file extension like this:-
GET /api/search/archive?name=*Logger.class&repos=third-party-releases-local,repo1-cache
But i am looking for a way to use fully qualified class name similar to this:-
GET /api/search/archive?name=org.apache.log4j.Logger&repos=third-party-releases-local,repo1-cache
but this is not working.
You can use the Artifactory query language for this.
For example, a query for searching an archive item called org/apache/log4j/Logger.class in the jcenter-cache repository would be
items.find({
"repo" : "jcenter-cache",
"archive.entry.name":{"$eq":"Logger.class "},
"archive.entry.path":{"$eq":"org/apache/log4j"}
})
The response would be
{
"results" : [ {
"repo" : "jcenter-cache",
"path" : "org/apache/log4j/com.springsource.org.apache.log4j/1.2.16",
"name" : "com.springsource.org.apache.log4j-1.2.16.jar",
"type" : "file",
"size" : 481202,
"created" : "2015-12-30T20:57:36.305Z",
"created_by" : "admin",
"modified" : "2010-08-04T13:18:06.000Z",
"modified_by" : "admin",
"updated" : "2015-12-30T20:57:36.354Z"
} ],
"range" : {
"start_pos" : 0,
"end_pos" : 1,
"total" : 1
}
}
To run such a query using curl use the following when the query is inside a file names aql.txt
curl -H "content-type: text/plain" -uuser:password --data #aql.txt http://my-artifactory-host/api/search/aql

Elasticsearch bulk/batch indexing with python requests module

I have a smallish (~50,00) array of json dictionaries that I want to store/index in ES. My preference is to use python, since the data I want to index is coming from a csv file, loaded and converted to json via python. Alternatively, I would like to skip the step of converting to json, and simply use the array of python dictionaries I have. Anyway, a quick search revealed the bulk indexing functionality of ES. I want to do something like this:
post_url = 'http://localhost:9202/_bulk'
request.post(post_url, data = acc ) # acc a python array of dictionaries
or
post_url = 'http://localhost:9202/_bulk'
request.post(post_url, params = acc ) # acc a python array of dictionaries
both request give a [HTTP 500 error]
My understanding is that you have to have one "command" per line (index, create, delete...) and then some of them (like index) takes a row of data on the next line like so
{'index': ''}\n
{'your': 'data'}\n
{'index': ''}\n
{'other': 'data'}\n
NB the new-lines, even on the last row.
Empty index objects like above works if you POST to ../index/type/_bulk or else you need to specify index and type I think, have not tried that.
You the following function will do it:
def post_request(self, endpoint, data):
endpoint = 'localhost:9200/_bulk'
response = requests.post(endpoint, data=data, headers={'content-type':'application/json', 'charset':'UTF-8'})
return response
As data you need to pass a String such:
{ "index" : { "_index" : "test-index", "_type" : "_doc", "_id" : "1681", "routing" : 0 }}
{ "field1" : ... , ..., "fieldN" : ... }
{ "index" : { "_index" : "test-index", "_type" : "_doc", "_id" : "1684", "routing" : 1 }}
{ "field1" : ... , ..., "fieldN" : ... }
Make sure you add a "\n" at the end of each line.
I don't know much about Python, but did you look at Pyes?
Bulk is supported in Pyes.