Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EReference


    }

    for (Iterator i = eReferenceToOppositeNameMap.entrySet().iterator(); i.hasNext(); )
    {
      Map.Entry entry = (Map.Entry)i.next();
      EReference eReference = (EReference)entry.getKey();
      String opposite = (String)entry.getValue();
      EClass oppositeEClass = eReference.getEReferenceType();
      if (eReference.getEOpposite() == null)
      {
        EStructuralFeature eOppositeFeature =  oppositeEClass.getEStructuralFeature(opposite);
       
        // Match by XML name if this fails.
        if (eOppositeFeature == null)
        {
          for (Iterator j = oppositeEClass.getEAllStructuralFeatures().iterator(); j.hasNext(); )
          {
            EStructuralFeature feature = (EStructuralFeature)j.next();
            if (opposite.equals(extendedMetaData.getName(feature)))
            {
              eOppositeFeature = feature;
              break;
            }
          }
        }
       
        if (eOppositeFeature instanceof EReference)
        {
          EReference eOpposite = (EReference)eOppositeFeature;
          eOpposite.setEOpposite(eReference);
          eReference.setEOpposite(eOpposite);
        }
      }

      if (eReference.getEOpposite() == null && eReference.isContainment())
      {
        EReference eOpposite = ecoreFactory.createEReference();
        eOpposite.setName(opposite);
        eOpposite.setEType(eReference.getEContainingClass());
        eOpposite.setLowerBound(0);
        eOpposite.setEOpposite(eReference);
        eReference.setEOpposite(eOpposite);
        eOpposite.setTransient(true);
        oppositeEClass.getEStructuralFeatures().add(eOpposite);
      }
    }

    eReferenceToOppositeNameMap.clear();
View Full Code Here


            EClass propertyEClass = (EClass)eClasses.get(propertyClass);

            if (propertyEClass != null)
            {
              // The property is another SDO, create an EReference to represent the property
              EReference reference = EcoreFactory.eINSTANCE.createEReference();
              reference.setName(propertyName);
              reference.setContainment(true);
              reference.setEType(propertyEClass);
              implEClass.getEStructuralFeatures().add(reference);

            }
            else
            {
              // The property is a List<T> and T is an SDO, created a 0..many EReference to represent the property
              if (propertyClass == List.class)
              {
                Type genericType = method.getGenericReturnType();
                if (genericType instanceof ParameterizedType)
                {
                  ParameterizedType parameterizedType = (ParameterizedType)genericType;
                  Type[] targs = parameterizedType.getActualTypeArguments();
                  if (targs.length != 0 && eClasses.containsKey(targs[0]))
                  {
                    propertyEClass = (EClass)eClasses.get(targs[0]);
                    if (propertyEClass != null)
                    {
                      EReference reference = EcoreFactory.eINSTANCE.createEReference();
                      reference.setName(propertyName);
                      reference.setContainment(true);
                      reference.setEType(propertyEClass);
                      reference.setUpperBound(-1);
                      implEClass.getEStructuralFeatures().add(reference);
                    }
                  }
                }
                continue;
View Full Code Here

  }

  protected void save(OutputStream outputStream, Object options) throws IOException
  {
    EObject oldContainer = null;
    EReference oldContainmentReference = null;
    int oldContainmentIndex = -1;

    if (documentRoot != null)
    {
      //TODO also check if rootObject is directly contained in a resource
View Full Code Here

  protected EMap getSchemaLocationMap()
  {
    EMap result = null;
    if ((documentRoot != null) && (extendedMetaData != null))
    {
      EReference xsiSchemaLocationMapFeature = extendedMetaData
          .getXSISchemaLocationMapFeature(documentRoot.eClass());
      if (xsiSchemaLocationMapFeature != null)
      {
        result = (EMap) documentRoot.eGet(xsiSchemaLocationMapFeature);
      }
View Full Code Here

    EStructuralFeature feature = super.createFeature(eClass, name, type, xsdComponent, minOccurs, maxOccurs);
   
    //FB What is the following for?
    if (feature instanceof EReference)
    {
      EReference eReference = (EReference)feature;
      if (xsdComponent != null && xsdComponent instanceof XSDParticle)
      {
        XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm();
        if (xsdTerm instanceof XSDElementDeclaration)
        {
          XSDTypeDefinition elementTypeDefinition = getEffectiveTypeDefinition(xsdComponent, (XSDElementDeclaration)xsdTerm);
          EClassifier eClassifier = getEClassifier(elementTypeDefinition);
          if (elementTypeDefinition instanceof XSDSimpleTypeDefinition && eClassifier instanceof EClass)
          {
            eReference.setContainment(true);
          }
        }
      }
    }
   
View Full Code Here

     * @param reference The reference whose opposite reference is retrieved.
     * @return The opposite of reference for owner.
     */
    public <E> List<E> getOppositeList(Class<E> dataClass, InternalEObject owner,
            EReference reference) {
        EReference opposite = observedRefToOpposite.get(reference);
        if (opposite == null)
            throw new IllegalArgumentException("This reference is not observed by this adapter: "
                    + reference.toString());

        List<E> result = new BasicInternalEList<E>(dataClass);
View Full Code Here

        result |= IS_UNSETTABLE;
      }

      if (eStructuralFeature instanceof EReference)
      {
        EReference eReference = (EReference)eStructuralFeature;
        EReference inverseEReference = eReference.getEOpposite();
        if (eReference.isContainment())
        {
          result |= IS_CONTAINMENT;
        }

        if (inverseEReference != null)
        {
          // This forces the feature ids to be assigned.
          //
          inverseEReference.getEContainingClass().getFeatureCount();
          result |= HAS_NAVIGABLE_INVERSE;
          if (inverseEReference.isMany())
          {
            result |= HAS_MANY_INVERSE;
          }
          if (inverseEReference.isContainment())
          {
            result |= IS_CONTAINER;
          }
        }
View Full Code Here

    if (extendedMetaData != null && contents.size() >= 1)
    {
      EObject root = contents.get(0);
      EClass eClass = root.eClass();

      EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eClass);
      if (xmlnsPrefixMapFeature != null)
      {
        @SuppressWarnings("unchecked") EMap<String, String> xmlnsPrefixMap = (EMap<String, String>)root.eGet(xmlnsPrefixMapFeature);
        for (Map.Entry<String, String> entry : helper.getPrefixToNamespaceMap())
        {
View Full Code Here

      if (resource != null && resource.getContents().size() >=1)
      {
        EObject root = resource.getContents().get(0);
        EClass eClass = root.eClass();

        EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eClass);
        if (xmlnsPrefixMapFeature != null)
        {
          @SuppressWarnings("unchecked") EMap<String, String> xmlnsPrefixMap = (EMap<String, String>)root.eGet(xmlnsPrefixMapFeature);
          helper.setPrefixToNamespaceMap(xmlnsPrefixMap);
        }
View Full Code Here

    if (useEncodedAttributeStyle)
    {
      InternalEObject container = ((InternalEObject)top).eInternalContainer();
      if (container != null)
      {
        EReference containmentReference = top.eContainmentFeature();
        EReference containerReference = containmentReference.getEOpposite();
        if (containerReference != null && !containerReference.isTransient())
        {
          saveEObjectSingle(top, containerReference);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.EReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.