imagematernal
Welcome, Guest. Please login or register.
Did you miss your activation email?

 
Advanced search

22745 Posts in 6703 Topics- by 17593 Members - Latest Member: permsk

20-10-2019 14:31:11
JOOM::GALLERY::FORUMArchiveJoomGallery 2.x ACLMigrationGallery 2.3.1 to JoomGallery 2 Migration assistance needed
Pages: [1]
Print
Author Topic: Gallery 2.3.1 to JoomGallery 2 Migration assistance needed  (Read 4651 times)
0 Members and 1 Guest are viewing this topic.
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« on: 27-10-2012 15:18:23 »

I have been asked to help with this migration and I have hit a few stumbling blocks.

The main one that I am having is getting the __construct() method of my class to actually be called.  This is preventing the check() method from passing because none of the variables are being registered from the form.  I fear this is a basic lack of knowledge on my part about how the Migration Plugin is supposed to function.

To get to this solution I copied from the JoomGallery 1.5.7 -> 2 migration script.

I have attached one version of my code.

I have figured out, so far, the SQL commands necessary to mutate the Gallery 2.3.1 database (which is in a very normalized / relational setup) into one table.  The only items we are concerned with migrating are images and their captions.  We do not need to retain comments or anything else.

Any help is appreciated.
Logged
Chraneco
Developer-Team
Hero Member
*****
Offline Offline

Posts: 3544


View Profile
« Reply #1 on: 27-10-2012 17:06:41 »

Hi,

do you mean that the __construct() method is not called at all?
This should be done by the migration manager automatically.

What does happen after pressing the 'Check' button?

Quote from: jhines0042
I have figured out, so far, the SQL commands necessary to mutate the Gallery 2.3.1 database (which is in a very normalized / relational setup) into one table.  The only items we are concerned with migrating are images and their captions.  We do not need to retain comments or anything else.

I'm not sure whether I understood this correctly. Wouldn't it be possible to join the different tables while retrieving data?
This way creating another table would not be necessary.

In which way are the parent categories stored in the tables of Gallery 2 (an example would be great)?

Regards
Chraneco
Logged
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #2 on: 27-10-2012 23:38:38 »

I believe that the __construct() method is not called at all... and I'm not sure how.  What happens when I click Check is that the page simply comes back to the form with the check button again.  I placed some debug messages into the check() method and none of them appeared.

Gallery 2 stores its data in the following 3 tables: g2_Item, g2_ItemAttributesMap, g2_FileSystemEntity.  The categories are stored as items along side of the images.  The difference is that the categories have "g_canContainChildren" set to 1 and images are set to 0

Since the JoomMigration script is expecting to alter one table to add the joom_migrated column and use that to keep track of what has been migrated it seemed best to me to create two new tables... migrate_categories and migrate_images in the Gallery 2 db and then use that as the source of the migration information.

The category path is stored in two ways.  g2_ItemAttributesMap stores the parentage of the categories as a fully qualified ID path (e.g. "7/25/" would mean that the immediate parent was 25 and that 25's parent was 7.  I've figured out how to parse this to just get out the immediate parent since that is what JoomGallery wants.)

Thanks for any help / guidance.
Logged
Chraneco
Developer-Team
Hero Member
*****
Offline Offline

Posts: 3544


View Profile
« Reply #3 on: 28-10-2012 15:47:40 »

Hi,

Quote from: jhines0042
I believe that the __construct() method is not called at all... and I'm not sure how.  What happens when I click Check is that the page simply comes back to the form with the check button again.  I placed some debug messages into the check() method and none of them appeared.

It seems that the file is not included and that's because the name is not matching. Assuming your migration is called 'g2joom' then the filename of the migration script has to be 'migrateg2joom.php' (so, prefixed by 'migrate'). Additionally, the class of your migration script has to be prefixed by 'JoomMigrate_' which would give you that: 'JoomMigrate_g2joom'.

The name 'g2joom' has also to appear in the first line of the constructor ($this->migrate = 'g2joom';) and in the HTML form at the end of the file:

Code
<input type="hidden" name="migration" value="g2joom" />

Quote from: jhines0042
Since the JoomMigration script is expecting to alter one table to add the joom_migrated column and use that to keep track of what has been migrated it seemed best to me to create two new tables... migrate_categories and migrate_images in the Gallery 2 db and then use that as the source of the migration information.

The category path is stored in two ways.  g2_ItemAttributesMap stores the parentage of the categories as a fully qualified ID path (e.g. "7/25/" would mean that the immediate parent was 25 and that 25's parent was 7.  I've figured out how to parse this to just get out the immediate parent since that is what JoomGallery wants.)

