first import
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
An example migration from comma separated value files into Drupal nodes. Also a
|
||||
good example of a DynamicMigration (i.e. the same migration class handles
|
||||
multiple migrations).
|
||||
|
||||
We currently depend on Features module just for easy export of a content type.
|
||||
|
||||
The data comes from http://www.retrosheet.org/gamelogs/index.html:
|
||||
|
||||
The information used here was obtained free of charge from and is copyrighted by
|
||||
Retrosheet. Interested parties may contact Retrosheet at "www.retrosheet.org".
|
@@ -0,0 +1,986 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_field_default_fields().
|
||||
*/
|
||||
function migrate_example_baseball_field_default_fields() {
|
||||
$fields = array();
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-body'
|
||||
$fields['node-migrate_example_baseball-body'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(
|
||||
'0' => 'node',
|
||||
),
|
||||
'field_name' => 'body',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'text_with_summary',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'hidden',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '0',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'hidden',
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'trim_length' => 600,
|
||||
),
|
||||
'type' => 'text_summary_or_trimmed',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'body',
|
||||
'label' => 'Body',
|
||||
'required' => FALSE,
|
||||
'settings' => array(
|
||||
'display_summary' => TRUE,
|
||||
'text_processing' => 1,
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'rows' => 20,
|
||||
'summary_rows' => 5,
|
||||
),
|
||||
'type' => 'text_textarea_with_summary',
|
||||
'weight' => '-4',
|
||||
),
|
||||
'widget_type' => 'text_textarea_with_summary',
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_attendance'
|
||||
$fields['node-migrate_example_baseball-field_attendance'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_attendance',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '7',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_attendance',
|
||||
'label' => 'Attendance',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '5',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_duration'
|
||||
$fields['node-migrate_example_baseball-field_duration'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_duration',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '8',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_duration',
|
||||
'label' => 'Duration',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => 'minutes',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '6',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_home_batters'
|
||||
$fields['node-migrate_example_baseball-field_home_batters'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '9',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_home_batters',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '10',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_home_batters',
|
||||
'label' => 'Home batters',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '7',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_home_game_number'
|
||||
$fields['node-migrate_example_baseball-field_home_game_number'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_home_game_number',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '3',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_home_game_number',
|
||||
'label' => 'Home game number',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_home_pitcher'
|
||||
$fields['node-migrate_example_baseball-field_home_pitcher'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_home_pitcher',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '11',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_home_pitcher',
|
||||
'label' => 'Home starting pitcher',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '9',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_home_score'
|
||||
$fields['node-migrate_example_baseball-field_home_score'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_home_score',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '4',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_home_score',
|
||||
'label' => 'Home score',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '2',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_home_team'
|
||||
$fields['node-migrate_example_baseball-field_home_team'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_home_team',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '2',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_home_team',
|
||||
'label' => 'Home team',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '0',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_outs'
|
||||
$fields['node-migrate_example_baseball-field_outs'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_outs',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '6',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_outs',
|
||||
'label' => 'Outs',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '4',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_park'
|
||||
$fields['node-migrate_example_baseball-field_park'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_park',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '1',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_park',
|
||||
'label' => 'Park',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '-2',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_start_date'
|
||||
$fields['node-migrate_example_baseball-field_start_date'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_start_date',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '14',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_start_date',
|
||||
'label' => 'Start date',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '12',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_visiting_batters'
|
||||
$fields['node-migrate_example_baseball-field_visiting_batters'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '9',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_visiting_batters',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '9',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_visiting_batters',
|
||||
'label' => 'Visiting batters',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '8',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_visiting_pitcher'
|
||||
$fields['node-migrate_example_baseball-field_visiting_pitcher'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_visiting_pitcher',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '12',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_visiting_pitcher',
|
||||
'label' => 'Visiting starting pitcher',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '10',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_visiting_score'
|
||||
$fields['node-migrate_example_baseball-field_visiting_score'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_visiting_score',
|
||||
'foreign keys' => array(),
|
||||
'indexes' => array(),
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'translatable' => '1',
|
||||
'type' => 'number_integer',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'number',
|
||||
'settings' => array(
|
||||
'decimal_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
'scale' => 0,
|
||||
'thousand_separator' => ' ',
|
||||
),
|
||||
'type' => 'number_integer',
|
||||
'weight' => '5',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_visiting_score',
|
||||
'label' => 'Visiting score',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'max' => '',
|
||||
'min' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 0,
|
||||
'module' => 'number',
|
||||
'settings' => array(),
|
||||
'type' => 'number',
|
||||
'weight' => '3',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field: 'node-migrate_example_baseball-field_visiting_team'
|
||||
$fields['node-migrate_example_baseball-field_visiting_team'] = array(
|
||||
'field_config' => array(
|
||||
'active' => '1',
|
||||
'cardinality' => '1',
|
||||
'deleted' => '0',
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_visiting_team',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
'0' => 'format',
|
||||
),
|
||||
),
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => '255',
|
||||
),
|
||||
'translatable' => '1',
|
||||
'type' => 'text',
|
||||
),
|
||||
'field_instance' => array(
|
||||
'bundle' => 'migrate_example_baseball',
|
||||
'default_value' => NULL,
|
||||
'deleted' => '0',
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'inline',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => '13',
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_visiting_team',
|
||||
'label' => 'Visiting team',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => '0',
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => '60',
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => '11',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_node_info().
|
||||
*/
|
||||
function migrate_example_baseball_node_info() {
|
||||
$items = array(
|
||||
'migrate_example_baseball' => array(
|
||||
'name' => t('migrate_example_baseball'),
|
||||
'base' => 'node_content',
|
||||
'description' => t('A baseball box score'),
|
||||
'has_title' => '1',
|
||||
'title_label' => t('Title'),
|
||||
'help' => '',
|
||||
),
|
||||
);
|
||||
return $items;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
core = "7.x"
|
||||
dependencies[] = "features"
|
||||
dependencies[] = "migrate"
|
||||
dependencies[] = "number"
|
||||
description = "Import baseball box scores."
|
||||
features[field][] = "node-migrate_example_baseball-body"
|
||||
features[field][] = "node-migrate_example_baseball-field_attendance"
|
||||
features[field][] = "node-migrate_example_baseball-field_duration"
|
||||
features[field][] = "node-migrate_example_baseball-field_home_batters"
|
||||
features[field][] = "node-migrate_example_baseball-field_home_game_number"
|
||||
features[field][] = "node-migrate_example_baseball-field_home_pitcher"
|
||||
features[field][] = "node-migrate_example_baseball-field_home_score"
|
||||
features[field][] = "node-migrate_example_baseball-field_home_team"
|
||||
features[field][] = "node-migrate_example_baseball-field_outs"
|
||||
features[field][] = "node-migrate_example_baseball-field_park"
|
||||
features[field][] = "node-migrate_example_baseball-field_start_date"
|
||||
features[field][] = "node-migrate_example_baseball-field_visiting_batters"
|
||||
features[field][] = "node-migrate_example_baseball-field_visiting_pitcher"
|
||||
features[field][] = "node-migrate_example_baseball-field_visiting_score"
|
||||
features[field][] = "node-migrate_example_baseball-field_visiting_team"
|
||||
features[node][] = "migrate_example_baseball"
|
||||
files[] = "migrate_example_baseball.migrate.inc"
|
||||
name = "migrate_example_baseball"
|
||||
package = "Migrate Examples"
|
||||
php = "5.2.4"
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-06-02
|
||||
version = "7.x-2.4"
|
||||
core = "7.x"
|
||||
project = "migrate"
|
||||
datestamp = "1338661580"
|
||||
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Set up the migration baseball example module.
|
||||
*/
|
||||
|
||||
function migrate_example_baseball_enable() {
|
||||
$path = dirname(__FILE__) . '/data';
|
||||
migrate_example_baseball_get_files($path);
|
||||
for ($i=0; $i<=9; $i++) {
|
||||
$file = 'gl200' . $i . '.txt';
|
||||
Migration::registerMigration('GameBaseball',
|
||||
pathinfo($file, PATHINFO_FILENAME),
|
||||
array('source_file' => $path . '/' . $file));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain our sample data from Retrosheet.
|
||||
*
|
||||
* @param $path
|
||||
*/
|
||||
function migrate_example_baseball_get_files($path) {
|
||||
// Don't replace old upper-case names
|
||||
if (!file_exists("$path/GL2000.TXT") && !file_exists("$path/gl2000.txt")) {
|
||||
file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
|
||||
$result = copy('http://www.retrosheet.org/gamelogs/gl2000_09.zip',
|
||||
$path . '/gl2000_09.zip');
|
||||
if ($result) {
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($path . '/gl2000_09.zip');
|
||||
$zip->extractTo($path);
|
||||
$zip->close();
|
||||
unlink("$path/gl2000_09.zip");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function migrate_example_baseball_uninstall() {
|
||||
$bundle = 'migrate_example_baseball';
|
||||
$field_names = array('field_park', 'field_home_team', 'field_home_game_number',
|
||||
'field_home_score', 'field_visiting_score', 'field_outs', 'field_attendance',
|
||||
'field_duration', 'field_home_batters', 'field_visiting_batters',
|
||||
'field_home_pitcher', 'field_visiting_pitcher', 'field_visiting_team',
|
||||
'field_start_date');
|
||||
foreach ($field_names as $field_name) {
|
||||
$instance = field_info_instance('node', $field_name, $bundle);
|
||||
field_delete_instance($instance);
|
||||
field_delete_field($field_name);
|
||||
}
|
||||
node_type_delete($bundle);
|
||||
}
|
||||
|
||||
function migrate_example_baseball_disable() {
|
||||
for ($i=0; $i<=9; $i++) {
|
||||
$file = 'gl200' . $i . '.txt';
|
||||
Migration::deregisterMigration(pathinfo($file, PATHINFO_FILENAME));
|
||||
$filename = dirname(__FILE__) . '/data/' . $file;
|
||||
if (file_exists($filename)) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the sample CSV data if necessary.
|
||||
*/
|
||||
function migrate_example_baseball_update_7201() {
|
||||
migrate_example_baseball_get_files(dirname(__FILE__) . '/data');
|
||||
}
|
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* A baseball game migration example.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* You must implement hook_migrate_api(), setting the API level to 2, for
|
||||
* your migration classes to be recognized by the Migrate module.
|
||||
*/
|
||||
function migrate_example_baseball_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dynamic migration that is reused for each source CSV file.
|
||||
*/
|
||||
class GameBaseball extends DynamicMigration {
|
||||
public function __construct(array $arguments) {
|
||||
$this->arguments = $arguments;
|
||||
parent::__construct();
|
||||
$this->description = t('Import box scores from CSV file.');
|
||||
|
||||
// Create a map object for tracking the relationships between source rows
|
||||
$this->map = new MigrateSQLMap($this->machineName,
|
||||
array(
|
||||
'start_date' => array('type' => 'varchar',
|
||||
'length' => 8,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Start date',
|
||||
),
|
||||
'home_team' => array('type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Home team',
|
||||
),
|
||||
'home_game_number' => array('type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Home team game number',
|
||||
),
|
||||
),
|
||||
MigrateDestinationNode::getKeySchema()
|
||||
);
|
||||
|
||||
// Create a MigrateSource object, which manages retrieving the input data.
|
||||
$this->source = new MigrateSourceCSV($arguments['source_file'], $this->csvcolumns(), array(), $this->fields());
|
||||
|
||||
$this->destination = new MigrateDestinationNode('migrate_example_baseball');
|
||||
|
||||
$this->addFieldMapping('title', 'title')
|
||||
->description('See prepareRow().');
|
||||
$this->addFieldMapping('field_start_date', 'start_date');
|
||||
$this->addFieldMapping('field_park', 'park_id');
|
||||
$this->addFieldMapping('field_visiting_team', 'visiting_team');
|
||||
$this->addFieldMapping('field_home_team', 'home_team');
|
||||
$this->addFieldMapping('field_home_game_number', 'home_game_number');
|
||||
$this->addFieldMapping('field_home_score', 'home_score');
|
||||
$this->addFieldMapping('field_visiting_score', 'visiting_score');
|
||||
$this->addFieldMapping('field_outs', 'outs');
|
||||
$this->addFieldMapping('field_attendance', 'attendance');
|
||||
$this->addFieldMapping('field_duration', 'duration')
|
||||
->defaultValue(NULL);
|
||||
$this->addFieldMapping('field_home_pitcher', 'home_pitcher');
|
||||
$this->addFieldMapping('field_visiting_pitcher', 'visiting_pitcher');
|
||||
$this->addFieldMapping('field_home_batters', 'home_batters')
|
||||
->separator(',')
|
||||
->description('See prepareRow().');
|
||||
$this->addFieldMapping('field_visiting_batters', 'visiting_batters')
|
||||
->separator(',')
|
||||
->description('See prepareRow().');
|
||||
for ($i=1; $i <= 9; $i++ ) {
|
||||
$this->addFieldMapping(NULL, "visiting_batter_$i")
|
||||
->description('Not needed since we use the multi-value field: visiting_batters.');
|
||||
$this->addFieldMapping(NULL, "home_batter_$i")
|
||||
->description('Not needed since we use the multi-value field: home_batters.');
|
||||
}
|
||||
}
|
||||
|
||||
function csvcolumns() {
|
||||
// Note: Remember to subtract 1 from column number at http://www.retrosheet.org/gamelogs/glfields.txt
|
||||
$columns[0] = array('start_date', 'Date of game');
|
||||
$columns[3] = array('visiting_team', 'Visiting team');
|
||||
$columns[6] = array('home_team', 'Home team');
|
||||
$columns[8] = array('home_game_number', 'Home team game number');
|
||||
$columns[9] = array('home_score', 'Home score');
|
||||
$columns[10] = array('visiting_score', 'Visiting score');
|
||||
$columns[11] = array('outs', 'Length of game in outs');
|
||||
$columns[16] = array('park_id', 'Ballpark ID');
|
||||
$columns[17] = array('attendance', 'Attendance');
|
||||
$columns[18] = array('duration', 'Duration in minutes');
|
||||
for ($i=1; $i <= 9; $i++ ) {
|
||||
$columns[103+3*$i] = array("visiting_batter_$i", "Visiting batter $i");
|
||||
$columns[130+3*$i] = array("home_batter_$i", "Home batter $i");
|
||||
}
|
||||
$columns[102] = array('visiting_pitcher', 'Visiting starting pitcher');
|
||||
$columns[104] = array('home_pitcher', 'Home starting pitcher');
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function prepareRow($row) {
|
||||
// Collect all the batters into one multi-value field.
|
||||
for ($i=1; $i <= 9; $i++ ) {
|
||||
$key = "visiting_batter_$i";
|
||||
$visiting_batters[] = $row->$key;
|
||||
$key = "home_batter_$i";
|
||||
$home_batters[] = $row->$key;
|
||||
}
|
||||
$row->visiting_batters = implode(',', $visiting_batters);
|
||||
$row->home_batters = implode(',', $home_batters);
|
||||
$row->title = "$row->home_team vs. $row->visiting_team. " . gmdate('M d, Y', strtotime($row->start_date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the machine name from the source file name.
|
||||
*/
|
||||
protected function generateMachineName($class_name = NULL) {
|
||||
return drupal_strtolower(pathinfo($this->arguments['source_file'],
|
||||
PATHINFO_FILENAME));
|
||||
}
|
||||
|
||||
function fields() {
|
||||
return array(
|
||||
'title' => 'A composite field made during prepareRow().',
|
||||
'home_batters' => 'An array of batters, populated during prepareRow().',
|
||||
'visiting_batters' => 'An array of batters, populated during prepareRow().',
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
include_once('migrate_example_baseball.features.inc');
|
Reference in New Issue
Block a user