@@ 51-113 (lines=63) @@ | ||
48 | /** |
|
49 | * @param EventImportedFromUDB2 $eventImportedFromUDB2 |
|
50 | */ |
|
51 | protected function applyEventImportedFromUDB2( |
|
52 | EventImportedFromUDB2 $eventImportedFromUDB2 |
|
53 | ) { |
|
54 | $itemId = $eventImportedFromUDB2->getEventId(); |
|
55 | $udb2Event = EventItemFactory::createEventFromCdbXml( |
|
56 | $eventImportedFromUDB2->getCdbXmlNamespaceUri(), |
|
57 | $eventImportedFromUDB2->getCdbXml() |
|
58 | ); |
|
59 | ||
60 | $itemType = EntityType::EVENT(); |
|
61 | ||
62 | $udb2EventAdapter = $this->itemBaseAdapterFactory->create($udb2Event); |
|
63 | ||
64 | $userId = $udb2EventAdapter->getResolvedCreatorUserId(); |
|
65 | ||
66 | /** @var \CultureFeed_Cdb_Data_EventDetail $detail */ |
|
67 | $detail = null; |
|
68 | $postalCode = ''; |
|
69 | $country = ''; |
|
70 | ||
71 | $details = $udb2Event->getDetails(); |
|
72 | foreach ($details as $languageDetail) { |
|
73 | // The first language detail found will be used. |
|
74 | $detail = $languageDetail; |
|
75 | break; |
|
76 | } |
|
77 | ||
78 | $name = trim($detail->getTitle()); |
|
79 | ||
80 | // Ignore items without a name. They might occur in UDB2 although this |
|
81 | // is not considered normal. |
|
82 | if (empty($name)) { |
|
83 | return; |
|
84 | } |
|
85 | ||
86 | $contact_cdb = $udb2Event->getContactInfo(); |
|
87 | if ($contact_cdb) { |
|
88 | $addresses = $contact_cdb->getAddresses(); |
|
89 | ||
90 | /** @var \CultureFeed_Cdb_Data_Address $address */ |
|
91 | foreach ($addresses as $address) { |
|
92 | /** @var \CultureFeed_Cdb_Data_Address_PhysicalAddress $physicalAddress */ |
|
93 | $physicalAddress = $address->getPhysicalAddress(); |
|
94 | if ($physicalAddress) { |
|
95 | $postalCode = $physicalAddress->getZip(); |
|
96 | $country = $physicalAddress->getCountry(); |
|
97 | } |
|
98 | } |
|
99 | } |
|
100 | ||
101 | $creationDate = $udb2EventAdapter->getCreationDateTime(); |
|
102 | ||
103 | $this->repository->updateIndex( |
|
104 | $itemId, |
|
105 | $itemType, |
|
106 | (string) $userId, |
|
107 | $name, |
|
108 | $postalCode, |
|
109 | $country, |
|
110 | $this->UDB2Domain, |
|
111 | $creationDate |
|
112 | ); |
|
113 | } |
|
114 | ||
115 | /** |
|
116 | * @param PlaceImportedFromUDB2 $placeImportedFromUDB2 |
|
@@ 118-176 (lines=59) @@ | ||
115 | /** |
|
116 | * @param PlaceImportedFromUDB2 $placeImportedFromUDB2 |
|
117 | */ |
|
118 | protected function applyPlaceImportedFromUDB2(PlaceImportedFromUDB2 $placeImportedFromUDB2) |
|
119 | { |
|
120 | $placeId = $placeImportedFromUDB2->getActorId(); |
|
121 | /** @var \CultureFeed_Cdb_Data_ActorDetail $detail */ |
|
122 | $detail = null; |
|
123 | $postalCode = ''; |
|
124 | $country = ''; |
|
125 | ||
126 | $udb2Actor = ActorItemFactory::createActorFromCdbXml( |
|
127 | $placeImportedFromUDB2->getCdbXmlNamespaceUri(), |
|
128 | $placeImportedFromUDB2->getCdbXml() |
|
129 | ); |
|
130 | ||
131 | $udb2ActorAdapter = $this->itemBaseAdapterFactory->create($udb2Actor); |
|
132 | ||
133 | $userId = $udb2ActorAdapter->getResolvedCreatorUserId(); |
|
134 | ||
135 | $details = $udb2Actor->getDetails(); |
|
136 | foreach ($details as $languageDetail) { |
|
137 | // The first language detail found will be used. |
|
138 | $detail = $languageDetail; |
|
139 | break; |
|
140 | } |
|
141 | ||
142 | $name = trim($detail->getTitle()); |
|
143 | ||
144 | // Ignore items without a name. They might occur in UDB2 although this |
|
145 | // is not considered normal. |
|
146 | if (empty($name)) { |
|
147 | return; |
|
148 | } |
|
149 | ||
150 | $contact_cdb = $udb2Actor->getContactInfo(); |
|
151 | if ($contact_cdb) { |
|
152 | $addresses = $contact_cdb->getAddresses(); |
|
153 | ||
154 | /** @var \CultureFeed_Cdb_Data_Address $address */ |
|
155 | foreach ($addresses as $address) { |
|
156 | $physicalAddress = $address->getPhysicalAddress(); |
|
157 | if ($physicalAddress) { |
|
158 | $postalCode = $physicalAddress->getZip(); |
|
159 | $country = $physicalAddress->getCountry(); |
|
160 | } |
|
161 | } |
|
162 | } |
|
163 | ||
164 | $creationDate = $udb2ActorAdapter->getCreationDateTime(); |
|
165 | ||
166 | $this->repository->updateIndex( |
|
167 | $placeId, |
|
168 | EntityType::PLACE(), |
|
169 | $userId, |
|
170 | $name, |
|
171 | $postalCode, |
|
172 | $country, |
|
173 | $this->UDB2Domain, |
|
174 | $creationDate |
|
175 | ); |
|
176 | } |
|
177 | } |
|
178 |