001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.party.impl;
008
009 import java.util.Collection;
010 import java.util.concurrent.atomic.AtomicInteger;
011
012 import org.eclipse.emf.common.notify.Notification;
013 import org.eclipse.emf.common.notify.NotificationChain;
014 import org.eclipse.emf.common.util.BasicEList;
015 import org.eclipse.emf.common.util.EList;
016 import org.eclipse.emf.ecore.EClass;
017 import org.eclipse.emf.ecore.InternalEObject;
018 import org.eclipse.emf.ecore.impl.ENotificationImpl;
019 import org.eclipse.emf.ecore.impl.EObjectImpl;
020 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
021 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
022 import org.eclipse.emf.ecore.util.EcoreUtil;
023 import org.eclipse.emf.ecore.util.InternalEList;
024
025 import com.hammurapi.party.ContactInfo;
026 import com.hammurapi.party.Identity;
027 import com.hammurapi.party.MatrixRelationship;
028 import com.hammurapi.party.Organization;
029 import com.hammurapi.party.Party;
030 import com.hammurapi.party.PartyPackage;
031 import com.hammurapi.party.Person;
032 import com.hammurapi.party.Tag;
033
034 /**
035 * <!-- begin-user-doc -->
036 * An implementation of the model object '<em><b>Person</b></em>'.
037 * <!-- end-user-doc -->
038 * <p>
039 * The following features are implemented:
040 * <ul>
041 * <li>{@link com.hammurapi.party.impl.PersonImpl#getTags <em>Tags</em>}</li>
042 * <li>{@link com.hammurapi.party.impl.PersonImpl#getComment <em>Comment</em>}</li>
043 * <li>{@link com.hammurapi.party.impl.PersonImpl#getContactInfo <em>Contact Info</em>}</li>
044 * <li>{@link com.hammurapi.party.impl.PersonImpl#getIdentity <em>Identity</em>}</li>
045 * <li>{@link com.hammurapi.party.impl.PersonImpl#getParent <em>Parent</em>}</li>
046 * <li>{@link com.hammurapi.party.impl.PersonImpl#getName <em>Name</em>}</li>
047 * <li>{@link com.hammurapi.party.impl.PersonImpl#getUid <em>Uid</em>}</li>
048 * <li>{@link com.hammurapi.party.impl.PersonImpl#getTitle <em>Title</em>}</li>
049 * </ul>
050 * </p>
051 *
052 * @generated
053 */
054 public class PersonImpl extends EObjectImpl implements Person {
055 /**
056 * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
057 * <!-- begin-user-doc -->
058 * <!-- end-user-doc -->
059 * @see #getTags()
060 * @generated
061 * @ordered
062 */
063 protected EList<Tag> tags;
064
065 /**
066 * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
067 * <!-- begin-user-doc -->
068 * <!-- end-user-doc -->
069 * @see #getComment()
070 * @generated
071 * @ordered
072 */
073 protected static final String COMMENT_EDEFAULT = null;
074
075 /**
076 * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
077 * <!-- begin-user-doc -->
078 * <!-- end-user-doc -->
079 * @see #getComment()
080 * @generated
081 * @ordered
082 */
083 protected String comment = COMMENT_EDEFAULT;
084
085 /**
086 * The cached value of the '{@link #getContactInfo() <em>Contact Info</em>}' containment reference list.
087 * <!-- begin-user-doc -->
088 * <!-- end-user-doc -->
089 * @see #getContactInfo()
090 * @generated
091 * @ordered
092 */
093 protected EList<ContactInfo> contactInfo;
094
095 /**
096 * The cached value of the '{@link #getIdentity() <em>Identity</em>}' containment reference list.
097 * <!-- begin-user-doc -->
098 * <!-- end-user-doc -->
099 * @see #getIdentity()
100 * @generated
101 * @ordered
102 */
103 protected EList<Identity> identity;
104
105 /**
106 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
107 * <!-- begin-user-doc -->
108 * <!-- end-user-doc -->
109 * @see #getName()
110 * @generated
111 * @ordered
112 */
113 protected static final String NAME_EDEFAULT = null;
114
115 /**
116 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
117 * <!-- begin-user-doc -->
118 * <!-- end-user-doc -->
119 * @see #getName()
120 * @generated
121 * @ordered
122 */
123 protected String name = NAME_EDEFAULT;
124
125 /**
126 * The default value of the '{@link #getUid() <em>Uid</em>}' attribute.
127 * <!-- begin-user-doc -->
128 * <!-- end-user-doc -->
129 * @see #getUid()
130 * @generated
131 * @ordered
132 */
133 protected static final String UID_EDEFAULT = null;
134
135 /**
136 * The cached value of the '{@link #getUid() <em>Uid</em>}' attribute.
137 * <!-- begin-user-doc -->
138 * <!-- end-user-doc -->
139 * @see #getUid()
140 * @generated
141 * @ordered
142 */
143 protected String uid = UID_EDEFAULT;
144
145 /**
146 * The default value of the '{@link #getTitle() <em>Title</em>}' attribute.
147 * <!-- begin-user-doc -->
148 * <!-- end-user-doc -->
149 * @see #getTitle()
150 * @generated
151 * @ordered
152 */
153 protected static final String TITLE_EDEFAULT = null;
154
155 /**
156 * The cached value of the '{@link #getTitle() <em>Title</em>}' attribute.
157 * <!-- begin-user-doc -->
158 * <!-- end-user-doc -->
159 * @see #getTitle()
160 * @generated
161 * @ordered
162 */
163 protected String title = TITLE_EDEFAULT;
164
165 private Organization externalParent;
166
167 private static AtomicInteger counter = new AtomicInteger();
168
169 /**
170 * <!-- begin-user-doc -->
171 * <!-- end-user-doc -->
172 * @generated NOT
173 */
174 protected PersonImpl() {
175 super();
176 if (getUid()==null) {
177 setUid("PERSON-"+Integer.toString(counter.incrementAndGet(), Character.MAX_RADIX)+"-"+Long.toString(System.currentTimeMillis(), Character.MAX_RADIX));
178 }
179 }
180
181 /**
182 * <!-- begin-user-doc -->
183 * <!-- end-user-doc -->
184 * @generated
185 */
186 @Override
187 protected EClass eStaticClass() {
188 return PartyPackage.Literals.PERSON;
189 }
190
191 /**
192 * <!-- begin-user-doc -->
193 * <!-- end-user-doc -->
194 * @generated
195 */
196 public EList<Tag> getTags() {
197 if (tags == null) {
198 tags = new EObjectContainmentEList<Tag>(Tag.class, this, PartyPackage.PERSON__TAGS);
199 }
200 return tags;
201 }
202
203 /**
204 * <!-- begin-user-doc -->
205 * <!-- end-user-doc -->
206 * @generated
207 */
208 public String getComment() {
209 return comment;
210 }
211
212 /**
213 * <!-- begin-user-doc -->
214 * <!-- end-user-doc -->
215 * @generated
216 */
217 public void setComment(String newComment) {
218 String oldComment = comment;
219 comment = newComment;
220 if (eNotificationRequired())
221 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PERSON__COMMENT, oldComment, comment));
222 }
223
224 /**
225 * <!-- begin-user-doc -->
226 * <!-- end-user-doc -->
227 * @generated
228 */
229 public EList<ContactInfo> getContactInfo() {
230 if (contactInfo == null) {
231 contactInfo = new EObjectContainmentWithInverseEList<ContactInfo>(ContactInfo.class, this, PartyPackage.PERSON__CONTACT_INFO, PartyPackage.CONTACT_INFO__OWNER);
232 }
233 return contactInfo;
234 }
235
236 /**
237 * <!-- begin-user-doc -->
238 * <!-- end-user-doc -->
239 * @generated
240 */
241 public EList<Identity> getIdentity() {
242 if (identity == null) {
243 identity = new EObjectContainmentEList<Identity>(Identity.class, this, PartyPackage.PERSON__IDENTITY);
244 }
245 return identity;
246 }
247
248 /**
249 * <!-- begin-user-doc -->
250 * <!-- end-user-doc -->
251 * @generated
252 */
253 public Organization getParent() {
254 if (eContainerFeatureID() != PartyPackage.PERSON__PARENT) return null;
255 return (Organization)eContainer();
256 }
257
258 /**
259 * <!-- begin-user-doc -->
260 * <!-- end-user-doc -->
261 * @generated
262 */
263 public NotificationChain basicSetParent(Organization newParent, NotificationChain msgs) {
264 msgs = eBasicSetContainer((InternalEObject)newParent, PartyPackage.PERSON__PARENT, msgs);
265 return msgs;
266 }
267
268 /**
269 * <!-- begin-user-doc -->
270 * <!-- end-user-doc -->
271 * @generated
272 */
273 public void setParent(Organization newParent) {
274 if (newParent != eInternalContainer() || (eContainerFeatureID() != PartyPackage.PERSON__PARENT && newParent != null)) {
275 if (EcoreUtil.isAncestor(this, newParent))
276 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
277 NotificationChain msgs = null;
278 if (eInternalContainer() != null)
279 msgs = eBasicRemoveFromContainer(msgs);
280 if (newParent != null)
281 msgs = ((InternalEObject)newParent).eInverseAdd(this, PartyPackage.ORGANIZATION__CHILDREN, Organization.class, msgs);
282 msgs = basicSetParent(newParent, msgs);
283 if (msgs != null) msgs.dispatch();
284 }
285 else if (eNotificationRequired())
286 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PERSON__PARENT, newParent, newParent));
287 }
288
289 /**
290 * <!-- begin-user-doc -->
291 * <!-- end-user-doc -->
292 * @generated
293 */
294 public String getName() {
295 return name;
296 }
297
298 /**
299 * <!-- begin-user-doc -->
300 * <!-- end-user-doc -->
301 * @generated
302 */
303 public void setName(String newName) {
304 String oldName = name;
305 name = newName;
306 if (eNotificationRequired())
307 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PERSON__NAME, oldName, name));
308 }
309
310 /**
311 * <!-- begin-user-doc -->
312 * <!-- end-user-doc -->
313 * @generated
314 */
315 public String getUid() {
316 return uid;
317 }
318
319 /**
320 * <!-- begin-user-doc -->
321 * <!-- end-user-doc -->
322 * @generated
323 */
324 public void setUid(String newUid) {
325 String oldUid = uid;
326 uid = newUid;
327 if (eNotificationRequired())
328 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PERSON__UID, oldUid, uid));
329 }
330
331 /**
332 * <!-- begin-user-doc -->
333 * <!-- end-user-doc -->
334 * @generated
335 */
336 public String getTitle() {
337 return title;
338 }
339
340 /**
341 * <!-- begin-user-doc -->
342 * <!-- end-user-doc -->
343 * @generated
344 */
345 public void setTitle(String newTitle) {
346 String oldTitle = title;
347 title = newTitle;
348 if (eNotificationRequired())
349 eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.PERSON__TITLE, oldTitle, title));
350 }
351
352 /**
353 * <!-- begin-user-doc -->
354 * <!-- end-user-doc -->
355 * @generated NOT
356 */
357 public EList<Party> getPath() {
358 EList<Party> ret;
359 if (getParent()!=null) {
360 ret = getParent().getPath();
361 } else if (externalParent!=null) {
362 ret = externalParent.getPath();
363 } else {
364 ret = new BasicEList<Party>();
365 }
366 ret.add(this);
367 return ret;
368 }
369
370 /**
371 * <!-- begin-user-doc -->
372 * <!-- end-user-doc -->
373 * @generated NOT
374 */
375 public void setExternalParent(Organization externalParent) {
376 this.externalParent = externalParent;
377 }
378
379 /**
380 * <!-- begin-user-doc -->
381 * <!-- end-user-doc -->
382 * @generated
383 */
384 @SuppressWarnings("unchecked")
385 @Override
386 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
387 switch (featureID) {
388 case PartyPackage.PERSON__CONTACT_INFO:
389 return ((InternalEList<InternalEObject>)(InternalEList<?>)getContactInfo()).basicAdd(otherEnd, msgs);
390 case PartyPackage.PERSON__PARENT:
391 if (eInternalContainer() != null)
392 msgs = eBasicRemoveFromContainer(msgs);
393 return basicSetParent((Organization)otherEnd, msgs);
394 }
395 return super.eInverseAdd(otherEnd, featureID, msgs);
396 }
397
398 /**
399 * <!-- begin-user-doc -->
400 * <!-- end-user-doc -->
401 * @generated
402 */
403 @Override
404 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
405 switch (featureID) {
406 case PartyPackage.PERSON__TAGS:
407 return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
408 case PartyPackage.PERSON__CONTACT_INFO:
409 return ((InternalEList<?>)getContactInfo()).basicRemove(otherEnd, msgs);
410 case PartyPackage.PERSON__IDENTITY:
411 return ((InternalEList<?>)getIdentity()).basicRemove(otherEnd, msgs);
412 case PartyPackage.PERSON__PARENT:
413 return basicSetParent(null, msgs);
414 }
415 return super.eInverseRemove(otherEnd, featureID, msgs);
416 }
417
418 /**
419 * <!-- begin-user-doc -->
420 * <!-- end-user-doc -->
421 * @generated
422 */
423 @Override
424 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
425 switch (eContainerFeatureID()) {
426 case PartyPackage.PERSON__PARENT:
427 return eInternalContainer().eInverseRemove(this, PartyPackage.ORGANIZATION__CHILDREN, Organization.class, msgs);
428 }
429 return super.eBasicRemoveFromContainerFeature(msgs);
430 }
431
432 /**
433 * <!-- begin-user-doc -->
434 * <!-- end-user-doc -->
435 * @generated
436 */
437 @Override
438 public Object eGet(int featureID, boolean resolve, boolean coreType) {
439 switch (featureID) {
440 case PartyPackage.PERSON__TAGS:
441 return getTags();
442 case PartyPackage.PERSON__COMMENT:
443 return getComment();
444 case PartyPackage.PERSON__CONTACT_INFO:
445 return getContactInfo();
446 case PartyPackage.PERSON__IDENTITY:
447 return getIdentity();
448 case PartyPackage.PERSON__PARENT:
449 return getParent();
450 case PartyPackage.PERSON__NAME:
451 return getName();
452 case PartyPackage.PERSON__UID:
453 return getUid();
454 case PartyPackage.PERSON__TITLE:
455 return getTitle();
456 }
457 return super.eGet(featureID, resolve, coreType);
458 }
459
460 /**
461 * <!-- begin-user-doc -->
462 * <!-- end-user-doc -->
463 * @generated
464 */
465 @SuppressWarnings("unchecked")
466 @Override
467 public void eSet(int featureID, Object newValue) {
468 switch (featureID) {
469 case PartyPackage.PERSON__TAGS:
470 getTags().clear();
471 getTags().addAll((Collection<? extends Tag>)newValue);
472 return;
473 case PartyPackage.PERSON__COMMENT:
474 setComment((String)newValue);
475 return;
476 case PartyPackage.PERSON__CONTACT_INFO:
477 getContactInfo().clear();
478 getContactInfo().addAll((Collection<? extends ContactInfo>)newValue);
479 return;
480 case PartyPackage.PERSON__IDENTITY:
481 getIdentity().clear();
482 getIdentity().addAll((Collection<? extends Identity>)newValue);
483 return;
484 case PartyPackage.PERSON__PARENT:
485 setParent((Organization)newValue);
486 return;
487 case PartyPackage.PERSON__NAME:
488 setName((String)newValue);
489 return;
490 case PartyPackage.PERSON__UID:
491 setUid((String)newValue);
492 return;
493 case PartyPackage.PERSON__TITLE:
494 setTitle((String)newValue);
495 return;
496 }
497 super.eSet(featureID, newValue);
498 }
499
500 /**
501 * <!-- begin-user-doc -->
502 * <!-- end-user-doc -->
503 * @generated
504 */
505 @Override
506 public void eUnset(int featureID) {
507 switch (featureID) {
508 case PartyPackage.PERSON__TAGS:
509 getTags().clear();
510 return;
511 case PartyPackage.PERSON__COMMENT:
512 setComment(COMMENT_EDEFAULT);
513 return;
514 case PartyPackage.PERSON__CONTACT_INFO:
515 getContactInfo().clear();
516 return;
517 case PartyPackage.PERSON__IDENTITY:
518 getIdentity().clear();
519 return;
520 case PartyPackage.PERSON__PARENT:
521 setParent((Organization)null);
522 return;
523 case PartyPackage.PERSON__NAME:
524 setName(NAME_EDEFAULT);
525 return;
526 case PartyPackage.PERSON__UID:
527 setUid(UID_EDEFAULT);
528 return;
529 case PartyPackage.PERSON__TITLE:
530 setTitle(TITLE_EDEFAULT);
531 return;
532 }
533 super.eUnset(featureID);
534 }
535
536 /**
537 * <!-- begin-user-doc -->
538 * <!-- end-user-doc -->
539 * @generated
540 */
541 @Override
542 public boolean eIsSet(int featureID) {
543 switch (featureID) {
544 case PartyPackage.PERSON__TAGS:
545 return tags != null && !tags.isEmpty();
546 case PartyPackage.PERSON__COMMENT:
547 return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
548 case PartyPackage.PERSON__CONTACT_INFO:
549 return contactInfo != null && !contactInfo.isEmpty();
550 case PartyPackage.PERSON__IDENTITY:
551 return identity != null && !identity.isEmpty();
552 case PartyPackage.PERSON__PARENT:
553 return getParent() != null;
554 case PartyPackage.PERSON__NAME:
555 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
556 case PartyPackage.PERSON__UID:
557 return UID_EDEFAULT == null ? uid != null : !UID_EDEFAULT.equals(uid);
558 case PartyPackage.PERSON__TITLE:
559 return TITLE_EDEFAULT == null ? title != null : !TITLE_EDEFAULT.equals(title);
560 }
561 return super.eIsSet(featureID);
562 }
563
564 /**
565 * <!-- begin-user-doc -->
566 * <!-- end-user-doc -->
567 * @generated
568 */
569 @Override
570 public String toString() {
571 if (eIsProxy()) return super.toString();
572
573 StringBuffer result = new StringBuffer(super.toString());
574 result.append(" (comment: ");
575 result.append(comment);
576 result.append(", name: ");
577 result.append(name);
578 result.append(", uid: ");
579 result.append(uid);
580 result.append(", title: ");
581 result.append(title);
582 result.append(')');
583 return result.toString();
584 }
585
586 } //PersonImpl