Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
CustomFieldsInstructionData.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
42  {
47  const ADD_MISSING_VALUES = 'Add missing value';
48 
54  const MAP_MISSING_VALUES = 'Map missing value';
55 
59  protected $missingValuesToAdd = array();
60 
64  protected $missingValuesToMap = array();
65 
69  public function getMissingValuesToAdd()
70  {
71  return $this->missingValuesToAdd;
72  }
73 
77  public function getMissingValuesToMap()
78  {
79  return $this->missingValuesToMap;
80  }
81 
86  public function hasDataByColumnName($columnName)
87  {
88  assert('is_string($columnName)');
89  if ((isset($this->missingValuesToAdd[$columnName]) && !empty($this->missingValuesToAdd[$columnName])) ||
90  (isset($this->missingValuesToMap[$columnName]) && !empty($this->missingValuesToMap[$columnName])))
91  {
92  return true;
93  }
94  return false;
95  }
96 
101  public function getDataByColumnName($columnName)
102  {
103  assert('is_string($columnName)');
104  $data = array();
105  if (isset($this->missingValuesToAdd[$columnName]))
106  {
107  $data[static::ADD_MISSING_VALUES] = $this->missingValuesToAdd[$columnName];
108  }
109  if (isset($this->missingValuesToMap[$columnName]))
110  {
111  $data[static::MAP_MISSING_VALUES] = $this->missingValuesToMap[$columnName];
112  }
113  return $data;
114  }
115 
120  public function addMissingValuesByColumnName(array $missingCustomFieldValues, $columnName)
121  {
122  assert('is_array($missingCustomFieldValues)');
123  assert('is_string($columnName)');
124  foreach ($missingCustomFieldValues as $missingCustomFieldValue)
125  {
126  $this->resolveMissingValueToAdd($missingCustomFieldValue, $columnName);
127  }
128  }
129 
135  public function addByInstructionsDataAndColumnName($instructionsData, $columnName)
136  {
137  assert('is_string($columnName)');
138  if (isset($instructionsData[static::ADD_MISSING_VALUES]))
139  {
140  foreach ($instructionsData[static::ADD_MISSING_VALUES] as $missingValueToAdd)
141  {
142  $this->resolveMissingValueToAdd($missingValueToAdd, $columnName);
143  }
144  }
145  if (isset($instructionsData[static::MAP_MISSING_VALUES]))
146  {
147  foreach ($instructionsData[static::MAP_MISSING_VALUES] as $missingValueToMap => $mapToValue)
148  {
149  $this->resolveMissingValueToMap($missingValueToMap, $mapToValue, $columnName);
150  }
151  }
152  }
153 
158  public function resolveForNewData(CustomFieldsInstructionData $newInstructionsData)
159  {
160  foreach ($newInstructionsData->getMissingValuesToAdd() as $columnName => $columnData)
161  {
162  foreach ($columnData as $missingValueToAdd)
163  {
164  $this->resolveMissingValueToAdd($missingValueToAdd, $columnName);
165  }
166  }
167  foreach ($newInstructionsData->getMissingValuesToMap() as $columnName => $columnData)
168  {
169  foreach ($columnData as $missingValueToMap => $mapToValue)
170  {
171  $this->resolveMissingValueToMap($missingValueToMap, $mapToValue, $columnName);
172  }
173  }
174  }
175 
176  protected function resolveMissingValueToAdd($missingCustomFieldValue, $columnName)
177  {
178  assert('is_string($missingCustomFieldValue) || is_numeric($missingCustomFieldValue)');
179  assert('is_string($columnName)');
180  if (!isset($this->missingValuesToAdd[$columnName]))
181  {
182  $this->missingValuesToAdd[$columnName] = array();
183  }
184  if (!in_array($missingCustomFieldValue, $this->missingValuesToAdd[$columnName]))
185  {
186  $this->missingValuesToAdd[$columnName][] = $missingCustomFieldValue;
187  }
188  }
189 
195  protected function resolveMissingValueToMap($missingCustomFieldValue, $mapToValue, $columnName)
196  {
197  assert('is_string($missingCustomFieldValue) || is_numeric($missingCustomFieldValue)');
198  assert('is_string($mapToValue)');
199  assert('is_string($columnName)');
200  if (!isset($this->missingValuesToMap[$columnName]))
201  {
202  $this->missingValuesToMap[$columnName] = array();
203  }
204  $this->missingValuesToMap[$columnName][$missingCustomFieldValue] = $mapToValue;
205  }
206  }
207 ?>
addMissingValuesByColumnName(array $missingCustomFieldValues, $columnName)
resolveForNewData(CustomFieldsInstructionData $newInstructionsData)
addByInstructionsDataAndColumnName($instructionsData, $columnName)
resolveMissingValueToMap($missingCustomFieldValue, $mapToValue, $columnName)
Generated on Tue Jul 7 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.