Thanks for the information. Maybe it would be better to simply add another column with the category ID to the existing table, but I did not test that.

Regards
Chraneco
Logged
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #4 on: 28-10-2012 20:28:19 »

Thank you for the reply, I thought that I might be missing something systematic like what you have suggested.  I'll make the changes and test it out and get back to you if it works (or doesn't)

Thanks again,

Joe H.
Logged
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #5 on: 06-11-2012 02:54:33 »

Just as an FYI, I finally got around to trying the things that you suggested and they did indeed help me get past some major hurdles.  Thank you.

Joe H.
Logged
Chraneco
Developer-Team
Hero Member
*****
Offline Offline

Posts: 3544


View Profile
« Reply #6 on: 06-11-2012 10:47:12 »

Hi,

alright, thanks for the feedback!

If you agree would you like to send us the final script so we can add it to our download section? This way it would be a contribution to the community and many people can benefit from it.

Regards
Chraneco
Logged
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #7 on: 16-11-2012 22:47:48 »

I will send it up when it is final.

One last problem...

I cannot seem to control the order of the categories.

I set $cat->ordering to be an incrementing value but the categories come out in an random order.  Hopefully I can get an answer for this tonight because the actual migration takes place tomorrow.

Thanks!

Joe H.
Logged
Chraneco
Developer-Team
Hero Member
*****
Offline Offline

Posts: 3544


View Profile
« Reply #8 on: 17-11-2012 13:43:33 »

Hi,

thank you very much!

At which place do you increment the ordering value?

Unfortunately, I can't say more about that without seeing the code.

Regards
Chraneco
Logged
jhines0042
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #9 on: 17-11-2012 14:05:41 »

protected function migrateCategories()
  {
   $query = $this->_db2->getQuery(true)
          ->select('g_id as cid, g_title as name, g_parent as parent, g_description as description, catpath ')
          ->from($this->table_categories)
          ->order('catpath desc');

    $this->prepareTable($query, $this->table_categories, 'g_parent', array(0));

   $runningorder = $this->_mainframe->getUserState('joom.migration.data.ordering',0);

    while($cat = $this->getNextObject())
    {
      // Make information accessible for JoomGallery
      $cat->parent_id = $cat->parent;
      $cat->access    = $cat->access + 1;
      $cat->published = 1;
      $cat->owner = 28;
      $cat->ordering = $runningorder + 1;
      $this->_mainframe->setUserState('joom.migration.data.ordering',$runningorder + 1);

     $orig_catpath = $this->_mainframe->getUserState('joom.migration.data.cat_path.'.$cat->parent,null);
      if($cat->parent_id == 0) {
         $this->_mainframe->setUserState('joom.migration.data.cat_path.'.$cat->cid, '');
      } else {
         $this->_mainframe->setUserState('joom.migration.data.cat_path.'.$cat->cid, $orig_catpath.DS.$cat->catpath);
      }

      $test_value = $this->_mainframe->getUserState('joom.migration.data.cat_path.'.$cat->cid, 'NOT STORED');
      $this->writeLogfile('storing joom.migration.data.cat_path.'.$cat->cid.'='.$test_value, JLog::INFO);

      $this->createCategory($cat, false);

      $this->markAsMigrated($cat->cid, 'g_id', $this->table_categories);

      if(!$this->checkTime())
      {
        $this->refresh();
      }
    }

    $this->resetTable($this->table_categories);
  }
Logged
Chraneco
Developer-Team
Hero Member
*****
Offline Offline

Posts: 3544


View Profile
« Reply #10 on: 17-11-2012 15:43:57 »

Hi,

I think the problem is that you aren't incrementing the value in each loop. You just store an incremented value in the session which will not be used until the next refresh of the page.

You have to replace the code

Code
      $cat->ordering = $runningorder + 1;
     $this->_mainframe->setUserState('joom.migration.data.ordering',$runningorder + 1);

with something like that:

Code
      $runningorder++;
     $cat->ordering = $runningorder;
     $this->_mainframe->setUserState('joom.migration.data.ordering',$runningorder);

This way, the value is incremented in each loop.

Regards
Chraneco
Logged
Pages: [1]
Print
Jump to:  

HOSTED BY SCHWARZKÜNSTLER ®

PROTECTED BY  ZB BLOCK  AND Project Honey Pot
Theme orange-lt created by panic

Bad Behavior has blocked 8323 access attempts in the last 7 days.

maternal