Skip to content

Commit

Permalink
[REF] [Import] Remove another good intention - conflict
Browse files Browse the repository at this point in the history
There is all sorts of handling for 'conflict' - but a conflict return code is never
generated
  • Loading branch information
eileenmcnaughton committed May 5, 2022
1 parent 99b43f2 commit da8d3d4
Show file tree
Hide file tree
Showing 30 changed files with 16 additions and 431 deletions.
11 changes: 0 additions & 11 deletions CRM/Activity/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function preProcess() {
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$mismatchCount = $this->get('unMatchCount');

// Get the mapping name displayed if the mappingId is set.
Expand All @@ -46,11 +45,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($conflictRowCount) {
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
Expand All @@ -63,9 +57,7 @@ public function preProcess() {
'totalRowCount',
'validRowCount',
'invalidRowCount',
'conflictRowCount',
'downloadErrorRecordsUrl',
'downloadConflictRecordsUrl',
'downloadMismatchRecordsUrl',
];
$this->setStatusUrl();
Expand All @@ -83,7 +75,6 @@ public function preProcess() {
public function postProcess() {
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$onDuplicate = $this->get('onDuplicate');

$mapper = $this->controller->exportValue('MapField', 'mapper');
Expand Down Expand Up @@ -139,8 +130,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
Expand Down
5 changes: 1 addition & 4 deletions CRM/Activity/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function preProcess() {
$this->set('totalRowCount', $totalRowCount);

$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
Expand Down Expand Up @@ -68,7 +67,7 @@ public function preProcess() {
// Only subtract dupes from successful import if we're skipping.

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$conflictRowCount - $duplicateRowCount - $mismatchCount
$duplicateRowCount - $mismatchCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -77,8 +76,6 @@ public function preProcess() {
'totalRowCount',
'validRowCount',
'invalidRowCount',
'conflictRowCount',
'downloadConflictRecordsUrl',
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
Expand Down
27 changes: 3 additions & 24 deletions CRM/Activity/Import/Parser/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,10 @@ public function run(

$this->_lineCount = 0;
$this->_invalidRowCount = $this->_validCount = 0;
$this->_totalCount = $this->_conflictCount = 0;
$this->_totalCount = 0;

$this->_errors = [];
$this->_warnings = [];
$this->_conflicts = [];

$this->_fileSize = number_format(filesize($fileName) / 1024.0, 2);

Expand Down Expand Up @@ -571,16 +570,6 @@ public function run(
$this->_errors[] = $values;
}

if ($returnCode & self::CONFLICT) {
$this->_conflictCount++;
$recordNumber = $this->_lineCount;
if ($this->_haveColumnHeader) {
$recordNumber--;
}
array_unshift($values, $recordNumber);
$this->_conflicts[] = $values;
}

if ($returnCode & self::DUPLICATE) {
$this->_duplicateCount++;
$recordNumber = $this->_lineCount;
Expand Down Expand Up @@ -620,14 +609,7 @@ public function run(
$this->_errorFileName = self::errorFileName(self::ERROR);
self::exportCSV($this->_errorFileName, $headers, $this->_errors);
}
if ($this->_conflictCount) {
$headers = array_merge(
[ts('Line Number'), ts('Reason')],
$customHeaders
);
$this->_conflictFileName = self::errorFileName(self::CONFLICT);
self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
}

if ($this->_duplicateCount) {
$headers = array_merge(
[ts('Line Number'), ts('View Activity History URL')],
Expand Down Expand Up @@ -700,14 +682,11 @@ public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('totalRowCount', $this->_totalCount);
$store->set('validRowCount', $this->_validCount);
$store->set('invalidRowCount', $this->_invalidRowCount);
$store->set('conflictRowCount', $this->_conflictCount);

if ($this->_invalidRowCount) {
$store->set('errorsFileName', $this->_errorFileName);
}
if ($this->_conflictCount) {
$store->set('conflictsFileName', $this->_conflictFileName);
}

if (isset($this->_rows) && !empty($this->_rows)) {
$store->set('dataValues', $this->_rows);
}
Expand Down
12 changes: 0 additions & 12 deletions CRM/Contact/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CRM_Contact_Import_Form_Preview extends CRM_Import_Form_Preview {
* @throws \CRM_Core_Exception
*/
public function preProcess() {
$conflictRowCount = $this->get('conflictRowCount');
$mismatchCount = $this->get('unMatchCount');
$columnNames = $this->get('columnNames');
$this->_disableUSPS = $this->get('disableUSPS');
Expand Down Expand Up @@ -66,12 +65,6 @@ public function preProcess() {
$this->assign('validRowCount', $this->getRowCount(CRM_Import_Parser::VALID));
$this->assign('totalRowCount', $this->getRowCount([]));

// @todo conflict rows are still being output in the parser & not updating the temp table - fix
if ($conflictRowCount) {
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contact_Import_Parser_Contact';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contact_Import_Parser_Contact';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
Expand Down Expand Up @@ -185,7 +178,6 @@ public function postProcess() {
$importJobParams = array(
'doGeocodeAddress' => $this->controller->exportValue('DataSource', 'doGeocodeAddress'),
'invalidRowCount' => $this->get('invalidRowCount'),
'conflictRowCount' => $this->get('conflictRowCount'),
'onDuplicate' => $this->get('onDuplicate'),
'dedupe' => $this->getSubmittedValue('dedupe_rule_id'),
'newGroupName' => $this->controller->exportValue($this->_name, 'newGroupName'),
Expand Down Expand Up @@ -251,10 +243,6 @@ public function postProcess() {

$this->set('errorFile', $errorFile);

// @todo - these should use the new url but are not reliably updating the table yet.
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contact_Import_Parser_Contact';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));

$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contact_Import_Parser_Contact';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
Expand Down
5 changes: 1 addition & 4 deletions CRM/Contact/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function preProcess() {
$totalRowCount += $relatedCount;

$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
Expand Down Expand Up @@ -75,14 +74,12 @@ public function preProcess() {
}
//now we also create relative contact in update and fill mode
$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$conflictRowCount - $duplicateRowCount - $mismatchCount
$duplicateRowCount - $mismatchCount
);

$this->assign('dupeActionString', $dupeActionString);

$properties = [
'conflictRowCount',
'downloadConflictRecordsUrl',
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
Expand Down
1 change: 0 additions & 1 deletion CRM/Contact/Import/ImportJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class CRM_Contact_Import_ImportJob {

protected $_doGeocodeAddress;
protected $_invalidRowCount;
protected $_conflictRowCount;
protected $_onDuplicate;
protected $_dedupe;
protected $_newGroupName;
Expand Down
21 changes: 1 addition & 20 deletions CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2576,11 +2576,10 @@ public function run(

$this->_rowCount = 0;
$this->_invalidRowCount = $this->_validCount = 0;
$this->_totalCount = $this->_conflictCount = 0;
$this->_totalCount = 0;

$this->_errors = [];
$this->_warnings = [];
$this->_conflicts = [];
$this->_unparsedAddresses = [];

$this->_tableName = $tableName = $this->getUserJob()['metadata']['DataSource']['table_name'];
Expand Down Expand Up @@ -2672,12 +2671,6 @@ public function run(
$this->_errors[] = $values;
}

if ($returnCode & self::CONFLICT) {
$this->_conflictCount++;
array_unshift($values, $this->_rowCount);
$this->_conflicts[] = $values;
}

if ($returnCode & self::NO_MATCH) {
$this->_unMatchCount++;
array_unshift($values, $this->_rowCount);
Expand Down Expand Up @@ -2715,14 +2708,6 @@ public function run(
}
}

if ($this->_conflictCount) {
$headers = array_merge([
ts('Line Number'),
ts('Reason'),
], $customHeaders);
$this->_conflictFileName = self::errorFileName(self::CONFLICT);
self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts);
}
if ($this->_unMatchCount) {
$headers = array_merge([
ts('Line Number'),
Expand Down Expand Up @@ -3039,7 +3024,6 @@ public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('totalRowCount', $this->_totalCount);
$store->set('validRowCount', $this->_validCount);
$store->set('invalidRowCount', $this->_invalidRowCount);
$store->set('conflictRowCount', $this->_conflictCount);
$store->set('unMatchCount', $this->_unMatchCount);

switch ($this->_contactType) {
Expand All @@ -3055,9 +3039,6 @@ public function set($store, $mode = self::MODE_SUMMARY) {
$store->set('contactType', CRM_Import_Parser::CONTACT_ORGANIZATION);
}

if ($this->_conflictCount) {
$store->set('conflictsFileName', $this->_conflictFileName);
}
if (isset($this->_rows) && !empty($this->_rows)) {
$store->set('dataValues', $this->_rows);
}
Expand Down
11 changes: 0 additions & 11 deletions CRM/Contribute/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function preProcess() {
$softCreditFields = $this->get('softCreditFields');
$mapperSoftCreditType = $this->get('mapperSoftCreditType');
$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$mismatchCount = $this->get('unMatchCount');

//get the mapping name displayed if the mappingId is set
Expand All @@ -48,11 +47,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($conflictRowCount) {
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
Expand All @@ -67,9 +61,7 @@ public function preProcess() {
'totalRowCount',
'validRowCount',
'invalidRowCount',
'conflictRowCount',
'downloadErrorRecordsUrl',
'downloadConflictRecordsUrl',
'downloadMismatchRecordsUrl',
];
$this->setStatusUrl();
Expand All @@ -85,7 +77,6 @@ public function preProcess() {
public function postProcess() {
$fileName = $this->controller->exportValue('DataSource', 'uploadFile');
$invalidRowCount = $this->get('invalidRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$onDuplicate = $this->get('onDuplicate');
$mapperSoftCreditType = $this->get('mapperSoftCreditType');

Expand Down Expand Up @@ -152,8 +143,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
Expand Down
5 changes: 1 addition & 4 deletions CRM/Contribute/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function preProcess() {
$this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
$validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
$conflictRowCount = $this->get('conflictRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
Expand Down Expand Up @@ -80,7 +79,7 @@ public function preProcess() {
/* only subtract dupes from successful import if we're skipping */

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$conflictRowCount - $duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
$duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -91,8 +90,6 @@ public function preProcess() {
'invalidRowCount',
'validSoftCreditRowCount',
'invalidSoftCreditRowCount',
'conflictRowCount',
'downloadConflictRecordsUrl',
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
Expand Down
Loading

0 comments on commit da8d3d4

Please sign in to comment.