How to add TimeInstant, CreationDate and ModifiedDate into CrateDB with Orion Context Broker? - fiware

I'm setting up a Firmware-Framework, where I unforutunately have to add historically Sensor Values. But I also need the creationDate and the modificationDate for other usecases.
Therefore I add the Attribute "Metadata" with the variable "TimeInstant". Then I create an Entity, create an Orion-Subscription for that Entity and update the Entity with my old Sensor-Valses.
The Json-File I send to the Orion-Context Broker to update the Attribute looks like this:
{
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2015-02-02T11:35:25.0000Z"
}
},
"type": "Number",
"value": 0.0132361 }
The Output in my Mongo-DB like this:
"_id": {
"id": "urn:ngsi-ld:SensorB-K1200____",
"type": "Sensor",
"servicePath": "/test/servicepath"
},
"attrNames": [
"Sensor_value"
],
"attrs": {
"Sensor_value": {
"value": 0.01632361,
"type": "Number",
"md": {
"TimeInstant": {
"type": "DateTime",
"value": 1422876989
}
},
"mdNames": [
"TimeInstant"
],
"creDate": 1568712813,
"modDate": 1568735930
}
},
"creDate": 1568712813,
"modDate": 1568735930,
"lastCorrelator": "0a129232-d964-11e9-8e5a-0242ac130009" }
But my Crate-DB only has the columns:
entity_id entity_type fiware_servicepath sensor_value time_index
My Subscription File looks like this:
{
"expires": "2019-12-24T18:00:00",
"notification": {
"http": {
"url": "http://quantumleap:8668/v2/notify"
},
"metadata": [
"dateCreated",
"dateModified",
"TimeInstant"
]
},
"subject": {
"entities": [
{
"id": "urn:ngsi-ld:SensorB-K1200____",
"type": "Sensor"
}
]
},
"throttling": 0 }
I've tried changing the "Metadata" Attributes in the Subscription-File, also tried restartig Crate-DB, ContextBroker e.g..
I excpect the CrateDb to show all three values: "dateCreated", "dateModified" and "TimeInstant".

Did you check what's the message notification actually sent by Orion to QuantumLeap?
As regards the payload I would try as follow:
{
"TimeInstant": {
"type": "DateTime",
"value": "2015-02-02T11:35:25.0000Z"
},
"type": "Number",
"value": 0.0132361
}
Internally we usually use as attribute name for this type of scenario dateObserved, but it would not make any difference w.r.t. TimeInstant.
I am not actually sure you can attach metadata to the root of NGSI message, I believe they are supposed to be attached only to attributes.
Anyhow, QuantumLeaps does not support NGSI metadata (i.e. metadata attached to NGSI attributes). Still it support time indexing based on them.
The way Quantum Leap handles TimeInstant metadata and other time metadata is via time_index. See documentation here: https://quantumleap.readthedocs.io/en/latest/user/#time-index

Related

How to operate with json list in CMake?

I have the following code which I'm trying to read in CMake.
{
"demo": [
{
"name": "foo0",
"url": "url1",
"verify_ssl": true
},
{
"name": "foo1",
"url": "url1",
"verify_ssl": true
},
{
"name": "foo2",
"url": "url2",
"verify_ssl": true
}
]
}
I'm trying to access a member from the list above, for example demo[0].name without success, what I'm doing wrong?
file(READ "${CONAN_CACHE}/demo.json" MY_JSON_STRING)
string(JSON CUR_NAME GET ${MY_JSON_STRING} demo[0].name)
One at a time.
string(JSON CUR_NAME GET ${MY_JSON_STRING} demo 0 name)

IF statement in Couchbase Map of view - I'm sure I'm missing something simple

