Ejemplo n.º 1
0
 private function createDuplicate(array &$fields)
 {
     $rootEntityID = isset($fields['ROOT_ENTITY_ID']) ? (int) $fields['ROOT_ENTITY_ID'] : 0;
     $typeID = isset($fields['TYPE_ID']) ? (int) $fields['TYPE_ID'] : 0;
     $matches = isset($fields['MATCHES']) ? $fields['MATCHES'] : '';
     $matches = $matches !== '' ? unserialize($matches) : array();
     $quantity = isset($fields['QUANTITY']) ? (int) $fields['QUANTITY'] : 0;
     $result = new Duplicate(DuplicateManager::createCriterion($typeID, $matches), array());
     $result->setRootEntityID($rootEntityID);
     $isJunk = isset($fields['IS_JUNK']) && strtoupper($fields['IS_JUNK']) === 'Y';
     if ($isJunk) {
         $result->markAsJunk(true);
         //Try to supply more information for junked item (if root entity is already deleted)
         $rootPersName = isset($fields['ROOT_ENTITY_NAME']) ? $fields['ROOT_ENTITY_NAME'] : '';
         if ($rootPersName !== '') {
             $names = explode(' ', $rootPersName);
             $qty = count($names);
             for ($i = 0; $i < $qty; $i++) {
                 $names[$i] = ucfirst($names[$i]);
             }
             $result->setRootPersonName(implode(' ', $names));
         }
         $rootOrgTitle = isset($fields['ROOT_ENTITY_TITLE']) ? $fields['ROOT_ENTITY_TITLE'] : '';
         if ($rootOrgTitle !== '') {
             $result->setRootOrganizationTitle(ucfirst($rootOrgTitle));
         }
     }
     $result->setTotalEntityCount($quantity);
     return $result;
 }
Ejemplo n.º 2
0
 protected function processEntityDeletion($entityTypeID, $entityID, array &$matchByType)
 {
     foreach ($matchByType as $typeID => &$typeMatches) {
         foreach ($typeMatches as &$matches) {
             $builder = Integrity\DuplicateManager::createIndexBuilder($typeID, $entityTypeID, $this->userID, $this->enablePermissionCheck);
             $builder->processEntityDeletion(Integrity\DuplicateManager::createCriterion($typeID, $matches), $entityID);
         }
         unset($matches);
     }
     unset($typeMatches);
 }
Ejemplo n.º 3
0
        __CrmDedupeListEndResonse(array('ERROR' => 'Left entity ID is not is not specified.'));
    }
    $rightEntityID = isset($_POST['RIGHT_ENTITY_ID']) ? (int) $_POST['RIGHT_ENTITY_ID'] : 0;
    if ($rightEntityID <= 0) {
        __CrmDedupeListEndResonse(array('ERROR' => 'Right entity ID is not is not specified.'));
    }
    $typeID = isset($_POST['INDEX_TYPE_NAME']) ? Integrity\DuplicateIndexType::resolveID($_POST['INDEX_TYPE_NAME']) : Integrity\DuplicateIndexType::UNDEFINED;
    if (!Integrity\DuplicateIndexType::isDefined($typeID)) {
        __CrmDedupeListEndResonse(array('ERROR' => 'Index type ID is not specified or invalid.'));
    }
    $enablePermissionCheck = !CCrmPerms::IsAdmin($currentUserID);
    $merger = Merger\EntityMerger::create($entityTypeID, $currentUserID, $enablePermissionCheck);
    $leftEntityMatches = isset($_POST['LEFT_ENTITY_INDEX_MATCHES']) && is_array($_POST['LEFT_ENTITY_INDEX_MATCHES']) ? $_POST['LEFT_ENTITY_INDEX_MATCHES'] : array();
    $leftEntityCriterion = Integrity\DuplicateManager::createCriterion($typeID, $leftEntityMatches);
    $rightEntityMatches = isset($_POST['RIGHT_ENTITY_INDEX_MATCHES']) && is_array($_POST['RIGHT_ENTITY_INDEX_MATCHES']) ? $_POST['RIGHT_ENTITY_INDEX_MATCHES'] : array();
    if (empty($rightEntityMatches)) {
        $rightEntityMatches = $leftEntityMatches;
    }
    $rightEntityCriterion = Integrity\DuplicateManager::createCriterion($typeID, $rightEntityMatches);
    try {
        $merger->registerCriterionMismatch($rightEntityCriterion, $leftEntityID, $rightEntityID);
        $builder = Integrity\DuplicateManager::createIndexBuilder($typeID, $entityTypeID, $currentUserID, $enablePermissionCheck);
        $builder->processMismatchRegistration($leftEntityCriterion, $leftEntityID);
    } catch (Merger\EntityMergerException $e) {
        __CrmDedupeListEndResonse(array('ERROR' => __CrmDedupeListErrorText($e)));
    } catch (Exception $e) {
        __CrmDedupeListEndResonse(array('ERROR' => $e->getMessage()));
    }
    $totalsText = $leftEntityCriterion->getTextTotals($leftEntityCriterion->getActualCount($entityTypeID, $leftEntityID, $currentUserID, $enablePermissionCheck, 51), 50);
    __CrmDedupeListEndResonse(array('LEFT_ENTITY_ID' => $leftEntityID, 'RIGHT_ENTITY_ID' => $rightEntityID, 'TEXT_TOTALS' => $totalsText));
}