MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
unidirectionalassociationmap.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 private $targetName;
6 private $databaseMap;
7 private $forClass;
8 private $associativeClass;
9 private $cardinality;
10 private $deleteAutomatic = FALSE;
11 private $retrieveAutomatic = FALSE;
12 private $saveAutomatic = FALSE;
13 private $joinAutomatic = FALSE;
14 private $inverse = FALSE;
15 private $entries = array();
16 private $direction = array();
17 private $orderAttributes = NULL;
18 private $indexAttribute;
19
20 public function __construct()
21 {
22 $this->inverse = FALSE;
23 }
24
25 public function setForClass(&$classMap)
26 {
27 $this->forClass = $classMap;
28 }
29
30 public function getForClass()
31 {
32 return $this->forClass;
33 }
34
35 public function setAssociativeClass(&$classMap)
36 {
37 $this->associativeClass = $classMap;
38 }
39
40 public function getAssociativeClass()
41 {
42 return $this->associativeClass;
43 }
44
45 public function setTargetName($name)
46 {
47 $this->targetName = $name;
48 }
49
50 public function getTargetName()
51 {
52 return $this->targetName;
53 }
54
55 public function setTarget($attributeMap)
56 {
57 $this->target = $attributeMap;
58 }
59
60 public function getTarget()
61 {
62 return $this->target;
63 }
64
65 public function setOrderAttributes($orderAttributes)
66 {
67 $this->orderAttributes = $orderAttributes;
68 }
69
70 public function getOrderAttributes()
71 {
72 return $this->orderAttributes;
73 }
74
75 public function setIndexAttribute($indexAttribute)
76 {
77 $this->indexAttribute = $indexAttribute;
78 }
79
80 public function getIndexAttribute()
81 {
82 return $this->indexAttribute;
83 }
84
85 public function setDeleteAutomatic($value = NULL)
86 {
87 if ($value === NULL)
88 $value = FALSE;
89
90 $this->deleteAutomatic = ($value == 'true');
91 }
92
93 public function setRetrieveAutomatic($value = NULL)
94 {
95 if ($value === NULL)
96 $value = FALSE;
97
98 $this->retrieveAutomatic = ($value == 'true');
99 }
100
101 public function setSaveAutomatic($value = NULL)
102 {
103 if ($value === NULL)
104 $value = FALSE;
105
106 $this->saveAutomatic = ($value == 'true');
107 }
108
109 public function setJoinAutomatic($value = NULL)
110 {
111 if ($value === NULL)
112 $value = FALSE;
113
114 if ($value === TRUE)
115 $value = 'inner';
116
117 $this->joinAutomatic = $value;
118 }
119
120 public function setInverse($value = NULL)
121 {
122 if ($value === NULL)
123 $value = FALSE;
124
125 $this->inverse = ($value == 'true') || ($value === TRUE);
126 }
127
128 public function isDeleteAutomatic()
129 {
130 return $this->deleteAutomatic;
131 }
132
133 public function isRetrieveAutomatic()
134 {
135 return $this->retrieveAutomatic;
136 }
137
138 public function isSaveAutomatic()
139 {
140 return $this->saveAutomatic;
141 }
142
143 public function isJoinAutomatic()
144 {
145 return $this->joinAutomatic;
146 }
147
148 public function getJoinAutomatic()
149 {
150 return $this->joinAutomatic;
151 }
152
153 public function isInverse()
154 {
155 return $this->inverse;
156 }
157
158 public function setCardinality($value = NULL)
159 {
160 if ($value === NULL)
161 $value = 'oneToOne';
162
163 $this->cardinality = $value;
164 }
165
166 public function getCardinality()
167 {
168 return $this->cardinality;
169 }
170
171 public function addEntry(&$udaEntry)
172 {
173 $this->entries[] = $udaEntry;
174 }
175
176 public function getEntry($index)
177 {
178 return $this->entries[$index];
179 }
180
181 public function addDirection($direction)
182 {
183 $this->direction[] = $direction;
184 }
185
186 public function getDirection()
187 {
188 return $this->direction;
189 }
190
191 public function getSize()
192 {
193 return count($this->entries);
194 }
195
196 public function getCriteria($orderAttrs, $manager)
197 {
198 $criteria = new RetrieveCriteria($this->forClass, $manager);
199
200 if ($this->cardinality == 'manyToMany')
201 {
202 $criteria->addAssociationMap($this->associativeClass, $this->direction[0], TRUE);
203 $criteria->addAssociationMap($this->associativeClass, $this->direction[1], FALSE);
204 $aMap = $this->associativeClass->getAssociationMap($this->direction[0]);
205 $n = $aMap->getSize();
206 for ($i = 0; $i < $n; $i++)
207 {
208 $criteria->addCriteria($aMap->getEntry($i)->getFrom(), '=', '?');
209 }
210 }
211 else
212 {
213 $n = $this->getSize();
214 if ($this->isInverse())
215 {
216 for ($i = 0; $i < $n; $i++)
217 {
218 $criteria->addCriteria($this->getEntry($i)->getFrom()->getName(), '=', '?');
219 }
220 }
221 else
222 {
223 for ($i = 0; $i < $n; $i++)
224 {
225 $criteria->addCriteria($this->getEntry($i)->getTo()->getName(), '=', '?');
226 }
227 }
228 }
229
230 if (count($this->orderAttributes))
231 {
232 foreach ($this->orderAttributes as $order)
233 {
234 $criteria->addOrderEntry($order);
235 }
236 }
237
238 return $criteria;
239 }
240
241 public function getCriteriaParameters($object)
242 {
243 $criteriaParameters = array();
244 if ($this->cardinality == 'manyToMany')
245 {
246 $aMap = $this->associativeClass->getAssociationMap($this->direction[0]);
247 $n = $aMap->getSize();
248 for ($i = 0; $i < $n; $i++)
249 {
250 $criteriaParameters[] = $aMap->getEntry($i)->getFrom()->getValue($object);
251 }
252 }
253 else
254 {
255 $n = $this->getSize();
256 if ($this->isInverse())
257 {
258 for ($i = 0; $i < $n; $i++)
259 {
260 $criteriaParameters[] = $this->getEntry($i)->getTo()->getValue($object);
261 }
262 }
263 else
264 {
265 for ($i = 0; $i < $n; $i++)
266 {
267 $criteriaParameters[] = $this->getEntry($i)->getFrom()->getValue($object);
268 }
269 }
270 }
271 return $criteriaParameters;
272 }
273}
274?>