I am unable to get ProtonCEP to create an event based on an absence rule.
The EPA "MissingQueueDataRule" is supposed to create an event "MissingQueueData" in the case that no events of type "QueueContextUpdate" (the entityID of the event is not important) are received in a past time interval (30 seconds).
There are no visible errors in the logs.
{
"epn": {
"events": [
{
"name": "Device",
"createdDate": "Thu Nov 12 2015",
"attributes": [
{
"name": "datacount5",
"type": "Integer",
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)"
}
]
},
{
"name": "Queue",
"createdDate": "Thu Nov 12 2015",
"attributes": [
{
"name": "name",
"type": "String",
"dimension": "0"
},
{
"name": "volume",
"type": "Integer",
"dimension": "0"
}
]
},
{
"name": "DeviceContextUpdate",
"createdDate": "Thu Nov 12 2015",
"attributes": [
{
"name": "datacount5m",
"type": "Integer",
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)"
},
{
"name": "entityId",
"type": "String",
"dimension": "0"
},
{
"name": "entityType",
"type": "String",
"dimension": "0"
},
{
"name": "lastupdate",
"type": "Date",
"dimension": "0"
},
{
"name": "activationdate",
"type": "Date",
"dimension": "0"
},
{
"name": "efficiencyratio",
"type": "Double",
"dimension": "0"
}
]
},
{
"name": "QueueContextUpdate",
"createdDate": "Thu Nov 12 2015",
"attributes": [
{
"name": "volume",
"type": "Integer",
"dimension": "0"
},
{
"name": "entityId",
"type": "String",
"dimension": "0"
},
{
"name": "entityType",
"type": "String",
"dimension": "0"
}
]
},
{
"name": "QueueVolumeHigh",
"createdDate": "Wed Jan 27 2016",
"attributes": [
{
"name": "Certainty",
"type": "Double",
"defaultValue": "1",
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)"
},
{
"name": "OccurrenceTime",
"type": "Date",
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters"
},
{
"name": "ExpirationTime",
"type": "Date",
"dimension": 0
},
{
"name": "Cost",
"type": "Double",
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity"
},
{
"name": "Duration",
"type": "Double",
"defaultValue": "0",
"dimension": 0,
"description": "Used in case the this event occur within an interval"
},
{
"name": "AffectedEntity",
"type": "String",
"dimension": "0"
},
{
"name": "AffectedEntityType",
"type": "String",
"dimension": "0"
},
{
"name": "EventType",
"type": "String",
"dimension": "0"
},
{
"name": "EventSeverity",
"type": "String",
"dimension": "0"
},
{
"name": "AffectedEntityVolume",
"type": "Integer",
"dimension": "0"
}
]
},
{
"name": "MissingQueueData",
"createdDate": "Wed Jan 27 2016",
"attributes": [
{
"name": "Certainty",
"type": "Double",
"defaultValue": "1",
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)"
},
{
"name": "OccurrenceTime",
"type": "Date",
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters"
},
{
"name": "ExpirationTime",
"type": "Date",
"dimension": 0
},
{
"name": "Cost",
"type": "Double",
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity"
},
{
"name": "Duration",
"type": "Double",
"defaultValue": "0",
"dimension": 0,
"description": "Used in case the this event occur within an interval"
},
{
"name": "EventSeverity",
"type": "String",
"defaultValue": "\"Warning\"",
"dimension": "0"
}
]
}
],
"epas": [
{
"name": "CriticalQueueVolumeRule",
"description": "Emit a QueueVolumeHigh with Severity=Critical if any Queue volume > 1000",
"createdDate": "Wed Jan 27 2016",
"createdBy": "Pedro",
"epaType": "All",
"context": "CriticalQueueVolumeComb",
"inputEvents": [
{
"name": "QueueContextUpdate",
"filterExpression": "QueueContextUpdate.volume>1000",
"consumptionPolicy": "Consume",
"instanceSelectionPolicy": "First"
}
],
"computedVariables": [],
"evaluationPolicy": "Immediate",
"cardinalityPolicy": "Single",
"internalSegmentation": [],
"derivedEvents": [
{
"name": "QueueVolumeHigh",
"reportParticipants": false,
"expressions": {
"OccurrenceTime": "QueueContextUpdate.DetectionTime",
"Duration": "0",
"AffectedEntity": "QueueContextUpdate.entityId",
"AffectedEntityType": "QueueContextUpdate.entityType",
"EventType": "\"QueueVolumeHigh\"",
"EventSeverity": "\"Critical\"",
"AffectedEntityVolume": "QueueContextUpdate.volume"
}
}
]
},
{
"name": "MissingQueueDataRule",
"description": "Detect when the scripts stop working and sending queue data",
"createdDate": "Wed Jan 27 2016",
"epaType": "Absence",
"context": "MissingQueueDataWindow",
"inputEvents": [
{
"name": "QueueContextUpdate",
"alias": "Q1",
"consumptionPolicy": "Consume",
"instanceSelectionPolicy": "First"
}
],
"computedVariables": [],
"evaluationPolicy": "Deferred",
"cardinalityPolicy": "Single",
"internalSegmentation": [],
"derivedEvents": [
{
"name": "MissingQueueData",
"reportParticipants": false,
"expressions": {
"Certainty": "1.0",
"Duration": "0",
"EventSeverity": "\"Warning\""
}
}
]
}
],
"contexts": {
"temporal": [
{
"name": "Always",
"createdDate": "Wed Jan 27 2016",
"type": "TemporalInterval",
"atStartup": true,
"neverEnding": true,
"initiators": [],
"terminators": []
},
{
"name": "CriticalQueueVolumeWindow",
"description": "Start when queue volume > 1000, ends in 30seconds",
"createdDate": "Wed Jan 27 2016",
"createdBy": "Pedro",
"type": "TemporalInterval",
"atStartup": false,
"neverEnding": false,
"initiators": [
{
"initiatorType": "Event",
"initiatorPolicy": "Ignore",
"name": "QueueContextUpdate",
"condition": "QueueContextUpdate.volume>1000"
}
],
"terminators": [
{
"terminatorType": "Event",
"terminatorPolicy": "First",
"terminationType": "Terminate",
"name": "QueueContextUpdate",
"condition": " QueueContextUpdate.volume<500"
},
{
"terminatorType": "RelativeTime",
"terminationType": "Terminate",
"relativeTime": "300000"
}
]
},
{
"name": "MissingQueueDataWindow",
"createdDate": "Wed Jan 27 2016",
"type": "TemporalInterval",
"atStartup": false,
"neverEnding": false,
"initiators": [
{
"initiatorType": "Event",
"initiatorPolicy": "Add",
"name": "QueueContextUpdate"
}
],
"terminators": [
{
"terminatorType": "RelativeTime",
"terminationType": "Terminate",
"relativeTime": "10000"
}
]
}
],
"segmentation": [
{
"name": "QueueID",
"description": "Treat objects as distinct based on entityID",
"createdDate": "Wed Jan 27 2016",
"createdBy": "Pedro",
"participantEvents": [
{
"name": "QueueContextUpdate",
"expression": "QueueContextUpdate.entityId"
},
{
"name": "QueueVolumeHigh",
"expression": "QueueVolumeHigh.AffectedEntity"
}
]
}
],
"composite": [
{
"name": "CriticalQueueVolumeComb",
"createdDate": "Wed Jan 27 2016",
"temporalContexts": [
{
"name": "CriticalQueueVolumeWindow"
}
],
"segmentationContexts": [
{
"name": "QueueID"
}
]
}
]
},
"consumers": [
{
"name": "DeviceReport",
"createdDate": "Thu Nov 12 2015",
"type": "File",
"properties": [
{
"name": "filename",
"value": "/usr/share/tomcat/webapps/sample/SentinelMonitor_DeviceReport.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "SendingDelay",
"value": "1000"
}
],
"events": [
{
"name": "Device"
}
]
},
{
"name": "QueueReport",
"createdDate": "Thu Nov 12 2015",
"type": "File",
"properties": [
{
"name": "filename",
"value": "/usr/share/tomcat/webapps/sample/SentinelMonitor_QueueReport.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "SendingDelay",
"value": "1000"
}
],
"events": [
{
"name": "Queue"
}
]
},
{
"name": "DeviceContextUpdateReport",
"createdDate": "Thu Nov 12 2015",
"type": "File",
"properties": [
{
"name": "filename",
"value": "/usr/share/tomcat/webapps/sample/SentinelMonitor_DeviceContextUpdateReport.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "SendingDelay",
"value": "1000"
}
],
"events": [
{
"name": "DeviceContextUpdate"
}
]
},
{
"name": "QueueContextUpdateReport",
"createdDate": "Thu Nov 12 2015",
"type": "File",
"properties": [
{
"name": "filename",
"value": "/usr/share/tomcat/webapps/sample/SentinelMonitor_QueueContextUpdateReport.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "SendingDelay",
"value": "1000"
}
],
"events": [
{
"name": "QueueContextUpdate"
},
{
"name": "QueueVolumeHigh"
},
{
"name": "MissingQueueData"
}
]
}
],
"producers": [],
"name": "SentinelMonitor"
}
}
The issue is that the initiator of the temporal context that your EPA is using is the QueueContextUpdate event that you are looking to find. Since this event doesn't arrive, the context is not initiated... and the EPA is not active at all...
For testing, I would suggest to change the initiator of the temporal context to At Startup and try to run again.
Later, you will need to decide what is the right definition of this temporal context, and what is the right initiator. Maybe you want to set this temporal context to be of Sliding Time Window type?
Related
I have a form with dependent fields that works fine, but now I'm trying to add a second dependent field, that will rely on my first dependent field:
{
"job_level": {
"type": "select",
"label": "Job Level",
"order": 8,
"state": "required",
"selection_values": [
{
"id": "",
"label": "* Job Level"
},
{
"id": "c_level",
"label": "C-Level"
},
{
"id": "architect",
"label": "Architect"
}
]
},
"job_function": {
"type": "select",
"label": "Job Function",
"order": 9,
"state": "required",
"dependent_field": {
"name": "job_level",
"values": [
"c_level",
"architect"
]
},
"selection_values": {
"c_level": [
{
"id": "",
"label": "* Job Function"
},
{
"id": "Security",
"label": "Security"
},
{
"id": "HR",
"label": "HR"
}
],
"architect": [
{
"id": "",
"label": "* Job Function"
},
{
"id": "Sales",
"label": "Sales"
}
]
}
},
"job_role": {
"type": "select",
"label": "Job Role",
"order": 10,
"state": "required",
"dependent_field": {
"name": "job_function",
"values": [
"Security",
"HR",
"Sales"
]
},
"selection_values": {
"Security": [
{
"id": "",
"label": "* Job Role"
},
{
"id": "CISO",
"label": "CISO"
},
{
"id": "CSO",
"label": "CSO"
},
{
"id": "Other",
"label": "Other"
}
],
"HR": [
{
"id": "",
"label": "* Job Role"
},
{
"id": "CHRO",
"label": "CHRO"
},
{
"id": "Other",
"label": "Other"
}
],
"Sales": [
{
"id": "",
"label": "* Job Role"
},
{
"id": "Operations_Sales",
"label": "Operations/Sales"
},
{
"id": "Other",
"label": "Other"
}
]
}
}
}
job_role is the field I'm trying to add, but when I'm selecting a Job Function in the form, the field is not appearing in the form. Any thoughts? Thanks.
How can we convert this schema to the below one:
{
"entityName": "Firm",
"attributes": [
{
"name": "FirmKey",
"rules": [
{
"type": "primaryKey",
"severity": "reject",
"operator": "",
"value": "1"
},
{
"type": "dataType",
"severity": "reject",
"operator": "",
"dataType": "int"
},
{
"type": "notNull",
"severity": "reject",
"operator": ""
}
]
},
{
"key": "attributedcfd6d27",
"name": "FirmName",
"unit": "",
"rules": [
{
"type": "dataType",
"severity": "reject",
"operator": "",
"dataType": "string"
}
],
}
}
converted:
{
"FirmKey":
{
"type": "list",
"schema":
{
"isint":true,
"isNull": NaN
}
},
"FirmName":
{
"type": "list",
"description": "Firm’s legal name",
"schema":
{
"type":"string",
"isNull": NaN
}
}
}
I have a JSON in the following format:
{
"subFields": [
{
"id": "question_1",
"type": "radioGroup",
"description": "Description1",
"title": "title1",
"subFields": [
{
"type": "radio",
"label": "Yes",
"value": 1
},
{
"type": "radio",
"label": "No",
"value": 0
},
{
"uiComponent": "SmallContent",
"componentProps": {
"text": "* If the answer to the above question is “Yes”, please contact the Support immediately."
}
}
]
},
{
"uiComponent": "Spacer"
},
{
"id": "question_2",
"type": "radioGroup",
"description": "Description2",
"title": "Title2",
"subFields": [
{
"type": "radio",
"label": "Label - Value 1",
"value": 1
},
{
"type": "radio",
"label": "Label - Value 2",
"value": 2
},
{
"type": "radio",
"label": "Label - Value 3",
"value": 3
},
{
"type": "radio",
"label": "Other",
"value": 13,
"subFields": [
{
"id": "question_2a",
"type": "string",
"condition": {
"type": "BinaryExpression",
"operator": "==",
"left": {
"type": "Identifier",
"name": "question_2"
},
"right": {
"type": "Literal",
"value": 13
}
}
}
]
}
]
},
{
"id": "question_2_b",
"style": {
"marginTop": "30px"
},
"type": "radioGroup",
"description": "Description3",
"title": "",
"subFields": [
{
"type": "radio",
"label": "Label - Radio 1",
"value": 1
},
{
"type": "radio",
"label": "Label - Radio 2",
"value": 2
},
{
"type": "radio",
"label": "Label - Radio 3",
"value": 3
}
]
},
{
"uiComponent": "Spacer"
},
{
"id": "question_3",
"type": "radioGroup",
"description": "Description3",
"title": "Title3",
"subFields": [
{
"type": "radio",
"label": "Yes",
"value": 1
},
{
"type": "radio",
"label": "No",
"value": 0
}
]
},
{
"uiComponent": "Spacer"
},
{
"condition": {
"type": "BinaryExpression",
"operator": "==",
"left": {
"type": "Identifier",
"name": "signer_type"
},
"right": {
"type": "Literal",
"value": "entity"
}
},
"subFields": [
{
"uiComponent": "Spacer"
},
{
"id": "question_4",
"type": "radioGroup",
"description": "Description_4",
"title": "Title_4",
"subFields": [
{
"type": "radio",
"label": "Yes",
"value": 1
},
{
"type": "radio",
"label": "No",
"value": 0
}
]
},
{
"uiComponent": "Spacer"
}
],
"uiComponent": "Block"
},
{
"uiComponent": "Spacer"
}
],
"uiComponent": "Container"
}
and I would like to generate the following output:
[
{
"id": "question_1",
"title": "title1",
"description": "Description1",
"type": "radioGroup",
"questions": "radio,Yes,1"
},
{
"id": "question_1",
"title": "title1",
"description": "Description1",
"type": "radioGroup",
"questions": "radio,No,0"
},
{
"id": "question_2",
"title": "Title2",
"description": "Description2",
"type": "radioGroup",
"questions": "radio,Label - Value 1,1"
},
{
"id": "question_2",
"title": "Title2",
"description": "Description2",
"type": "radioGroup",
"questions": "radio,Label - Value 2,2"
},
{
"id": "question_2",
"title": "Title2",
"description": "Description2",
"type": "radioGroup",
"questions": "radio,Label - Value 3,3"
},
{
"id": "question_2_b",
"title": "",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,Label - Value 1,1"
},
{
"id": "question_2_b",
"title": "",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,Label - Value 2,2"
},
{
"id": "question_2_b",
"title": "",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,Label - Value 3,3"
},
{
"id": "question_3",
"title": "Title3",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,Yes,1"
},
{
"id": "question_3",
"title": "Title3",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,No,0"
}
]
or in alternative a reduced version:
[
"question_1",
"title1",
"Description1",
"radioGroup",
"radio,Yes,1",
"radio,No,0"
],
[
"question_2",
"title2",
"Description2",
"radioGroup",
"radio,Label - Value 1,1",
"radio,Label - Value 2,2",
"radio,Label - Value 3,3",
],
[
"question_2_b",
"Description3",
"radioGroup",
"radio,Label - Value 1,1",
"radio,Label - Value 2,2",
"radio,Label - Value 3,3",
],
[
"question_3",
"Title3",
"Description3",
"radioGroup",
"radio,Yes,1",
"radio,No,0"
]
The objective is to get only the objects that contain the id (to remove the {"uiComponent": "Spacer"} objects) and get only the subFields with these tags inside the array:
"subFields": [
{
"type": "xxxx",
"label": "xxxx",
"value": xxxx
},
I was able to flatten the JSON array by using the following JQ pattern:
jq play 1
.subFields[] | select(has("id") and .id != null)| {id: .id, type: .type, description: .description, anwers: .subFields}
and generated this result:
{
"id": "question_1",
"type": "radioGroup",
"description": "Description1",
"anwers": [
{
"type": "radio",
"label": "Yes",
"value": 1
},
{
"type": "radio",
"label": "No",
"value": 0
},
{
"uiComponent": "SmallContent",
"componentProps": {
"text": "* If the answer to the above question is “Yes”, please contact the Support immediately."
}
}
]
}
{
"id": "question_2",
"type": "radioGroup",
"description": "Description2",
"anwers": [
{
"type": "radio",
"label": "Label - Value 1",
"value": 1
},
{
"type": "radio",
"label": "Label - Value 2",
"value": 2
},
{
"type": "radio",
"label": "Label - Value 3",
"value": 3
},
{
"type": "radio",
"label": "Other",
"value": 13,
"subFields": [
{
"id": "question_2a",
"type": "string",
"condition": {
"type": "BinaryExpression",
"operator": "==",
"left": {
"type": "Identifier",
"name": "question_2"
},
"right": {
"type": "Literal",
"value": 13
}
}
}
]
}
]
}
{
"id": "question_2_b",
"type": "radioGroup",
"description": "Description3",
"anwers": [
{
"type": "radio",
"label": "Label - Radio 1",
"value": 1
},
{
"type": "radio",
"label": "Label - Radio 2",
"value": 2
},
{
"type": "radio",
"label": "Label - Radio 3",
"value": 3
}
]
}
{
"id": "question_3",
"type": "radioGroup",
"description": "Description3",
"anwers": [
{
"type": "radio",
"label": "Yes",
"value": 1
},
{
"type": "radio",
"label": "No",
"value": 0
}
]
}
My problem is that I don't know how to remove these sections:
{
"uiComponent": "SmallContent",
"componentProps": {
"text": "* If the answer to the above question is “Yes”, please contact the Support immediately."
}
}
and
"subFields": [
{
"id": "question_2a",
"type": "string",
"condition": {
"type": "BinaryExpression",
"operator": "==",
"left": {
"type": "Identifier",
"name": "question_2"
},
"right": {
"type": "Literal",
"value": 13
}
}
}
]
I played a little bit arround with this jq for the question_3 only:
jq play 2
.subFields[] | {id: .id, title: .title, description: .description, type: .type, subFields: .subFields} | select(has("id") and .id != null) | select(.id=="question_3") | {id: .id, title: .title, description: .description, type: .type, questions: (.subFields[]|join(","))}
and produced this result:
{
"id": "question_3",
"title": "Title3",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,Yes,1"
}
{
"id": "question_3",
"title": "Title3",
"description": "Description3",
"type": "radioGroup",
"questions": "radio,No,0"
}
and also
jq play 3
.subFields[] | {id: .id, title: .title, description: .description, type: .type, subFields: .subFields} | select(has("id") and .id != null) | select(.id=="question_3") | [.id, .title, .description, .type, (.subFields[]|join(","))]
resulting on this:
[
"question_3",
"Title3",
"Description3",
"radioGroup",
"radio,Yes,1",
"radio,No,0"
]
Can you help me improve those JQ pattern I created to get the intended results?
Thanks in advance!
The following produces your first alternative:
.subFields[]
| select(.id?)
| { id, title, description, type} +
(.subFields[]
| select(.type?)
| [.type,.label,.value] | join(",")
| { questions: .} )
Notice the two select() filters.
The key names are specified explicitly here to ensure the ordering you specified is honored.
I have a json response like below. In the views array may or may not contain actions array.
In the reponse If any of view array contains actions object , then i have to validate that actions data with json schema(schema1.json)
And in the schema i mentioned the action propertes like(type,label,localizedlabel) as required ones.
But when I modify key or value type of this type,label,localizedlabel in the response does not output any errors.
Tested via( https://www.jsonschemavalidator.net/). what wrong with my schema?
How can i validate actions object only whenever it present inside any of view array?
schema1.json
{
"$id": "",
"type": "array",
"items": {
"$id": "/items",
"type": "object",
"properties": {
"name": {
"$id": "/items/properties/name",
"type": "string",
"title": "The Name Schema ",
"default": "",
"examples": [
"Preview"
]
},
"displayOrder": {
"$id": "/items/properties/displayOrder",
"type": "integer",
"title": "The Displayorder Schema ",
"default": 0,
"examples": [
1
]
},
"actions": {
"$id": "/items/properties/actions",
"type": "array",
"items": {
"$id": "/items/properties/actions/items",
"type": "object",
"properties": {
"type": {
"$id": "/items/properties/actions/items/properties/type",
"type": "string",
"title": "The Type Schema ",
"default": "",
"examples": [
"watch"
]
},
"label": {
"$id": "/items/properties/actions/items/properties/label",
"type": "string",
"title": "The Label Schema ",
"default": "",
"examples": [
"Watch"
]
},
"localizedLabel": {
"$id": "/items/properties/actions/items/properties/localizedLabel",
"type": "object",
"properties": {
"ENG": {
"$id": "/items/properties/actions/items/properties/localizedLabel/properties/ENG",
"type": "string",
"title": "The Eng Schema ",
"default": "",
"examples": [
"Watch"
]
},
"ESP": {
"$id": "/items/properties/actions/items/properties/localizedLabel/properties/ESP",
"type": "string",
"title": "The Esp Schema ",
"default": "",
"examples": [
"Ver"
]
}
}
}
},
"required": [
"type",
"label",
"localizedLabel"
]
}
},
"localizedName": {
"$id": "/items/properties/localizedName",
"type": "object",
"properties": {
"ENG": {
"$id": "/items/properties/localizedName/properties/ENG",
"type": "string",
"title": "The Eng Schema ",
"default": "",
"examples": [
"Preview"
]
},
"ESP": {
"$id": "/items/properties/localizedName/properties/ESP",
"type": "string",
"title": "The Esp Schema ",
"default": "",
"examples": [
"Adelanto"
]
}
}
}
},
"required": [
"actions"
]
}
}
response json
[{
"season": 2017,
"teamData": {
"awayTeam": {
"id": 6,
"city": "Dallas",
"name": "Mavericks",
"abbr": "DAL",
"color": "#0B51A1"
},
"homeTeam": {
"id": 8,
"city": "Detroit",
"name": "Pistons",
"abbr": "DET",
"color": "#990300"
}
},
"views": [{
"name": "Preview",
"displayOrder": 1,
"groups": [{
"type": "static",
"displayOrder": 1,
"tiles": [{
"context": "event",
"collection": "event",
"auditType": "pregame-preview",
"displayOrder": 1,
"_id": "5ac58ea21ee2112b33291f1c",
"eventId": 2018040608,
"dimensions": {
"width": 372,
"height": 375
},
"tileId": "36b154e719d7d8397da487cbc4e5f7d1",
"renderTime": "2018-04-05T02:49:05+00:00",
"dataTime": "2018-04-05T02:48:58+00:00",
"dataStamp": 1522896538,
"location": "http://test.com/2018040608/static/pre-event/pregame-preview/1522896538.png",
"tile_type": "static"
}
]
}
],
"actions": [{
"type": "watch",
"label": "Watch",
"localizedLabel": {
"ENG": "Watch",
"ESP": "Ver"
}
}, {
"type": "record",
"label": "Record",
"localizedLabel": {
"ENG": "Record",
"ESP": "Grabar"
}
}, {
"type": "tile_overlay",
"label": "Current Standings",
"tili": {
"context": "event",
"collection": "event",
"auditType": "full-standings",
"_id": "5ac6f9de2ccaf768d092c918",
"eventId": 2018040608,
"dimensions": {
"width": 1140,
"height": 660
},
"tileId": "852f92537e68dc99b54f1228459ec9ef",
"renderTime": "2018-04-06T04:38:54+00:00",
"dataTime": "2018-04-06T04:38:52+00:00",
"dataStamp": 1522989532,
"location": "http://test.com/2018040608/static/pre-event/full-standings/1522989532.png"
},
"localizedLabel": {
"ENG": "Current Standings",
"ESP": "Posición actual"
}
}, {
"type": "favorite",
"label": "Favorite",
"localizedLabel": {
"ENG": "Favorite",
"ESP": "Favorito"
}
}
],
"localizedName": {
"ENG": "Preview",
"ESP": "Adelanto"
}
}, {
"name": "Team Stats",
"displayOrder": 2,
"groups": [{
"type": "static",
"displayOrder": 1,
"tiles": [{
"context": "event",
"collection": "event",
"auditType": "pregame-team_stats",
"displayOrder": 1,
"_id": "5ac6755a4f82eb58a5eae6a6",
"eventId": 2018040608,
"dimensions": {
"width": 372,
"height": 510
},
"tileId": "1302dc16c9fe68c3e6edadd98afce2bc",
"renderTime": "2018-04-05T19:13:30+00:00",
"dataTime": "2018-04-05T19:13:28+00:00",
"dataStamp": 1522955608,
"location": "http://test.com/2018040608/static/pre-event/pregame-team_stats/1522955608.png",
"tile_type": "static"
}
]
}
],
"localizedName": {
"ENG": "Team Stats",
"ESP": "Estadísticas del equipo"
}
}, {
"name": "Leaders",
"displayOrder": 3,
"groups": [{
"type": "static",
"displayOrder": 1,
"tiles": [{
"context": "event",
"collection": "event",
"auditType": "pregame-leaders",
"displayOrder": 1,
"_id": "5ac26eb31ee2112b3328b00c",
"eventId": 2018040608,
"dimensions": {
"width": 372,
"height": 510
},
"tileId": "96abc24c47d61327426ef2b24281acbf",
"renderTime": "2018-04-02T17:55:57+00:00",
"dataTime": "2018-04-02T17:55:54+00:00",
"dataStamp": 1522691754,
"location": "http://test.com/2018040608/static/pre-event/pregame-leaders/1522691754.png",
"tile_type": "static"
}
]
}
],
"localizedName": {
"ENG": "Leaders",
"ESP": "Líderes"
}
}
]
}
]
There's nothing wrong with your schema. It should do what you need if used properly. Because it only describes the "views" part of the schema you would need to iterate through your response and pass just the "views" part of each item to the validator one at a time.
Or, you could add enough of the response structure to the schema to validate everything at once. Then you could just pass your whole response to the validator.
{
"type": "array",
"items": {
"type": "object",
"properties": {
"views": { "$ref": "schema1.json" }
}
}
}
using CEP i'm trying to make a basic example of communication between Proton and Orion.
I simply want Proton to receive a notification of temperature from Orion and send back a payload changing one boolean attribute if the temperature value is superior or equal to 20.
Here is the definition i'm using.
{
"epn":
{
"events":
[
{
"name": "TemperatureContextUpdate",
"attributes":
[
{
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)",
"name": "Certainty",
"defaultValue": "1",
"type": "Double"
},
{
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters",
"name": "OccurrenceTime",
"type": "Date"
},
{
"dimension": 0,
"name": "ExpirationTime",
"type": "Date"
},
{
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity",
"name": "Cost",
"type": "Double"
},
{
"dimension": 0,
"description": "Used in case the this event occur within an interval",
"name": "Duration",
"defaultValue": "0",
"type": "Double"
},
{
"dimension": "0",
"name": "entityId",
"type": "String"
},
{
"dimension": "0",
"name": "entityType",
"type": "String"
},
{
"dimension": "0",
"name": "temperature",
"type": "Integer"
},
{
"dimension": "0",
"name": "chaud",
"type": "Boolean"
}
],
"createdDate": "Wed Feb 22 2017"
},
{
"name": "Out_TemperatureContextUpdate",
"attributes":
[
{
"dimension": 0,
"description": "The certainty that this event happen (value between 0 to 1)",
"name": "Certainty",
"defaultValue": "1",
"type": "Double"
},
{
"dimension": 0,
"description": "No value means it equals the event detection time, other option is to use one of the defined distribution functions with parameters",
"name": "OccurrenceTime",
"type": "Date"
},
{
"dimension": 0,
"name": "ExpirationTime",
"type": "Date"
},
{
"dimension": 0,
"description": "The cost of this event occurrence. Negative if this is an opportunity",
"name": "Cost",
"type": "Double"
},
{
"dimension": 0,
"description": "Used in case the this event occur within an interval",
"name": "Duration",
"defaultValue": "0",
"type": "Double"
},
{
"dimension": "0",
"name": "entityId",
"type": "String"
},
{
"dimension": "0",
"name": "entityType",
"type": "String"
},
{
"dimension": "0",
"name": "temperature",
"type": "Integer"
},
{
"dimension": "0",
"name": "chaud",
"type": "Boolean"
}
],
"createdDate": "Wed Feb 22 2017"
}
],
"name": "TemperatureDemo",
"consumers":
[
{
"events":
[
{
"name": "Out_TemperatureContextUpdate"
}
],
"name": "Consumer_Rest",
"properties":
[
{
"name": "URL",
"value": "http://172.17.0.3:1026/v2/entities"
},
{
"name": "contentType",
"value": "application/json"
},
{
"name": "formatter",
"value": "json_ngsi"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
},
{
"name": "dateFormat",
"value": "dd/MM/yyyy-HH:mm:ss"
}
],
"type": "Rest",
"createdDate": "Wed Feb 22 2017"
},
{
"events":
[
{
"name": "TemperatureContextUpdate"
}
],
"name": "Consumer_File",
"properties":
[
{
"name": "filename",
"value": "/home/work/Documents/test.txt"
},
{
"name": "formatter",
"value": "json"
},
{
"name": "delimiter",
"value": ";"
},
{
"name": "tagDataSeparator",
"value": "="
}
],
"type": "File",
"createdDate": "Wed Feb 22 2017"
}
],
"epas":
[
{
"inputEvents":
[
{
"instanceSelectionPolicy": "First",
"alias": "TemperatureContextUpdate",
"filterExpression": "TemperatureContextUpdate.temperature>=20",
"name": "TemperatureContextUpdate",
"consumptionPolicy": "Consume"
}
],
"derivedEvents":
[
{
"name": "Out_TemperatureContextUpdate",
"reportParticipants": false,
"expressions":
{
"Cost": "TemperatureContextUpdate.Cost",
"Certainty": "TemperatureContextUpdate.Certainty",
"OccurrenceTime": "TemperatureContextUpdate.OccurrenceTime",
"Duration": "TemperatureContextUpdate.Duration",
"entityId": "TemperatureContextUpdate.entityId",
"ExpirationTime": "TemperatureContextUpdate.ExpirationTime",
"chaud": "true",
"entityType": "TemperatureContextUpdate.entityType",
"temperature": "TemperatureContextUpdate.temperature"
}
}
],
"evaluationPolicy": "Immediate",
"name": "EPA_Change",
"internalSegmentation":
[
],
"context": "always",
"epaType": "Basic",
"cardinalityPolicy": "Single",
"localPlacement": true,
"createdDate": "Wed Feb 22 2017",
"computedVariables":
[
]
}
],
"optimization":
{
},
"contexts":
{
"temporal":
[
{
"terminators":
[
],
"neverEnding": true,
"atStartup": true,
"name": "always",
"type": "TemporalInterval",
"createdDate": "Wed Feb 22 2017",
"initiators":
[
]
}
],
"segmentation":
[
],
"composite":
[
]
},
"producers":
[
]
}
}
I try to create a file while first update is receive but this file is always empty, btw it is correctly create in my directory and change everytime I change definition. The rest payload is never send like the condition is never triggered.
The payload I send :
{
"subscriptionId": "51c04a21d714fb3b37d7d5a7",
"data":
[ {
"id": "temp1",
"type": "Temperature",
"temperature": {
"type":"integer",
"value": 28,
"metadata":{}
},
"chaud": {
"type":"boolean",
"value": false,
"metadata":{}
},
"Certainty": {
"value": "1",
"type": "Float"
},
"Cost": {
"value": "0",
"type": "Float"
},
"Name": {
"value": "",
"type": "String"
},
"EventSource": {
"value": "",
"type": "String"
},
"Duration": {
"value": "0",
"type": "Float"
}
}
]
}
The log catalina.out :
INFOS: started event message body reader
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader parseVTwoFormat
INFOS: Event: TemperatureContextUpdate
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom
INFOS: finished event message body reader
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.providers.EventJSONNgsiMessageReader readFrom
INFOS: EventJSONNgsiMessageReader: read event TemperatureContextUpdate; entityId=temp1; EventId=ba868559-7589-4720-ab75-658b920a3f14; chaud=false; entityType=Temperature; Chronon=null; temperature=28; DetectionTime=1487845415319; Name=; Certainty=1; Cost=0; EventSource=; OccurrenceTime=null; Duration=0; Annotation=; ExpirationTime=null; from broker...
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFOS: starting submitNewEvent
févr. 23, 2017 11:23:35 AM com.ibm.hrl.proton.webapp.resources.EventResource submitNewEvent
INFOS: events sent to proton runtime...
So any idea where is my problem ?
Thanks.
your mistake is that you send an event with an empty name.
I am sorry the same information is duplicated in the input, however this steams from the integration between Proton and Orion, each of which requires the information in different form and the difference was not patched smoothly.
The input you should send should contain the input event name, like this :
{
"subscriptionId": "51c04a21d714fb3b37d7d5a7",
"data":
[ {
"id": "temp1",
"type": "Temperature",
"temperature": {
"type":"integer",
"value": "28",
"metadata":{}
},
"chaud": {
"type":"boolean",
"value": false,
"metadata":{}
},
"Certainty": {
"value": "1",
"type": "Float"
},
"Cost": {
"value": "0",
"type": "Float"
},
"Name": {
"value": "TemperatureContextUpdate",
"type": "String"
},
"EventSource": {
"value": "",
"type": "String"
},
"Duration": {
"value": "0",
"type": "Float"
}
}
]
}
Note that the name attribute now has value "TemperatureContextUpdate"