| /******************************************************************************* |
| * Copyright (c) 2007, 2013 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License 2.0, which accompanies this distribution |
| * and is available at https://www.eclipse.org/legal/epl-2.0/. |
| * |
| * Contributors: |
| * Oracle - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.jpt.jpa.core.resource.orm; |
| |
| 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.jpt.jpa.core.resource.orm.v2_1.JPA2_1; |
| import org.eclipse.jpt.jpa.core.resource.orm.v2_1.OrmV2_1Package; |
| import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlForeignKey_2_1; |
| import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlManyToOne_2_1; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator; |
| import org.eclipse.jpt.jpa.core.MappingKeys; |
| import org.eclipse.wst.common.internal.emf.resource.Translator; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * A representation of the model object '<em><b>Many To One</b></em>'. |
| * |
| * Provisional API: This interface is part of an interim API that is still |
| * under development and expected to change significantly before reaching |
| * stability. It is available at this early stage to solicit feedback from |
| * pioneering adopters on the understanding that any code that uses this API |
| * will almost certainly be broken (repeatedly) as the API evolves. |
| * <!-- end-user-doc --> |
| * |
| * |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlManyToOne() |
| * @model kind="class" |
| * @generated |
| */ |
| public class XmlManyToOne extends AbstractXmlSingleRelationshipMapping implements XmlManyToOne_2_1 |
| { |
| |
| /** |
| * The cached value of the '{@link #getForeignKey() <em>Foreign Key</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getForeignKey() |
| * @generated |
| * @ordered |
| */ |
| protected XmlForeignKey foreignKey; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XmlManyToOne() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return OrmPackage.Literals.XML_MANY_TO_ONE; |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Foreign Key</b></em>' containment reference. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Foreign Key</em>' containment reference isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Foreign Key</em>' containment reference. |
| * @see #setForeignKey(XmlForeignKey) |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlManyToOne_2_1_ForeignKey() |
| * @model containment="true" |
| * @generated |
| */ |
| public XmlForeignKey getForeignKey() |
| { |
| return foreignKey; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetForeignKey(XmlForeignKey newForeignKey, NotificationChain msgs) |
| { |
| XmlForeignKey oldForeignKey = foreignKey; |
| foreignKey = newForeignKey; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY, oldForeignKey, newForeignKey); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne#getForeignKey <em>Foreign Key</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Foreign Key</em>' containment reference. |
| * @see #getForeignKey() |
| * @generated |
| */ |
| public void setForeignKey(XmlForeignKey newForeignKey) |
| { |
| if (newForeignKey != foreignKey) |
| { |
| NotificationChain msgs = null; |
| if (foreignKey != null) |
| msgs = ((InternalEObject)foreignKey).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY, null, msgs); |
| if (newForeignKey != null) |
| msgs = ((InternalEObject)newForeignKey).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY, null, msgs); |
| msgs = basicSetForeignKey(newForeignKey, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY, newForeignKey, newForeignKey)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: |
| return basicSetForeignKey(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 OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: |
| return getForeignKey(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: |
| setForeignKey((XmlForeignKey)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: |
| setForeignKey((XmlForeignKey)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: |
| return foreignKey != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) |
| { |
| if (baseClass == XmlManyToOne_2_1.class) |
| { |
| switch (derivedFeatureID) |
| { |
| case OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY: return OrmV2_1Package.XML_MANY_TO_ONE_21__FOREIGN_KEY; |
| default: return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) |
| { |
| if (baseClass == XmlManyToOne_2_1.class) |
| { |
| switch (baseFeatureID) |
| { |
| case OrmV2_1Package.XML_MANY_TO_ONE_21__FOREIGN_KEY: return OrmPackage.XML_MANY_TO_ONE__FOREIGN_KEY; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| // **************** XmlAttributeMapping impl ****************************** |
| |
| public String getMappingKey() { |
| return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY; |
| } |
| |
| |
| // **************** translators ******************************************* |
| |
| public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) { |
| return new SimpleTranslator(elementName, structuralFeature, buildTranslatorChildren()); |
| } |
| |
| private static Translator[] buildTranslatorChildren() { |
| return new Translator[] { |
| buildNameTranslator(), |
| buildTargetEntityTranslator(), |
| buildFetchTranslator(), |
| buildOptionalTranslator(), |
| buildAccessTranslator(), |
| buildMapsIdTranslator(), |
| buildIdTranslator(), |
| buildJoinColumnTranslator(), |
| buildForeignKeyTranslator(), |
| buildJoinTableTranslator(), |
| buildCascadeTranslator() |
| }; |
| } |
| |
| |
| protected static Translator buildForeignKeyTranslator() { |
| return XmlForeignKey.buildTranslator(JPA2_1.FOREIGN_KEY, OrmV2_1Package.eINSTANCE.getXmlManyToOne_2_1_ForeignKey()); |
| } |
| |
| } |