Uploaded image for project: 'Help-Coaches-Desk'
  1. Help-Coaches-Desk
  2. HELC-710

FIWARE.Request.Coach.CreatiFI.General Support #246: A couple of bugs in the POI Data Provider GE

    Details

    • Type: extRequest
    • Status: Closed
    • Priority: Major
    • Resolution: Done
    • Component/s: CreatiFI
    • Labels:
      None

      Description

      Hi,

      A user found (and fixed) some bugs on the POI Data Provider GE.
      Here it is his report:

      "
      Hi.

      We are using a custom data field in our POI data. Based on the POI Data Provider documentation it should support adding custom fields to the data in addition to the "fw_core" field. However the POI Data Provider would not accept JSON data that had other than the predefined "fw_xxx" fields.

      The code in add_poi.php gets a list of supported components by calling get_supported_components() from db.php which has a hardcoded list of supported component names.

      We have fixed that by modifying the PHP code in our own instance ourselves. The change was made to db.php as follows:

      function get_supported_components()
      {
      // Markus Kauppinen: Added "mipsoft_landmarker"
      $components = array("fw_core", "fw_contact", "fw_xml3d", "fw_media",
      "fw_time", "fw_sensor", "fw_marker", "fw_relationships",
      "mipsoft_landmarker");

      return $components;
      }
      Also handling the timestamps when updating data could be better documented. It's quite confusing. It's not instantly clear should we include a new timestamp in the JSON data that we send via HTTP POST or will the receiving PHP code assign a new one.

      We now know that the PHP code inserts a new timestamp to the fw_core data. But it does not insert it to the custom data. However when updating it checks both timestamps (in update_poi.php) and if they do not match then that (custom) data is not updated. The PHP code even doesn't allow a zero timestamp value so it must a valid value.

      So it doesn't set the custom data timestamp but still expects a valid one when updating data. This is a clear error. It should either set the custom data timestamp or allow a zero timestamp when updating the data. We have now ourselves modified the PHP code to insert the custom data timestamp as well in add_poi.php as follows:

      $mongodb = connectMongoDB($db_opts['mongo_db_name']);
      foreach($request_array as $comp_name => $comp_data)
      {
      if ($comp_name == 'fw_core')
      continue;
      if (in_array($comp_name, $supported_components))

      { $comp_data["_id"] = $uuid; // Markus Kauppinen: $comp_data["last_update"]["timestamp"] = $timestamp; $collection = $mongodb->$comp_name; $collection->insert($comp_data); }

      }

      "

      Thanks in advance.

      (Reported by xavier.carol@i2cat.net)

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              leandroguillen Leandro Guillén
              Reporter:
              leandroguillen Leandro Guillén
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: