/**
* <copyright> Copyright (c) 2008-2009 Jonas Helming, Maximilian Koegel. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html </copyright>
*
*
*
*/
package org.eclipse.emf.emfstore.server.model.accesscontrol.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.emfstore.common.model.impl.IdentifiableElementImpl;
import org.eclipse.emf.emfstore.server.model.ProjectId;
import org.eclipse.emf.emfstore.server.model.accesscontrol.AccesscontrolPackage;
import org.eclipse.emf.emfstore.server.model.accesscontrol.Role;
import org.eclipse.emf.emfstore.server.model.accesscontrol.RoleAssignment;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Role Assignment</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.emfstore.server.model.accesscontrol.impl.RoleAssignmentImpl#getRole <em>Role</em>}</li>
* <li>{@link org.eclipse.emf.emfstore.server.model.accesscontrol.impl.RoleAssignmentImpl#getProjectId <em>Project Id</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class RoleAssignmentImpl extends IdentifiableElementImpl implements RoleAssignment {
/**
* The cached value of the '{@link #getRole() <em>Role</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getRole()
* @generated
* @ordered
*/
protected Role role;
/**
* The cached value of the '{@link #getProjectId() <em>Project Id</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getProjectId()
* @generated
* @ordered
*/
protected ProjectId projectId;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RoleAssignmentImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return AccesscontrolPackage.Literals.ROLE_ASSIGNMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Role getRole() {
if (role != null && role.eIsProxy()) {
InternalEObject oldRole = (InternalEObject)role;
role = (Role)eResolveProxy(oldRole);
if (role != oldRole) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE, oldRole, role));
}
}
return role;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Role basicGetRole() {
return role;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setRole(Role newRole) {
Role oldRole = role;
role = newRole;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE, oldRole, role));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ProjectId getProjectId() {
if (projectId != null && projectId.eIsProxy()) {
InternalEObject oldProjectId = (InternalEObject)projectId;
projectId = (ProjectId)eResolveProxy(oldProjectId);
if (projectId != oldProjectId) {
InternalEObject newProjectId = (InternalEObject)projectId;
NotificationChain msgs = oldProjectId.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, null, null);
if (newProjectId.eInternalContainer() == null) {
msgs = newProjectId.eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, null, msgs);
}
if (msgs != null) msgs.dispatch();
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, oldProjectId, projectId));
}
}
return projectId;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ProjectId basicGetProjectId() {
return projectId;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetProjectId(ProjectId newProjectId, NotificationChain msgs) {
ProjectId oldProjectId = projectId;
projectId = newProjectId;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, oldProjectId, newProjectId);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setProjectId(ProjectId newProjectId) {
if (newProjectId != projectId) {
NotificationChain msgs = null;
if (projectId != null)
msgs = ((InternalEObject)projectId).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, null, msgs);
if (newProjectId != null)
msgs = ((InternalEObject)newProjectId).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, null, msgs);
msgs = basicSetProjectId(newProjectId, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID, newProjectId, newProjectId));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID:
return basicSetProjectId(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE:
if (resolve) return getRole();
return basicGetRole();
case AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID:
if (resolve) return getProjectId();
return basicGetProjectId();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE:
setRole((Role)newValue);
return;
case AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID:
setProjectId((ProjectId)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE:
setRole((Role)null);
return;
case AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID:
setProjectId((ProjectId)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case AccesscontrolPackage.ROLE_ASSIGNMENT__ROLE:
return role != null;
case AccesscontrolPackage.ROLE_ASSIGNMENT__PROJECT_ID:
return projectId != null;
}
return super.eIsSet(featureID);
}
} //RoleAssignmentImpl