Migrate field_farm_soil_sample_points to field_farm_geofield.
This commit is contained in:
parent
8551b39cd4
commit
365062a6c0
|
@ -36,55 +36,5 @@ function farm_soil_field_default_field_bases() {
|
|||
'type' => 'taxonomy_term_reference',
|
||||
);
|
||||
|
||||
// Exported field_base: 'field_farm_soil_sample_points'.
|
||||
$field_bases['field_farm_soil_sample_points'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => -1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_farm_soil_sample_points',
|
||||
'indexes' => array(
|
||||
'bbox' => array(
|
||||
0 => 'top',
|
||||
1 => 'bottom',
|
||||
2 => 'left',
|
||||
3 => 'right',
|
||||
),
|
||||
'bottom' => array(
|
||||
0 => 'bottom',
|
||||
),
|
||||
'centroid' => array(
|
||||
0 => 'lat',
|
||||
1 => 'lon',
|
||||
),
|
||||
'geohash' => array(
|
||||
0 => 'geohash',
|
||||
),
|
||||
'lat' => array(
|
||||
0 => 'lat',
|
||||
),
|
||||
'left' => array(
|
||||
0 => 'left',
|
||||
),
|
||||
'lon' => array(
|
||||
0 => 'lon',
|
||||
),
|
||||
'right' => array(
|
||||
0 => 'right',
|
||||
),
|
||||
'top' => array(
|
||||
0 => 'top',
|
||||
),
|
||||
),
|
||||
'locked' => 0,
|
||||
'module' => 'geofield',
|
||||
'settings' => array(
|
||||
'backend' => 'default',
|
||||
'srid' => 4326,
|
||||
),
|
||||
'translatable' => 0,
|
||||
'type' => 'geofield',
|
||||
);
|
||||
|
||||
return $field_bases;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,5 @@ dependencies[] = taxonomy
|
|||
features[ctools][] = strongarm:strongarm:1
|
||||
features[features_api][] = api:2
|
||||
features[field_base][] = field_farm_soil_names
|
||||
features[field_base][] = field_farm_soil_sample_points
|
||||
features[taxonomy][] = farm_soil_names
|
||||
features[variable][] = pathauto_taxonomy_term_farm_soil_names_pattern
|
||||
|
|
|
@ -78,6 +78,71 @@ function farm_soil_test_field_default_field_instances() {
|
|||
),
|
||||
);
|
||||
|
||||
// Exported field_instance: 'log-farm_soil_test-field_farm_geofield'.
|
||||
$field_instances['log-farm_soil_test-field_farm_geofield'] = array(
|
||||
'bundle' => 'farm_soil_test',
|
||||
'default_value' => NULL,
|
||||
'deleted' => 0,
|
||||
'description' => 'Use the map to pinpoint the location(s) from which this sample is taken. If you are preparing a soil test, you may be sampling multiple points within a given area. All the points that comprise this sample should be included.',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'module' => 'openlayers_geofield',
|
||||
'settings' => array(
|
||||
'data' => 'full',
|
||||
'map_layer_preset' => 'farm_map_geofield_formatter:openlayers_geofield_layer_formatter',
|
||||
),
|
||||
'type' => 'openlayers_geofield',
|
||||
'weight' => 1,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'log',
|
||||
'field_name' => 'field_farm_geofield',
|
||||
'label' => 'Sample points',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'openlayers_geofield',
|
||||
'settings' => array(
|
||||
'allow_edit' => 1,
|
||||
'data_storage' => 'collection',
|
||||
'delta_handling' => 'default',
|
||||
'feature_types' => array(
|
||||
'path' => 0,
|
||||
'point' => 'point',
|
||||
'polygon' => 0,
|
||||
),
|
||||
'geocoder_field' => 'field_farm_files',
|
||||
'geocoder_handler' => 'kml',
|
||||
'handler_settings' => array(
|
||||
'google' => array(
|
||||
'all_results' => 0,
|
||||
'biasing' => array(
|
||||
'bounds' => '',
|
||||
'components' => '',
|
||||
'region' => '',
|
||||
),
|
||||
'geometry_type' => 'point',
|
||||
'reject_results' => array(
|
||||
'APPROXIMATE' => 0,
|
||||
'GEOMETRIC_CENTER' => 0,
|
||||
'RANGE_INTERPOLATED' => 0,
|
||||
'ROOFTOP' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
'openlayers_map' => 'farm_map_geofield',
|
||||
'showInputField' => 1,
|
||||
'use_geocoder' => 1,
|
||||
),
|
||||
'type' => 'openlayers_geofield',
|
||||
'weight' => 3,
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field_instance: 'log-farm_soil_test-field_farm_images'.
|
||||
$field_instances['log-farm_soil_test-field_farm_images'] = array(
|
||||
'bundle' => 'farm_soil_test',
|
||||
|
@ -292,68 +357,7 @@ function farm_soil_test_field_default_field_instances() {
|
|||
'size' => 60,
|
||||
),
|
||||
'type' => 'taxonomy_autocomplete',
|
||||
'weight' => 4,
|
||||
),
|
||||
);
|
||||
|
||||
// Exported field_instance:
|
||||
// 'log-farm_soil_test-field_farm_soil_sample_points'.
|
||||
$field_instances['log-farm_soil_test-field_farm_soil_sample_points'] = array(
|
||||
'bundle' => 'farm_soil_test',
|
||||
'default_value' => NULL,
|
||||
'deleted' => 0,
|
||||
'description' => 'Use the map to pinpoint the location(s) from which this sample is taken. If you are preparing a soil test, you may be sampling multiple points within a given area. All the points that comprise this sample should be included.',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'module' => 'openlayers_geofield',
|
||||
'settings' => array(
|
||||
'data' => 'full',
|
||||
'map_layer_preset' => 'farm_map_geofield_formatter:openlayers_geofield_layer_formatter',
|
||||
),
|
||||
'type' => 'openlayers_geofield',
|
||||
'weight' => 1,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'log',
|
||||
'field_name' => 'field_farm_soil_sample_points',
|
||||
'label' => 'Sample Points',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'openlayers_geofield',
|
||||
'settings' => array(
|
||||
'allow_edit' => 1,
|
||||
'data_storage' => 'collection',
|
||||
'delta_handling' => 'default',
|
||||
'feature_types' => array(
|
||||
'path' => 0,
|
||||
'point' => 'point',
|
||||
'polygon' => 0,
|
||||
),
|
||||
'geocoder_field' => 'field_farm_files',
|
||||
'geocoder_handler' => 'kml',
|
||||
'handler_settings' => array(
|
||||
'google' => array(
|
||||
'all_results' => 0,
|
||||
'geometry_type' => 'point',
|
||||
'reject_results' => array(
|
||||
'APPROXIMATE' => 0,
|
||||
'GEOMETRIC_CENTER' => 0,
|
||||
'RANGE_INTERPOLATED' => 0,
|
||||
'ROOFTOP' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
'openlayers_map' => 'farm_map_geofield',
|
||||
'showInputField' => 1,
|
||||
'use_geocoder' => 1,
|
||||
),
|
||||
'type' => 'openlayers_geofield',
|
||||
'weight' => 3,
|
||||
'weight' => 5,
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -368,7 +372,7 @@ function farm_soil_test_field_default_field_instances() {
|
|||
t('Notes');
|
||||
t('Optionally assign this task to one or more people.');
|
||||
t('Photos');
|
||||
t('Sample Points');
|
||||
t('Sample points');
|
||||
t('Soil Names');
|
||||
t('Use the map to pinpoint the location(s) from which this sample is taken. If you are preparing a soil test, you may be sampling multiple points within a given area. All the points that comprise this sample should be included.');
|
||||
t('Use this to organize your logs into categories for easier searching and filtering later.');
|
||||
|
|
|
@ -172,7 +172,7 @@ function farm_soil_test_field_group_info() {
|
|||
'children' => array(
|
||||
0 => 'field_farm_area',
|
||||
1 => 'field_farm_soil_names',
|
||||
2 => 'field_farm_soil_sample_points',
|
||||
2 => 'field_farm_geofield',
|
||||
),
|
||||
'format_type' => 'fieldset',
|
||||
'format_settings' => array(
|
||||
|
|
|
@ -37,12 +37,12 @@ features[field_group][] = group_farm_notes|log|farm_soil_test|form
|
|||
features[field_group][] = group_farm_soil|log|farm_soil_test|form
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_area
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_files
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_geofield
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_images
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_log_category
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_log_owner
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_notes
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_soil_lab
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_soil_names
|
||||
features[field_instance][] = log-farm_soil_test-field_farm_soil_sample_points
|
||||
features[log_type][] = farm_soil_test
|
||||
features[views_view][] = farm_log_soil_tests
|
||||
|
|
|
@ -19,7 +19,6 @@ function farm_soil_test_update_dependencies() {
|
|||
return $dependencies;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change "Soil Types" to "Soil Names".
|
||||
*/
|
||||
|
@ -45,3 +44,34 @@ function farm_soil_test_update_7000(&$sandbox) {
|
|||
$field = field_info_instance('log', 'field_farm_soil_types', 'farm_soil_test');
|
||||
field_delete_instance($field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate soil test sample points to field_farm_geofield.
|
||||
*/
|
||||
function farm_soil_test_update_7001(&$sandbox) {
|
||||
|
||||
// Define table mappings.
|
||||
$table_mappings = array(
|
||||
'field_data_field_farm_soil_sample_points' => 'field_data_field_farm_geofield',
|
||||
'field_revision_field_farm_soil_sample_points' => 'field_revision_field_farm_geofield',
|
||||
);
|
||||
|
||||
// Check to be sure that the tables exist. If not, bail.
|
||||
foreach ($table_mappings as $old => $new) {
|
||||
$tables = array($old, $new);
|
||||
foreach ($tables as $table) {
|
||||
if (!db_table_exists($table)) {
|
||||
throw new DrupalUpdateException('Database table not found: ' . $table . '. Aborting update.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate data.
|
||||
foreach ($table_mappings as $old => $new) {
|
||||
db_query('INSERT INTO {' . $new . '} SELECT * FROM {' . $old . '}');
|
||||
}
|
||||
|
||||
// Delete the old field instance.
|
||||
$field = field_info_instance('log', 'field_farm_soil_sample_points', 'farm_soil_test');
|
||||
field_delete_instance($field);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue