Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/insert ngsi datetime as epoch millis #2341

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@

- [cygnus-common] [Arcgis] All NGSI DateTime are translated to Millis from Epoch (esriFieldTypeDate) (#2339)
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ private void addProperty(JsonObject jsonObj, String name, Object property) {
jsonObj.addProperty(name, (Boolean) property);
break;
case DATE_CLASSNAME:
simpleDateFormat = new SimpleDateFormat(DATE_PATTERN);
jsonObj.addProperty(name, simpleDateFormat.format((Date) property));
// All NGSI DateTime are translated to Millis from Epoch (esriFieldTypeDate)
Date date = (Date) property;
jsonObj.addProperty(name, date.getTime());
break;
case GREGORIAN_CALENDAR_CLASSNAME:
simpleDateFormat = new SimpleDateFormat(DATE_PATTERN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Let's see both configuration options:

###### Entity data in CB:

service = vehicles
service-path = /4wheels
entity-type = Car
service = vehicles
service-path = /4wheels
entity-type = Car

If the Feature table for type "Car" is `https://arcgis.com/{hash}/arcgis/rest/services/vehicles/cars`, the subscription with custom notif would be:

Expand Down Expand Up @@ -115,22 +115,22 @@ Note that to avoid using the name mappings to modify the unique field value of `

###### result

Feature table url: https://arcgis.com/{hash}/arcgis/rest/services/vehicles/cars
Table's unique field: licensePlate
Feature table url: https://arcgis.com/{hash}/arcgis/rest/services/vehicles/cars
Table's unique field: licensePlate

[Top](#top)

##### Using Cygnus name mappings

###### Agent.conf file:

agent.arcgis-sink.arcgis_service_url = https://arcgis.com/{hash}/arcgis/rest/services
agent.arcgis-sink.enable_name_mappings = true
agent.arcgis-sink.arcgis_service_url = https://arcgis.com/{hash}/arcgis/rest/services
agent.arcgis-sink.enable_name_mappings = true
###### Entity data:

service = vehicles
service-path = /4wheels
entity-type = Car
service = vehicles
service-path = /4wheels
entity-type = Car

The name mappings configuration would be:

Expand All @@ -156,8 +156,8 @@ The name mappings configuration would be:

###### result

Feature table url: https://arcgis.com/{hash}/arcgis/rest/services/vehicles/cars
Table's unique field: licensePlate
Feature table url: https://arcgis.com/{hash}/arcgis/rest/services/vehicles/cars
Table's unique field: licensePlate

[Top](#top)

Expand Down Expand Up @@ -297,7 +297,7 @@ Note that `speed` attribute is not required in the name mappings file as it matc
From https://doc.arcgis.com/en/data-pipelines/latest/process/output-feature-layer.htm
> ... Date fields are stored in feature layers using the format milliseconds from epoch and the coordinated universal time (UTC) time zone. The values will be displayed differently depending on where you are viewing the data. For example, querying the feature service REST end point will return values in milliseconds from epoch, such as 1667411518878....

So, to persist a `esriFieldTypeDate` field in the Feature Layer, cygnus has to receive an attribute "Number" from the CB with the milliseconds from epoch.
So, all NGSI DateTime are persisted like a `esriFieldTypeDate` field in the Feature Layer, because arcgis sink transform NGSI DateTime into the milliseconds from epoch.

## <a name="section3"></a>Programmers guide
### <a name="section3.1"></a>`NGSIArcgisFeatureTableSink` class
Expand Down
Loading