PerfMigrate.d.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * PerfGroupeNodeMigration
  4. *
  5. */
  6. abstract class PerfDNodeMigration extends PerfApiMigration {
  7. public function __construct() {
  8. $this->description = t('Migrate Document Sonore Class');
  9. parent::__construct();
  10. $this->fields += array(
  11. 'ID' => t('id'),
  12. 'title' => t('title'),
  13. 'synopsis_description' => t('SYNOPSIS_DESCRIPTION'),
  14. 'duree' => t('duree'),
  15. 'proprietaire' => t('proprietaire'),
  16. 'realisateur' => t('realisateur'),
  17. 'date_realisation' => t('date_realisation'),
  18. 'production' => t('production'),
  19. 'notes' => t('notes'),
  20. );
  21. // The source ID here is the one retrieved from the XML listing file, and
  22. // used to identify the specific item's file
  23. $this->map = new MigrateSQLMap($this->machineName,
  24. array(
  25. 'ID' => array(
  26. 'type' => 'varchar',
  27. 'length' => 255,
  28. 'not null' => TRUE,
  29. )
  30. ),
  31. MigrateDestinationNode::getKeySchema()
  32. );
  33. $item_ID_xpath = '@ID'; // relative to item_xpath and gets assembled
  34. // into full path /producers/producer/sourceid
  35. $items_class = new MigrateItemsXML($this->items_url, $this->item_xpath, $item_ID_xpath); //
  36. $this->source = new MigrateSourceMultiItems($items_class, $this->fields);
  37. $this->addFieldMapping('language')->defaultValue('fr');
  38. $this->addFieldMapping('is_new')->defaultValue(TRUE);
  39. // $this->addFieldMapping('created', 'date_creation');
  40. // $this->addFieldMapping('changed', 'date_modif');
  41. $this->addFieldMapping('status')->defaultValue(1);
  42. $this->addFieldMapping('promote')->defaultValue(0);
  43. $this->addFieldMapping('sticky')->defaultValue(0);
  44. $this->addFieldMapping('title', 'title');
  45. $this->addFieldMapping('field_duree', 'duree');
  46. $this->addFieldMapping('field_synopsis_description', 'synopsis_description')
  47. ->xpath('@SYNOPSIS_DESCRIPTION');
  48. $this->addFieldMapping('field_synopsis_description:format')->defaultValue('filtred_html');
  49. $this->addFieldMapping('field_proprietaire', 'proprietaire')
  50. ->xpath('@ID_PROPRIETAIRE_OBJET');
  51. $this->addFieldMapping('field_realisateur', 'realisateur')
  52. ->xpath('@REALISATEUR');
  53. $this->addFieldMapping('field_date_realisation', 'date_realisation')
  54. ->xpath('@DATE_REALISATION');
  55. $this->addFieldMapping('field_production', 'production')
  56. ->xpath('@PRODUCTION');
  57. $this->addFieldMapping('field_notes', 'notes')
  58. ->xpath('@NOTES');
  59. $this->addUnmigratedDestinations(array('revision_uid', 'created', 'changed', 'revision', 'log', 'tnid','comment', 'uid','path', 'pathauto',
  60. 'field_duree:format', 'field_duree:language',
  61. 'field_synopsis_description:language',
  62. 'field_proprietaire:language', 'field_proprietaire:format',
  63. 'field_realisateur:language', 'field_realisateur:format',
  64. 'field_date_realisation:language', 'field_date_realisation:format',
  65. 'field_production:language', 'field_production:format',
  66. 'field_notes:language', 'field_notes:format',
  67. 'field_performances'
  68. ));
  69. }
  70. public function prepareRow($row){
  71. // dsm($row , '--- $row ---');
  72. $xml = $row->xml;
  73. $title = $this->getAttribute($xml, 'TITRE');
  74. if(strlen($title) > 255)
  75. $title = substr($title, 0, 250) . '...';
  76. $row->title = $title;
  77. $row->duree = $this->getAttribute($xml, 'DUREE') .' '. $this->getAttribute($xml, 'UNITE_DUREE');
  78. }
  79. public function prepare($node, stdClass $row) {
  80. $node->name = 'migration';
  81. $node->workflow = 2;
  82. }
  83. }