I'm trying to limit the map in my view to a specific set of documents by either having the id "startsWith" a string or based on there being a specific node in the JSON> I can't seem to get a result set once I add an IF statement. The reduce is a simple _count:
function(doc, meta) {
if (doc.metricType == "Limit_Exceeded") {
emit([doc.ownedByCustomerNumber, doc.componentProduct.category], meta.id);
}
}
I've also tried if (doc.metricType) and also if(meta.id.startsWith("Turnaway:")
Example Doc:
{
"OvidUserId": 26105400,
"id": "Turnaway:00005792:10562440",
"ipAddress": "111187081038",
"journalTurnawayNumber": 10562440,
"metricType": "Limit_Exceeded",
"oaCode": "OA_Gold",
"orderNumber": 683980,
"ovidGroupID": 3113900,
"ovidGroupName": "tnu999",
"ovidUserName": "tnu999",
"ownedByCustomerNumber": 59310,
"platform": "Lippincott",
"samlString": "",
"serialName": "00005792",
"sessionID": "857616ee-dab7-43d0-a08b-abb2482297dd",
"soldProduct": {
"category": "Multidisciplinary Subjects",
"name": "Custom Collection For CALIS - LWW TA 2020",
"productCode": "CCFCCSI20",
"productNumber": 33410,
"subCategory": "",
"subject": "Multidisciplinary Subjects"
},
"soldToCustomer": {
"customerNumber": 59310,
"keyAccount": false,
"name": "Tongji University"
},
"turnawayDateTime": "2022-05-04T03:01:44.600",
"usedByCustomer": {
"customerNumber": 59310,
"keyAccount": false,
"name": "Tongji University"
},
"usedByCustomerNumber": 59310,
"yearMonth": "202205"
},
"id": "Turnaway:00005792:10562440"
}
Thanks,
Gerry
Found it (of course after posting the question) The second component of the Key in the emit has to exist. I entered doc.componentProduct.category instead of doc.soldProduct.Category.

How to POST a record with fk data in Strapi?

I have a problem when I try to POST a new record.
I have a legacy app that I'm consuming with Strapi, so I didn't let Strapi create the tables, it just only use what is on the DDBB.
This one of the collection type: (enfermedadrepeticion) (go to repeticion_id)
{
"kind": "collectionType",
"connection": "atdbconnection",
"collectionName": "enfermedadrepeticion",
"info": {
"name": "RepeticionEnfermedad"
},
"options": {
"increments": false,
"timestamps": false
},
"attributes": {
"valor": {
"type": "decimal"
},
"enfermedad_id": {
"type": "integer"
},
"valor_1": {
"type": "string"
},
"valor_2": {
"type": "string"
},
"fechaTomaDato": {
"type": "string"
},
"repeticion_id": {
"via": "repeticion_enfermedads",
"model": "repeticion"
}
}
}
this is the model "repeticion" ... go to repeticion_enfermedads...
{
"kind": "collectionType",
"connection": "atdbconnection",
"collectionName": "repeticiones",
"info": {
"name": "Repeticion"
},
"options": {
"increments": false,
"timestamps": false
},
"attributes": {
"activa": {
"type": "boolean"
},
"altura": {
"type": "string"
},
"linea_id": {
"model": "linea"
},
"ensayo_id": {
"type": "integer"
},
"esp": {
"type": "string"
},
... bunch of fields ...
"repeticion_enfermedads": {
"collection": "repeticion-enfermedad",
"via": "repeticion_id"
}
}
}
My relation is: One Repeticion have 0 or N repeticion-enfermedad, via repeticion_id field.
Using this relation, when I fetch data from "Repeticion" I get one or more "Repeticion-Enfermedad".
So, when I need to update una entry in "Repeticion-Enfermedad" I PUT the data with this body :
body {
enfermedad_id: 1,
fechaTomaDato: '2021-05-05 03:29:29',
fechaUltCambio: '2021-05-05 03:29:29',
repeticion_id: { id: 392571 },
valor: 60,
valor_1: '60',
valor_2: 'S'
}
and everything works fine!!
But when I try to create a record using POST, with the same body, I get a 500 error.
error Error: ER_NO_DEFAULT_FOR_FIELD: Field 'repeticion_id' doesn't have a default value
I try to send the body using Swagger, and I get the same error.
I try, sending "repeticion_id" field, using integer, string, object, etc, but I cant't make it work...
My Strapi version is 3.0.6
I really don't want to alter the model definition, it's working fine...
Any suggestion ??
Best Regards
OK, I found the problem.
There is nothing to do with Strapi, I have to add NOT NULL to the field in RepeticionEnfermedad table.
It looks like Strapi first tries to create a record in that table, and then updates the recently added record...
I leave my answer in case someone got the same problem.
Chiao!

