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

Arcgis sink. Should quote unique id when is a esriFieldTypeString #2311

Closed
danielvillalbamota opened this issue Oct 9, 2023 · 1 comment
Closed

Comments

@danielvillalbamota
Copy link
Collaborator

danielvillalbamota commented Oct 9, 2023

Context

Using the sink of Arcgis I am getting the following error:

time=2023-10-05T10:37:21.532Z | lvl=DEBUG | corr=-e329-4c7e-9c2a; cbnotif=1 | trans=-8b19-495a-ba5c-| srv=N/A | subsrv=N/A | comp=cygnus-ngsi | op=requestHTTP | msg=com.telefonica.iot.cygnus.backends.arcgis.restutils.RestApi[179] : requesting HTTP: https://<arcgis_url>/FeatureServer/0/query?outSR=%7B%22wkid%22%3A4326%7D&outFields=*&resultOffset=0&where=id+IN+%28ENT-NLO-001%29&token=<token>&f=json
time=2023-10-05T10:37:21.610Z | lvl=DEBUG | corr=-e329-4c7e-9c2a; cbnotif=1 | trans=-8b19-495a-ba5c-| srv=N/A | subsrv=N/A | comp=cygnus-ngsi | op=requestHTTP | msg=com.telefonica.iot.cygnus.backends.arcgis.restutils.RestApi[261] : Disposing connection objects
time=2023-10-05T10:37:21.610Z | lvl=DEBUG | corr=-e329-4c7e-9c2a; cbnotif=1 | trans=-8b19-495a-ba5c-| srv=N/A | subsrv=N/A | comp=cygnus-ngsi | op=getFeatureList | msg=com.telefonica.iot.cygnus.backends.arcgis.restutils.RestFeatureTable[216] : Response code: 200
        {"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to perform query operation."]}}
time=2023-10-05T10:37:21.611Z | lvl=DEBUG | corr=-e329-4c7e-9c2a; cbnotif=1 | trans=-8b19-495a-ba5c-| srv=N/A | subsrv=N/A | comp=cygnus-ngsi | op=checkHttpResponse | msg=com.telefonica.iot.cygnus.backends.arcgis.restutils.RestApi[372] : Response has erros, 400 Response Error 400  Unable to complete operation.
Unable to perform query operation.
time=2023-10-05T10:37:21.611Z | lvl=ERROR | corr=-e329-4c7e-9c2a; cbnotif=1 | trans=-8b19-495a-ba5c-| srv=N/A | subsrv=N/A | comp=cygnus-ngsi | op=checkResponse | msg=com.telefonica.iot.cygnus.backends.arcgis.restutils.RestFeatureTable[235] : Error: 400
Response Error 400  Unable to complete operation.
Unable to perform query operation.

The subscription is configured to assign the value "id" to the type attribute:

{
  "url": "http://<cygnus_arcgis_source>/notify",
  "ngsi": {
    "type": "id"
  },
  "headers": {
    "fiware-service": "<arcgis_base_path>",
    "fiware-servicepath": "<arcgis_url_path>/FeatureServer/0"
  }
}

Problem

The following query https://<arcgis_url>/FeatureServer/0/query?outSR=%7B%22wkid%22%3A4326%7D&outFields=*&resultOffset=0&where=id+IN+%28ENT-NLO-001%29&token=<token>&f=json requires to wrap ENT-NLO-001 with single quotes ' to get the expected answer as "id" is defined as esriFieldTypeString in the FeatureLayer. When I perform that query I get the right answer.

So I guess there is some problem checking the uniqueFieldType or the uniqueField in the following block:

if (hasAttribute(uniqueField)) {
String uniqueFieldType = getAttributeType(uniqueField);
quoted = GisAttributeType.DATE.equals(uniqueFieldType)
|| GisAttributeType.STRING.equals(uniqueFieldType);
// Make the list
for (Feature feature : featureArray) {
if (feature.getAttributes().containsKey(uniqueField)) {
String value = feature.getAttributes().get(uniqueField).toString();
if (quoted) {
value = "'" + value + "'";
}
result.append(separator + value);
separator = ",";
}
}

Expected behavior

It should perform the query as:

https://<arcgis_url>/FeatureServer/0/query?outSR=%7B%22wkid%22%3A4326%7D&outFields=*&resultOffset=0&where=id+IN+%28%27ENT-NLO-001%27%29&token=<token>&f=json
@danielvillalbamota
Copy link
Collaborator Author

The fix in #2312 works. I close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant