All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openxma.dsl.dom.model.impl.EntityImpl Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/**
 * 
 * 
 *
 * $Id: EntityImpl.java 10224 2013-01-04 15:48:48Z dschwarz $
 */
package org.openxma.dsl.dom.model.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.ECollections;
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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.openxma.dsl.common.extensions.EObjectPropertiesAdapter;
import org.openxma.dsl.core.model.ConditionsBlock;
import org.openxma.dsl.dom.DomPackage;
import org.openxma.dsl.dom.model.Attribute;
import org.openxma.dsl.dom.model.AttributeGroup;
import org.openxma.dsl.dom.model.Dao;
import org.openxma.dsl.dom.model.DataView;
import org.openxma.dsl.dom.model.Entity;
import org.openxma.dsl.dom.model.PresentableFeature;

import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;

/**
 *  An implementation of the model object '
 * Entity'. 
 * 

* The following features are implemented: *

    *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getSuperType Super Type}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getAttributeGroups Attribute Groups}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getConditionsBlock Conditions Block}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getRepository Repository}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getKey Key}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getSortOrders Sort Orders}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getIdentifier Identifier}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getVersion Version}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getRequiredReferences Required References}
  • *
  • {@link org.openxma.dsl.dom.model.impl.EntityImpl#getRequiredAttributes Required Attributes}
  • *
*

* * @generated */ public class EntityImpl extends ComplexTypeImpl implements Entity { /** * The cached value of the '{@link #getSuperType() Super Type}' reference. * * @see #getSuperType() * @generated * @ordered */ protected Entity superType; /** * The cached value of the '{@link #getAttributeGroups() Attribute Groups}' containment reference list. * * * @see #getAttributeGroups() * @generated * @ordered */ protected EList attributeGroups; /** * The cached value of the '{@link #getConditionsBlock() Conditions Block}' containment reference. * * @see #getConditionsBlock() * @generated * @ordered */ protected ConditionsBlock conditionsBlock; /** * @generated NOT */ private Dao repository; /** * @generated NOT */ private DataView defaultView; /** * @generated NOT */ private AttributeGroup key; /** * * @generated */ protected EntityImpl() { super(); } /** * * @generated */ @Override protected EClass eStaticClass() { return DomPackage.Literals.ENTITY; } /** * * * @generated NOT */ public Entity getObject() { return this; } /** * * @generated */ public Entity getSuperType() { if (superType != null && superType.eIsProxy()) { InternalEObject oldSuperType = (InternalEObject)superType; superType = (Entity)eResolveProxy(oldSuperType); if (superType != oldSuperType) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, DomPackage.ENTITY__SUPER_TYPE, oldSuperType, superType)); } } return superType; } /** * * @generated */ public Entity basicGetSuperType() { return superType; } /** * * @generated */ public void setSuperType(Entity newSuperType) { Entity oldSuperType = superType; superType = newSuperType; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, DomPackage.ENTITY__SUPER_TYPE, oldSuperType, superType)); } /** * * * @generated */ public EList getAttributeGroups() { if (attributeGroups == null) { attributeGroups = new EObjectContainmentEList(AttributeGroup.class, this, DomPackage.ENTITY__ATTRIBUTE_GROUPS); } return attributeGroups; } /** * * @generated */ public ConditionsBlock getConditionsBlock() { return conditionsBlock; } /** * * @generated */ public NotificationChain basicSetConditionsBlock(ConditionsBlock newConditionsBlock, NotificationChain msgs) { ConditionsBlock oldConditionsBlock = conditionsBlock; conditionsBlock = newConditionsBlock; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomPackage.ENTITY__CONDITIONS_BLOCK, oldConditionsBlock, newConditionsBlock); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * * @generated */ public void setConditionsBlock(ConditionsBlock newConditionsBlock) { if (newConditionsBlock != conditionsBlock) { NotificationChain msgs = null; if (conditionsBlock != null) msgs = ((InternalEObject)conditionsBlock).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DomPackage.ENTITY__CONDITIONS_BLOCK, null, msgs); if (newConditionsBlock != null) msgs = ((InternalEObject)newConditionsBlock).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DomPackage.ENTITY__CONDITIONS_BLOCK, null, msgs); msgs = basicSetConditionsBlock(newConditionsBlock, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, DomPackage.ENTITY__CONDITIONS_BLOCK, newConditionsBlock, newConditionsBlock)); } /** * * * @generated NOT */ public Dao getRepository() { if (this.repository == null) { Collection daos = EcoreUtil.getObjectsByType(eContainer().eContents(), DomPackage.eINSTANCE.getDao()); if (daos != null) { for (Dao dao : daos) { if (dao.getEntity() != null && dao.getEntity().equals(this)) { this.repository = dao; } } } } return this.repository; } /** * * * @generated NOT */ public AttributeGroup getKey() { if (null == key) { if (getSuperType() != null && !getSuperType().equals(this)) { key = getSuperType().getKey(); } for (Iterator iterator = getAttributeGroups().iterator(); null == key && iterator.hasNext();) { AttributeGroup attributeGroup = iterator.next(); if (attributeGroup.isKey()) { key = attributeGroup; } } } return key; } /** * * * @generated NOT */ public EList getSortOrders() { EList sortOrders = new EObjectEList(AttributeGroup.class, this, DomPackage.ENTITY__SORT_ORDERS); sortOrders.addAll(Collections2.filter(getAttributeGroups(), new Predicate() { public boolean apply(AttributeGroup input) { return input.isSortorder(); } })); return sortOrders; } /** * * * @generated NOT */ private Attribute identifierAttribute; /** * * * @generated NOT */ private Attribute versionAttribute; /** * * * @generated NOT */ public Attribute getIdentifier() { if (null == identifierAttribute) { if (getSuperType() != null && !getSuperType().equals(this)) { identifierAttribute = (Attribute) getSuperType().getIdentifier(); } for (Iterator iterator = getAttributes().iterator(); null == identifierAttribute && iterator.hasNext();) { Attribute attribute = iterator.next(); if (attribute.isIdentifier()) { identifierAttribute = attribute; } } } return identifierAttribute; } /** * * * @generated NOT */ public Attribute getVersion() { if (null == versionAttribute) { if (getSuperType() != null && !getSuperType().equals(this)) { versionAttribute = (Attribute) getSuperType().getVersion(); } for (Iterator iterator = getAttributes().iterator(); null == versionAttribute && iterator.hasNext();) { Attribute attribute = iterator.next(); if (attribute.isVersion()) { versionAttribute = attribute; } } } return versionAttribute; } /** * * * @generated NOT */ public EList getRequiredReferences() { EList requiredReferences = new EObjectEList(Attribute.class, this, DomPackage.ENTITY__REQUIRED_REFERENCES); requiredReferences.addAll(Collections2.filter(getAllAttributes(), new Predicate() { public boolean apply(Attribute attribute) { return attribute.isRequired() && attribute.isReference(); } })); return requiredReferences; } /** * * * @generated NOT */ public EList getRequiredAttributes() { EList requiredAttributes = new EObjectEList(Attribute.class, this, DomPackage.ENTITY__REQUIRED_ATTRIBUTES); requiredAttributes.addAll(Collections2.filter(getAllAttributes(), new Predicate() { public boolean apply(Attribute attribute) { return attribute.isRequired() && !attribute.isReference(); } })); return requiredAttributes; } /** * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case DomPackage.ENTITY__ATTRIBUTE_GROUPS: return ((InternalEList)getAttributeGroups()).basicRemove(otherEnd, msgs); case DomPackage.ENTITY__CONDITIONS_BLOCK: return basicSetConditionsBlock(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case DomPackage.ENTITY__SUPER_TYPE: if (resolve) return getSuperType(); return basicGetSuperType(); case DomPackage.ENTITY__ATTRIBUTE_GROUPS: return getAttributeGroups(); case DomPackage.ENTITY__CONDITIONS_BLOCK: return getConditionsBlock(); case DomPackage.ENTITY__REPOSITORY: return getRepository(); case DomPackage.ENTITY__KEY: return getKey(); case DomPackage.ENTITY__SORT_ORDERS: return getSortOrders(); case DomPackage.ENTITY__IDENTIFIER: return getIdentifier(); case DomPackage.ENTITY__VERSION: return getVersion(); case DomPackage.ENTITY__REQUIRED_REFERENCES: return getRequiredReferences(); case DomPackage.ENTITY__REQUIRED_ATTRIBUTES: return getRequiredAttributes(); } return super.eGet(featureID, resolve, coreType); } /** * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case DomPackage.ENTITY__SUPER_TYPE: setSuperType((Entity)newValue); return; case DomPackage.ENTITY__ATTRIBUTE_GROUPS: getAttributeGroups().clear(); getAttributeGroups().addAll((Collection)newValue); return; case DomPackage.ENTITY__CONDITIONS_BLOCK: setConditionsBlock((ConditionsBlock)newValue); return; } super.eSet(featureID, newValue); } /** * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case DomPackage.ENTITY__SUPER_TYPE: setSuperType((Entity)null); return; case DomPackage.ENTITY__ATTRIBUTE_GROUPS: getAttributeGroups().clear(); return; case DomPackage.ENTITY__CONDITIONS_BLOCK: setConditionsBlock((ConditionsBlock)null); return; } super.eUnset(featureID); } /** * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case DomPackage.ENTITY__SUPER_TYPE: return superType != null; case DomPackage.ENTITY__ATTRIBUTE_GROUPS: return attributeGroups != null && !attributeGroups.isEmpty(); case DomPackage.ENTITY__CONDITIONS_BLOCK: return conditionsBlock != null; case DomPackage.ENTITY__REPOSITORY: return getRepository() != null; case DomPackage.ENTITY__KEY: return getKey() != null; case DomPackage.ENTITY__SORT_ORDERS: return !getSortOrders().isEmpty(); case DomPackage.ENTITY__IDENTIFIER: return getIdentifier() != null; case DomPackage.ENTITY__VERSION: return getVersion() != null; case DomPackage.ENTITY__REQUIRED_REFERENCES: return !getRequiredReferences().isEmpty(); case DomPackage.ENTITY__REQUIRED_ATTRIBUTES: return !getRequiredAttributes().isEmpty(); } return super.eIsSet(featureID); } /** * @generated NOT */ @Override public EList getAllAttributes() { EList allAttributes = new EObjectEList(Attribute.class, this, DomPackage.ENTITY__ALL_ATTRIBUTES); if (getSuperType() != null && !getSuperType().equals(this)) { allAttributes.addAll(getSuperType().getAllAttributes()); } allAttributes.addAll(getAttributes()); return allAttributes; } /** * @generated NOT */ public void setDas(Dao das) { this.repository = das; } /** * @generated NOT */ public Collection copyAttributes() { Collection attributes = EcoreUtil.copyAll(getAttributes()); if (getSuperType() != null) { Collection superTypeAttributes = getSuperType().copyAttributes(); attributes.addAll(EcoreUtil.copyAll(superTypeAttributes)); } return attributes; } /** * @generated NOT */ public Attribute getAttributeByName(String name) { for (Attribute attribute : copyAttributes()) { if (name.equalsIgnoreCase(attribute.getName())) { return attribute; } } return null; } /** * @generated NOT */ public DataView getDefaultDataView() { if (null == defaultView) { Collection dataViews = EcoreUtil.getObjectsByType(eContainer().eContents(), DomPackage.eINSTANCE .getDataView()); for (Iterator iterator = dataViews.iterator(); iterator.hasNext() && defaultView == null;) { DataView dataView = (DataView) iterator.next(); if (getDefaultDataViewName().equals(dataView.getName())) { defaultView = dataView; } } } return defaultView; } /** * @generated NOT */ public String getDefaultDataViewName() { return getName() + "View"; } /** * @generated NOT */ public EList getResolvedAttributeList() { EList resolvedAttributeList = ECollections.emptyEList(); if (getKey() != null) { resolvedAttributeList = getKey().getResolvedAttributeList(); } else if (getIdentifier() != null) { resolvedAttributeList = new BasicEList(); Attribute attributeCopy = (Attribute) EcoreUtil.copy(getIdentifier()); EObjectPropertiesAdapter.setProperty(attributeCopy, "entity", this); resolvedAttributeList.add(attributeCopy); } return resolvedAttributeList; } /** * @generated NOT */ public List getAllPresentableFeaturesIncludingSuperType() { List presentableFeatureList = new ArrayList(); presentableFeatureList.addAll(getAllAttributes()); return presentableFeatureList; } } // EntityImpl




© 2015 - 2024 Weber Informatics LLC | Privacy Policy