property servicetoken cannot be empty

"certificatefordns":{
"Type" : "AWS::CertificateManager::Certificate",
"Properties" : {
"DomainName" : "*.test-elb.acb.com",
"ValidationMethod" : "DNS"
},
"CertificateDNSRecord":{
"Type": "Custom::CertificateDNSRecord",
"Properties": {
"CertificateArn": {
"Ref": "certificatefordns"
},
"DomainName": "*.test-elb.acb.com"
}},
"DNS": {
"Type": "AWS::Route53::RecordSetGroup",
"Properties": {
"HostedZoneId": "Z01724793QXGY7AZ",
"RecordSets": [
{
"Name": {
"Ref": "AlternateDomainNames"
},
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z23TAZ6MNIO",
"DNSName": {
"Fn::GetAtt": [
"WebLoadBalancer",
"DNSName"
]
}
}
},
{
"Name": {
"Fn::Sub": "${CertificateDNSRecord.Name}"
},
"Type": {
"Fn::Sub": "${CertificateDNSRecord.Type}"
},
"TTL": "60",
"Weight": 1,
"SetIdentifier": "*.test-elb.acb.com",
"ResourceRecords": [
{
"Fn::Sub": "${CertificateDNSRecord.Value}"
}
]
}
]
}
}
Hi Team,
I want to create a new certificate for Load balancer and with the help of this json code I am able to create that certificate but after some time it will through an error that property servicetoken cannot be empty So As i searched I am confused that I need to create lambda function or what?
Or Is there any other way to decline this error.
Please guide me into this.
Custom resources in CloudFormation require a ServiceToken:
The service token that was given to the template developer by the service provider to access the service, such as an Amazon SNS topic ARN or Lambda function ARN. The service token must be from the same region in which you are creating the stack.
Your Custom::CertificateDNSRecord is missing it. Thus you have to provide it.
If the custom resource is for validating ACM certifications, you can check the new option, which should not require custom lambda function:
AWS Certificate Manager Extends Automation of Certificate Issuance Via CloudFormation
Yes I got the solution own my own. We just need to use this template that's it.
"certificatefordns":{
"Type" : "AWS::CertificateManager::Certificate",
"Properties" : {
"DomainName" : "*.test-elb.acb.com",
"ValidationMethod" : "DNS",
"DomainValidationOptions": [
{
"DomainName": {
"Ref": "AlternateDomainNames"
},
"HostedZoneId": "Z01724793QXGL8FOZ"
}]
}
},
It will create a new certificate.

Fiware: NGSI v2 susbcription: getting notified only about the attribute that has changed

I have this subscription:
{
"id": "5a27abba56256c402cec5654",
"description": "my subscription",
"status": "active",
"subject": {
"entities": [
{
"idPattern": ".*"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"timesSent": 56939,
"lastNotification": "2018-01-29T09:06:45.00Z",
"attrs": [],
"attrsFormat": "normalized",
"http": {
"url": "http://notif_url"
},
"lastFailure": "2018-01-24T15:10:08.00Z",
"lastSuccess": "2018-01-29T09:06:45.00Z"
}
}
Using it I can get notified about new entities whithout specifiying a particular entity ID.
The problem is that when one entity attribute changes I get notified about all attributes.
Is it possible to get notified only about the attribute that has changed and keeping in the same time the possibility to discover new entities?
Something like in if attribut x changed in the condition part, get notified about it:
"condition": {
"attrs": [attribute_X]
}
"notification": {
"attrs": [attribute_X]
}
Thanks!
It works the way you mention. I mean, using:
"condition": {
"attrs": [ "attribute_X" ]
}
...
"notification": {
"attrs": [ "attribute_X" ]
}
Whenever attribute named attribute_X changes (or appears first time, typically at entity creation time) you will receive a notification including only attribute_X