| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * 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 |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.ecview.core.common.model.core.authorization.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; |
| import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; |
| import org.eclipse.osbp.ecview.core.common.model.core.YEmbeddable; |
| import org.eclipse.osbp.ecview.core.common.model.core.authorization.AuthorizationPackage; |
| import org.eclipse.osbp.ecview.core.common.model.core.authorization.YFieldAuthorization; |
| |
| /** |
| * <!-- begin-user-doc --> An implementation of the model object ' |
| * <em><b>YField Authorization</b></em>'. <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.osbp.ecview.core.common.model.core.authorization.impl.YFieldAuthorizationImpl#getTarget <em>Target</em>}</li> |
| * <li>{@link org.eclipse.osbp.ecview.core.common.model.core.authorization.impl.YFieldAuthorizationImpl#getRoles <em>Roles</em>}</li> |
| * <li>{@link org.eclipse.osbp.ecview.core.common.model.core.authorization.impl.YFieldAuthorizationImpl#getActions <em>Actions</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class YFieldAuthorizationImpl extends MinimalEObjectImpl.Container |
| implements YFieldAuthorization { |
| /** |
| * The cached value of the '{@link #getTarget() <em>Target</em>}' reference. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @see #getTarget() |
| * @generated |
| * @ordered |
| */ |
| protected YEmbeddable target; |
| |
| /** |
| * The cached value of the '{@link #getRoles() <em>Roles</em>}' attribute list. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @see #getRoles() |
| * @generated |
| * @ordered |
| */ |
| protected EList<String> roles; |
| |
| /** |
| * The cached value of the '{@link #getActions() <em>Actions</em>}' attribute list. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @see #getActions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<String> actions; |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| protected YFieldAuthorizationImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AuthorizationPackage.Literals.YFIELD_AUTHORIZATION; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public YEmbeddable getTarget() { |
| if (target != null && target.eIsProxy()) { |
| InternalEObject oldTarget = (InternalEObject)target; |
| target = (YEmbeddable)eResolveProxy(oldTarget); |
| if (target != oldTarget) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET, oldTarget, target)); |
| } |
| } |
| return target; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public YEmbeddable basicGetTarget() { |
| return target; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTarget(YEmbeddable newTarget) { |
| YEmbeddable oldTarget = target; |
| target = newTarget; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET, oldTarget, target)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<String> getRoles() { |
| if (roles == null) { |
| roles = new EDataTypeUniqueEList<String>(String.class, this, AuthorizationPackage.YFIELD_AUTHORIZATION__ROLES); |
| } |
| return roles; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<String> getActions() { |
| if (actions == null) { |
| actions = new EDataTypeUniqueEList<String>(String.class, this, AuthorizationPackage.YFIELD_AUTHORIZATION__ACTIONS); |
| } |
| return actions; |
| } |
| |
| public boolean isAllowed(String role, String action, YEmbeddable embeddable) { |
| return getTarget() == embeddable && getRoles().contains(role) |
| && getActions().contains(action); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET: |
| if (resolve) return getTarget(); |
| return basicGetTarget(); |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ROLES: |
| return getRoles(); |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ACTIONS: |
| return getActions(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET: |
| setTarget((YEmbeddable)newValue); |
| return; |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ROLES: |
| getRoles().clear(); |
| getRoles().addAll((Collection<? extends String>)newValue); |
| return; |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ACTIONS: |
| getActions().clear(); |
| getActions().addAll((Collection<? extends String>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET: |
| setTarget((YEmbeddable)null); |
| return; |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ROLES: |
| getRoles().clear(); |
| return; |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ACTIONS: |
| getActions().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__TARGET: |
| return target != null; |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ROLES: |
| return roles != null && !roles.isEmpty(); |
| case AuthorizationPackage.YFIELD_AUTHORIZATION__ACTIONS: |
| return actions != null && !actions.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (roles: "); |
| result.append(roles); |
| result.append(", actions: "); |
| result.append(actions); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // YFieldAuthorizationImpl |