コード例 #1
0
     $curr_timestamp_query = "SELECT timestamp FROM {$fw_core_tbl} WHERE uuid='" . $uuid . "'";
     $curr_timestamp_result = pg_query($curr_timestamp_query);
     if (!$curr_timestamp_result) {
         header("HTTP/1.0 500 Internal Server Error");
         $error = pg_last_error();
         die($error);
     }
     $row = pg_fetch_row($curr_timestamp_result);
     $curr_timestamp = $row[0];
     if ($curr_timestamp != NULL) {
         if ($curr_timestamp != $update_timestamp) {
             header("HTTP/1.0 400 Bad Request");
             die("The given last_update:timestamp (" . $update_timestamp . ") does not match the value in the database (" . $curr_timestamp . ") in fw_core!");
         }
     }
     update_fw_core($db_opts, $pgcon, $uuid, $fw_core, $fw_core_tbl, $new_timestamp, $user_id);
 }
 $supported_components = get_supported_components();
 //Update other components to MongoDB...
 $mongodb = connectMongoDB($db_opts['mongo_db_name']);
 foreach ($poi_data as $comp_name => $comp_data) {
     //Skip fw_core as it has been allready processed...
     if ($comp_name == "fw_core") {
         continue;
     }
     //Process update for fw_relationships.
     //Each relationship object is stored as a single document in MongoDB,
     //identified by MongoDB's internal identifier (ObjectID).
     if ($comp_name == "fw_relationships") {
         foreach ($comp_data as $relationship) {
             //Relationships are identified by the pair (subject, predicate)
コード例 #2
0
     // Update dynamic data in the POI data
     $comps_to_update = array_merge($comps_to_update, array_keys($dyn_data));
 }
 // end if data expired
 foreach ($comps_to_update as $comp_name) {
     if (in_array($comp_name, $dyn_comp_names) || $comp_name == 'fw_dynamic') {
         if ($comp_name == "fw_core") {
             // fw_core has changed
             // However, don't update, if the place is lost
             if (isset($dyn_data['fw_core']['location'])) {
                 $location = $dyn_data['fw_core']['location'];
                 if (isset($location['wgs84'])) {
                     $lat = $location['wgs84']['latitude'];
                     $lon = $location['wgs84']['longitude'];
                     if (isset($lat) && isset($lon) && $lat != 0 && $lon != 0) {
                         update_fw_core($db_opts, $pgcon, $uuid, $data[$uuid]['fw_core'], $fw_core_tbl, $new_timestamp);
                     }
                 }
             }
         } else {
             if ($comp_name == "fw_relationships") {
                 // do nothing
             } else {
                 if (in_array($comp_name, $supported_components)) {
                     $collection = $mongodb->{$comp_name};
                     $comp_data = $data[$uuid][$comp_name];
                     $comp_data['last_update']['timestamp'] = $new_timestamp;
                     $data[$uuid][$comp_name]['last_update']['timestamp'] = $new_timestamp;
                     $comp_data["_id"] = $uuid;
                     $upd_criteria = array("_id" => $uuid);
                     try {