Add extra field mappings and tamper plugins for all log types.
This commit is contained in:
parent
0651fa0c7c
commit
6ba444c322
|
@ -249,6 +249,21 @@ function farm_crop_feeds_importer_default_alter(&$importers) {
|
|||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
|
||||
// Add extra field mappings to seedings.
|
||||
$name = 'log_farm_seeding';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Source/supplier',
|
||||
'target' => 'field_farm_seed_source',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,3 +21,45 @@ function farm_livestock_eggs_farm_ui_entities() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_livestock_eggs_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to eggs.
|
||||
$name = 'log_farm_eggs';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Quantity',
|
||||
'target' => 'field_farm_egg_qty',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Group',
|
||||
'target' => 'field_farm_animal_group',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_tamper_default_alter().
|
||||
*/
|
||||
function farm_livestock_eggs_feeds_tamper_default_alter(&$feeds_tampers) {
|
||||
|
||||
// If farm_import is not installed, bail.
|
||||
if (!module_exists('farm_import')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Explode group so it supports multiple values.
|
||||
$feeds_tamper = farm_import_feeds_tamper_plugin('log', 'farm_eggs', 'Group', 'explode');
|
||||
$feeds_tampers[$feeds_tamper->id] = $feeds_tamper;
|
||||
}
|
||||
|
|
|
@ -22,3 +22,24 @@ function farm_log_harvest_farm_ui_entities() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_log_harvest_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to harvests.
|
||||
$name = 'log_farm_harvest';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Lot number',
|
||||
'target' => 'field_farm_lot_number',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,3 +23,69 @@ function farm_log_input_farm_ui_entities() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_log_input_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to inputs.
|
||||
$name = 'log_farm_input';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Material',
|
||||
'target' => 'field_farm_material',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Purpose',
|
||||
'target' => 'field_farm_input_purpose',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Application method',
|
||||
'target' => 'field_farm_input_method',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Source/manufacturer',
|
||||
'target' => 'field_farm_input_source',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Lot number',
|
||||
'target' => 'field_farm_lot_number',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Date purchased',
|
||||
'target' => 'field_farm_date_purchase:start',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_tamper_default_alter().
|
||||
*/
|
||||
function farm_log_input_feeds_tamper_default_alter(&$feeds_tampers) {
|
||||
|
||||
// If farm_import is not installed, bail.
|
||||
if (!module_exists('farm_import')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert date purchased to a Unix timestamp
|
||||
$feeds_tamper = farm_import_feeds_tamper_plugin('log', 'farm_input', 'Date purchased', 'strtotime');
|
||||
$feeds_tampers[$feeds_tamper->id] = $feeds_tamper;
|
||||
}
|
||||
|
|
|
@ -21,3 +21,48 @@ function farm_log_sale_farm_ui_entities() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_log_sale_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to sales.
|
||||
$name = 'log_farm_sale';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Customer',
|
||||
'target' => 'field_farm_customer',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Invoice number',
|
||||
'target' => 'field_farm_invoice_number',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Lot number',
|
||||
'target' => 'field_farm_lot_number',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Unit price',
|
||||
'target' => 'field_farm_unit_price',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Total price',
|
||||
'target' => 'field_farm_total_price',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,3 +23,45 @@ function farm_soil_test_farm_ui_entities() {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_soil_test_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to soil tests.
|
||||
$name = 'log_farm_soil_test';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Laboratory',
|
||||
'target' => 'field_farm_soil_lab',
|
||||
'unique' => FALSE,
|
||||
'language' => 'und',
|
||||
),
|
||||
array(
|
||||
'source' => 'Soil names',
|
||||
'target' => 'field_farm_soil_names',
|
||||
'term_search' => '0',
|
||||
'autocreate' => 1,
|
||||
'language' => 'und',
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_tamper_default_alter().
|
||||
*/
|
||||
function farm_soil_test_feeds_tamper_default_alter(&$feeds_tampers) {
|
||||
|
||||
// If farm_import is not installed, bail.
|
||||
if (!module_exists('farm_import')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Explode soil names so it supports multiple values.
|
||||
$feeds_tamper = farm_import_feeds_tamper_plugin('log', 'farm_soil_test', 'Soil names', 'explode');
|
||||
$feeds_tampers[$feeds_tamper->id] = $feeds_tamper;
|
||||
}
|
||||
|
|
|
@ -22,3 +22,23 @@ function farm_water_test_farm_ui_entities() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_importer_default_alter().
|
||||
*/
|
||||
function farm_water_test_feeds_importer_default_alter(&$importers) {
|
||||
|
||||
// Add extra field mappings to water tests.
|
||||
$name = 'log_farm_water_test';
|
||||
if (!empty($importers[$name])) {
|
||||
$mappings = array(
|
||||
array(
|
||||
'source' => 'Laboratory',
|
||||
'target' => 'field_farm_water_lab',
|
||||
'unique' => FALSE,
|
||||
),
|
||||
);
|
||||
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
||||
$importer_mappings = array_merge($importer_mappings, $mappings);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue