Currently, existing terms can only be replaced. Implement true updating functionality that first loads a term and then updates it.

Comments

alex_b’s picture

StatusFileSize
new3.91 KB

Requires: #853194-1: Mapping: don't reset all targets.

This patch introduces a real "update existing" option: http://skitch.com/alexbarth/dcmfc/edit-importer-term-importer-feeds-test...

When selected "update existing" it actually loads the term from the database before updating it.

HOWEVER:

Given that the taxonomy module does not support *any* load hooks the only thing that gets loaded before updating is the 'name' and the 'description' field of a taxonomy term :P

What does this mean for modules like geotaxonomy that add data to taxonomy terms?

This patch invokes a hook_feeds_taxonomy_load() to make up for taxonomy's deficiencies. An implementation for e. g. geotaxonomy looks like this:

/**
 * Implementation of hook_feeds_taxonomy_load().
 */
function geotaxonomy_feeds_taxonomy_load($term) {
  if ($geo = geotaxonomy_get_term($tid)) {
    $term = array_merge($term, $geo);
  }
  return $term;
}
alex_b’s picture

Status: Active » Needs work
Issue tags: +Needs tests
alex_b’s picture

TKS’s picture

StatusFileSize
new7.68 KB

alex_b:

Some progress, but not quite there -- at least in my testing.

First off, the patch you link to as a dependency (http://drupal.org/node/853194#comment-3197988) installs smoothly, as does the related patch for but geotaxonomy.module. But 853156-1_term_updating.patch choked on Chunk 4 -- the output from FeedsTermProcessor.inc.rej is below:

***************
*** 145,155 ****
        '#options' => $options,
        '#default_value' => $this->config['vocabulary'],
      );
-     // @todo Implement true updating.
      $form['update_existing'] = array(
-       '#type' => 'checkbox',
-       '#title' => t('Replace existing terms'),
-       '#description' => t('If an existing term is found for an imported term, replace it. Existing terms will be determined using mappings that are a "unique target".'),
        '#default_value' => $this->config['update_existing'],
      );
      return $form;
--- 152,166 ----
        '#options' => $options,
        '#default_value' => $this->config['vocabulary'],
      );
      $form['update_existing'] = array(
+       '#type' => 'radios',
+       '#title' => t('Update existing terms'),
+       '#description' => t('Select how existing terms should be updated. Existing terms will be determined using mappings that are a "unique target".'),
+       '#options' => array(
+         FEEDS_SKIP_EXISTING => 'Do not update existing terms',
+         FEEDS_REPLACE_EXISTING => 'Replace existing terms',
+         FEEDS_UPDATE_EXISTING => 'Update existing terms (slower than replacing them)',
+       ),
        '#default_value' => $this->config['update_existing'],
      );
      return $form;

I manually updated the code in FeedsTermProcessor.inc, and the additional option to "Update existing terms (slower than replacing them)" is there, just as it is in your Skitch screenshot.

When I go to actually import, however, the import page no longer has a field for uploading new files -- see http://drupal.org/files/shapefile_import_no_file_browser.PNG.

Since both my shapefile ZIP and my Lat/Long CSV file are already on the site, hitting the import button seems to in fact import the new files -- I get the status message of "Updated 177 Terms in Countries. / Rebuilt term hierarchy." (This is the case for both importers I have set up -- one for shapefiles, and one for lat/long import.)

But most importantly, uploading the shapefiles purges all the lat/long data from my "Countries" geotaxonomy, and vice-versa.

So I seem to have gotten a non-functioning " "Update existing terms " radio button, lost my file-upload window, but not had any real change in the actual update-vs-overwrite situation.

alex_b’s picture

Status: Needs work » Needs review

This is very strange behavior that you are reporting here.

I just did a cvs checkout of the contributions/modules/feeds HEAD and applied the patches #853194-1 and the patch from #1 cleanly.

I can also not confirm missing upload fields.

So I'd recommend to replace the existing Feeds copy with a fresh checkout, apply both patches (and run update.php for that matter).

I think you've set up your importers right, but to make sure we are on the same page, here is a quick run down on how merging updates should work. Let's say your using geotaxonomy module and you'd like to import term locations with one import, term boundaries with another import.

- Create an importer A for the location import: map name (unique), lat, lon.
- Create another importer B for boundaries import: map name (unique), top boundary, right boundary, bottom boundary, left boundary.
- Import A, then B or vice versa.

If the problem persists, can you post your importer configurations attached as txt files?

TKS’s picture

Sounds like a plan. Will report back after some additional testing.

rjbrown99’s picture

I implemented something like this in my custom FeedsNodeProcessor. This issue may be of interest to you as I banged my head against it for hours:

#594004: taxonomy_node_get_terms() needs a $reset param that node_load can call when *it* is reset

TKS’s picture

alex_b -- After a clean CVS checkout of the module, the patch applied cleanly, and the basic functionality and UI are all there as one would expect.

Shapefiles still disappear whenever a term is modified -- this happens when making a change manually as well as when re-importing a CSV of lat/lon data. It's easy to work around that bug, of course, by re-importing your shapefiles after any other changes are made. But since there's no way to see the status of shapefiles on an Edit Term page, the only way to tell what's missing is to look at an actual map. So it'd be great to find a fix for this.

And in the interim, I'll look for a logical place that a warning message could be placed. (Status messages for any GeoTaxonomy import, perhaps?)

alex_b’s picture

Status: Needs review » Reviewed & tested by the community

After a clean CVS checkout of the module, the patch applied cleanly, and the basic functionality and UI are all there as one would expect.

The patch here is RTBC then.

Shapefiles still disappear whenever a term is modified

I just found the culprit for that: #859472: Geometry field blown away after changes through UI.

alex_b’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thank you.

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

Automatically closed -- issue fixed for 2 weeks with no activity.