/**
  * @see DataAnalyzerInterface::runAndMakeMessages()
  */
 public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     assert('is_string($columnName)');
     $customFieldData = CustomFieldDataModelUtil::getDataByModelClassNameAndAttributeName($this->modelClassName, $this->attributeName);
     $dropDownValues = unserialize($customFieldData->serializedData);
     $dropDownValues = ArrayUtil::resolveArrayToLowerCase($dropDownValues);
     $data = $dataProvider->getCountDataByGroupByColumnName($columnName);
     $count = 0;
     $missingDropDowns = null;
     foreach ($data as $valueCountData) {
         if ($valueCountData[$columnName] == null) {
             continue;
         }
         if ($missingDropDowns != null) {
             $lowerCaseMissingValuesToMap = ArrayUtil::resolveArrayToLowerCase($missingDropDowns);
         } else {
             $lowerCaseMissingValuesToMap = array();
         }
         if (!in_array(strtolower($valueCountData[$columnName]), $dropDownValues) && !in_array(strtolower($valueCountData[$columnName]), $lowerCaseMissingValuesToMap)) {
             $missingDropDowns[] = $valueCountData[$columnName];
             $count++;
         }
     }
     if ($count > 0) {
         $label = '{count} dropdown value(s) are missing from the field. ';
         $label .= 'These values will be added upon import.';
         $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count)));
     }
     if ($missingDropDowns != null) {
         $instructionsData = array(DropDownSanitizerUtil::ADD_MISSING_VALUE => $missingDropDowns);
         $this->setInstructionsData($instructionsData);
     }
 }
 /**
  * @see DataAnalyzerInterface::runAndMakeMessages()
  */
 public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     $acceptableValues = BooleanSanitizerUtil::getAcceptableValues();
     $inPart = SQLOperatorUtil::resolveOperatorAndValueForOneOf('oneOf', $acceptableValues);
     $where = DatabaseCompatibilityUtil::lower($columnName) . ' NOT ' . $inPart;
     $count = $dataProvider->getCountByWhere($where);
     if ($count > 0) {
         $label = '{count} value(s) have invalid check box values. ';
         $label .= 'These values will be set to false upon import.';
         $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count)));
     }
 }
 /**
  * @see DataAnalyzerInterface::runAndMakeMessages()
  */
 public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     assert('is_string($columnName)');
     assert('is_string($this->attributeName)');
     $minLength = $this->resolveMinLength($this->modelClassName, $this->attributeName);
     if ($minLength == null) {
         return;
     }
     $where = static::resolvColumnNameSqlLengthFunction($columnName) . ' < ' . $minLength;
     $count = $dataProvider->getCountByWhere($where);
     if ($count > 0) {
         $label = '{count} value(s) are too short for this field. ';
         $label .= 'These rows will be skipped during import.';
         $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count, '{length}' => $minLength)));
     }
 }
 /**
  * Given a data provider and a column name, process over all the rows and analyze the column specified by
  * column name.  After the data is processed any messages required are made and added to the messages array.
  * @param object $dataProvider
  * @param string $columnName
  */
 protected function processAndMakeMessage(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     assert('is_string($columnName)');
     $page = 0;
     $itemsProcessed = 0;
     $totalItemCount = $dataProvider->getTotalItemCount(true);
     $dataProvider->getPagination()->setCurrentPage($page);
     while (null != ($data = $dataProvider->getData(true))) {
         foreach ($data as $rowData) {
             $this->analyzeByValue($rowData->{$columnName});
             $itemsProcessed++;
         }
         if ($itemsProcessed < $totalItemCount) {
             $page++;
             $dataProvider->getPagination()->setCurrentPage($page);
         } else {
             break;
         }
     }
     $this->makeMessages();
 }
 public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     assert('is_string($columnName)');
     $dropDownValues = $this->resolveStates();
     $dropDownValues = ArrayUtil::resolveArrayToLowerCase($dropDownValues);
     $data = $dataProvider->getCountDataByGroupByColumnName($columnName);
     $count = 0;
     foreach ($data as $valueCountData) {
         if ($valueCountData[$columnName] == null) {
             continue;
         }
         if (!in_array(strtolower($valueCountData[$columnName]), $dropDownValues)) {
             $count++;
         }
     }
     if ($count > 0) {
         $label = '{count} value(s) are not valid. ';
         $label .= 'Rows that have these values will be skipped during import.';
         $this->addMessage(Zurmo::t('ContactsModule', $label, array('{count}' => $count)));
     }
 }
 /**
  * @see LinkedToMappingRuleDataAnalyzerInterface::runAndMakeMessages()
  */
 public function runAndMakeMessages(AnalyzerSupportedDataProvider $dataProvider, $columnName, $mappingRuleType, $mappingRuleData)
 {
     assert('is_string($columnName)');
     assert('is_array($mappingRuleData)');
     $modelClassName = $this->modelClassName;
     $model = new $modelClassName(false);
     if (!$model->isAttributeRequired($this->attributeName)) {
         return false;
     }
     $mappingRuleFormClassName = $mappingRuleType . 'MappingRuleForm';
     $defaultValueAttributeName = $mappingRuleFormClassName::getAttributeName();
     if ($mappingRuleData[$defaultValueAttributeName] != null) {
         return;
     }
     $where = $columnName . ' IS NULL OR ' . $columnName . "=''";
     // Not Coding Standard
     $count = $dataProvider->getCountByWhere($where);
     if ($count > 0) {
         $label = '{count} value(s) are missing and are required. ';
         $label .= 'These rows will be skipped on import.';
         $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count)));
     }
 }
 /**
  * Check whether the specified value corresponds to a valid username of a user model.
  * @param AnalyzerSupportedDataProvider $dataProvider
  * @param string $columnName
  */
 protected function resolveForTypeUsername(AnalyzerSupportedDataProvider $dataProvider, $columnName)
 {
     assert('is_string($columnName)');
     $usernameValues = UserValueTypeSanitizerUtil::getUsernames();
     $usernameValues = ArrayUtil::resolveArrayToLowerCase($usernameValues);
     $data = $dataProvider->getCountDataByGroupByColumnName($columnName);
     $count = 0;
     foreach ($data as $valueCountData) {
         if ($valueCountData[$columnName] == null) {
             continue;
         }
         if (!in_array(TextUtil::strToLowerWithDefaultEncoding($valueCountData[$columnName]), $usernameValues)) {
             $count++;
         }
     }
     if ($count > 0) {
         $label = '{count} username(s) specified were not found. ';
         $label .= 'These values will not be used during the import.';
         $this->addMessage(Zurmo::t('ImportModule', $label, array('{count}' => $count)));
     }
 }