You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/02/21 13:34:21 UTC

svn commit: r509984 [1/4] - in /incubator/tuscany/java/sdo: impl/src/main/java/org/apache/tuscany/sdo/helper/ impl/src/main/java/org/apache/tuscany/sdo/impl/ impl/src/main/java/org/apache/tuscany/sdo/util/ impl/src/test/java/org/apache/tuscany/sdo/test...

Author: kelvingoodson
Date: Wed Feb 21 04:34:19 2007
New Revision: 509984

URL: http://svn.apache.org/viewvc?view=rev&rev=509984
Log:
TUSCANY-521 -- The core of this change lies in
a) for the runtime, the fact that ClassImpl now maintains lists of user visible properties,  rather than relying on the state of the EMF implementation objects
b) for the generated classes, the creation of 2 sets of Property indices,  one for the user and one for referencing internal EMF objects' features.  Each generated class has a generated method for mapping between the external and internal indices.
All other changes relate to the use or testing of the above changes.

Added:
    incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/InheritanceTestCase.java   (with props)
    incubator/tuscany/java/sdo/tools/src/test/resources/subgroup.xsd   (with props)
    incubator/tuscany/java/sdo/tools/src/test/resources/subgroup1.xml   (with props)
Modified:
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
    incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/templates/model/SDOClass.java
    incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/templates/model/SDOFactoryClass.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/MixedQuote.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/MixedRepeatingChoice.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/RepeatingChoice.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/SequencesFactory.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/TwoRCs.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/TwoRCsMixed.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/MixedQuoteImpl.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/MixedRepeatingChoiceImpl.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/RepeatingChoiceImpl.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/SequencesFactoryImpl.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/TwoRCsImpl.java
    incubator/tuscany/java/sdo/tools/src/test/java/com/example/sequences/impl/TwoRCsMixedImpl.java
    incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet
    incubator/tuscany/java/sdo/tools/templates/models/SDOFactoryClass.javajet

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java Wed Feb 21 04:34:19 2007
@@ -289,7 +289,7 @@
     // get/create document root
     EPackage ePackage = extendedMetaData.getPackage(uri);
     Type documentRoot = 
-      ePackage != null ? (Type)extendedMetaData.getType(extendedMetaData.getPackage(uri), "") : null;
+      ePackage != null ? (Type)extendedMetaData.getType(ePackage, "") : null;
     if (documentRoot == null) 
     {
       documentRoot = SDOUtil.createType(this, uri, null, false);

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java Wed Feb 21 04:34:19 2007
@@ -19,20 +19,28 @@
  */
 package org.apache.tuscany.sdo.impl;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.ArrayList;
+import java.util.Collections;
 
 import org.apache.tuscany.sdo.SDOFactory;
 import org.apache.tuscany.sdo.model.ModelFactory;
 import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
 import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.UniqueEList;
 import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.emf.ecore.EcorePackage;
 import org.eclipse.emf.ecore.impl.EClassImpl;
+import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
 import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.util.FeatureMap;
 
 import commonj.sdo.Property;
 import commonj.sdo.Sequence;
@@ -49,6 +57,8 @@
  */
 public class ClassImpl extends EClassImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/
 {
+	private static final long serialVersionUID = 1L;
+	
   private static final Property UNINITIALIZED_CSPC = SDOFactory.eINSTANCE.createAttribute();
   private Property changeSummaryPropertyCache = UNINITIALIZED_CSPC;
   
@@ -99,18 +109,24 @@
    */
   public boolean isOpen()
   {
-    for (int i = 0, count = getFeatureCount(); i < count; ++i)
+    final List properties = getExtendedProperties();
+    if (properties != Collections.EMPTY_LIST)
     {
-      EStructuralFeature eStructuralFeature = getEStructuralFeature(i);
-      switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature))
+      for (int i = 0, count = properties.size(); i < count; ++i)
       {
-        case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE:
-          if (eStructuralFeature == ExtendedMetaData.INSTANCE.getMixedFeature(this)) break;
-        case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE:
-        case ExtendedMetaData.GROUP_FEATURE:
+        EStructuralFeature eStructuralFeature = (EStructuralFeature)properties.get(i);
+        if (isOpenFeatureMap(eStructuralFeature))
           return true;
       }
     }
+
+    for (final Iterator iterator = getBaseTypes().iterator() ; iterator.hasNext(); )
+    {
+      Type baseType = (Type)iterator.next();
+      if (baseType.isOpen())
+        return true;
+    }
+
     return false;
   }
 
@@ -122,7 +138,7 @@
   public boolean isSequenced()
   {
     // isSequenced == isMixed 
-    return ExtendedMetaData.INSTANCE.getMixedFeature(this) != null;
+    return ExtendedMetaData.INSTANCE.getMixedFeature(this) != null; //FB is there a more efficient way to check this now that we have extendedProperties list?
   }
 
   protected List aliasNames = null;
@@ -140,16 +156,64 @@
     }
     return aliasNames;
   }
-
-  /**
-   * <!-- begin-user-doc -->
-   * <!-- end-user-doc -->
-   * @generated NOT
-   */
+  
+  protected List declaredProperties = null;
+  
   public List getDeclaredProperties()
   {
-    return getEStructuralFeatures();
+    if (declaredProperties == null) {
+      initPropertyLists();
+    }
+    return declaredProperties;
+  }
+  
+  protected List extendedProperties = null;
+  
+  public List getExtendedProperties()
+  {
+    if (extendedProperties == null) {
+      initPropertyLists();
+    }
+    return extendedProperties;
+  }
+  
+  protected void initPropertyLists()
+  {
+    declaredProperties = new ArrayList();
+    extendedProperties = Collections.EMPTY_LIST;
+    
+    for (Iterator i = getEStructuralFeatures().iterator(); i.hasNext(); ) {
+      EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next();
+      boolean isExtendedProperty = DataObjectUtil.isInternalProperty(eStructuralFeature);
+      if (isExtendedProperty) {
+        if (extendedProperties == Collections.EMPTY_LIST)
+          extendedProperties = new ArrayList();
+        extendedProperties.add(eStructuralFeature);
+      }
+      else
+        declaredProperties.add(eStructuralFeature);
+    }
   }
+  
+  public EList getEStructuralFeatures()
+  {
+    if (eStructuralFeatures == null)
+    {
+      eStructuralFeatures = 
+        new EObjectContainmentWithInverseEList(EStructuralFeature.class, this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS)
+        {
+          protected void didChange()
+          {
+            declaredProperties = extendedProperties = null;
+          }
+        };
+    }
+    return eStructuralFeatures;
+  }
+
+  protected List allProperties = null;
+  protected List allExtendedProperties = null;
+  protected EList allFeaturesCache = null;
 
   /**
    * <!-- begin-user-doc -->
@@ -158,7 +222,81 @@
    */
   public List getProperties()
   {
-    return getEAllStructuralFeatures();
+    final EList allFeatures = getEAllStructuralFeatures();
+    if (allFeatures != allFeaturesCache) 
+    {
+      allFeaturesCache = allFeatures;
+      allProperties = allExtendedProperties = null;
+    }
+    if (allProperties == null)
+    {
+      allProperties = new UniqueEList();
+      for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); )
+      {
+        Type baseType = (Type)iterator.next();
+        allProperties.addAll(baseType.getProperties());
+      }
+      allProperties.addAll(getDeclaredProperties());
+    }
+    return allProperties;
+  }
+
+  public List getAllExtendedProperties()
+  {
+    final EList allFeatures = getEAllStructuralFeatures();
+    if (allFeatures != allFeaturesCache) 
+    {
+      allFeaturesCache = allFeatures;
+      allProperties = allExtendedProperties = null;
+    }
+    if (allProperties == null)
+    {
+      allExtendedProperties = new UniqueEList();
+      for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); )
+      {
+        Type baseType = (Type)iterator.next();
+        allExtendedProperties.addAll(((ClassImpl)baseType).getAllExtendedProperties());
+      }
+      allExtendedProperties.addAll(getExtendedProperties());
+    }
+    return allExtendedProperties;
+  }
+  
+  protected boolean isOpenFeatureMap(EStructuralFeature eStructuralFeature)
+  {
+    switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature))
+    {
+      case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE:
+        return eStructuralFeature != ExtendedMetaData.INSTANCE.getMixedFeature(this);
+      case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE:
+      //FB I think this is wrong ... case ExtendedMetaData.GROUP_FEATURE:
+        return true;
+    }
+    return false;
+  }
+
+  public void addInstanceProperties(EObject dataObject, Collection propertyList)
+  {
+    for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); )
+    {
+      ClassImpl baseType = (ClassImpl)iterator.next();
+      baseType.addInstanceProperties(dataObject, propertyList);
+    }
+
+    for (final Iterator iter = getExtendedProperties().iterator(); iter.hasNext(); )
+    {
+      EStructuralFeature eStructuralFeature = (EStructuralFeature)iter.next();
+      if (isOpenFeatureMap(eStructuralFeature))
+      {
+        List features = (List)dataObject.eGet(eStructuralFeature);
+        for (int j = 0, size = features.size(); j < size; ++j)
+        {
+          FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j);
+          EStructuralFeature entryFeature = entry.getEStructuralFeature();
+          propertyList.add(entryFeature);
+        }
+      }
+    }
   }
 
   /**

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java Wed Feb 21 04:34:19 2007
@@ -177,6 +177,7 @@
   }
   
   protected interface ChangeContext {}
+
   
   protected ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext)
   {
@@ -275,9 +276,14 @@
     throw new UnsupportedOperationException();
   }
   
+  protected int internalConvertIndex(int internalIndex)
+  {
+    return internalIndex;
+  }
+  
   public Object eGet(int featureID, boolean resolve, boolean coreType)
   {
-    Object result = get(featureID, resolve);
+    Object result = get(internalConvertIndex(featureID), resolve);
     if (coreType)
     {
       if (result instanceof FeatureMap.Internal.Wrapper) result = ((FeatureMap.Internal.Wrapper)result).featureMap();
@@ -287,17 +293,17 @@
 
   public void eSet(int featureID, Object newValue)
   {
-    set(featureID, newValue);
+    set(internalConvertIndex(featureID), newValue);
   } 
 
   public void eUnset(int featureID)
   {
-    unset(featureID);
+    unset(internalConvertIndex(featureID));
   }
   
   public boolean eIsSet(int featureID)
   {
-    return isSet(featureID);
+    return isSet(internalConvertIndex(featureID));
   }
   
   private class ChangeContextImpl implements ChangeContext
@@ -308,9 +314,10 @@
     }
   }
   
-  public NotificationChain eInverseRemove(InternalEObject otherEnd, int propertyIndex, NotificationChain msgs)
+  //FB TODO ... review this? ... what about eInverseAdd?
+  public NotificationChain eInverseRemove(InternalEObject otherEnd, int propertyNumber, NotificationChain msgs)
   {
-    return ((ChangeContextImpl)inverseRemove(otherEnd, propertyIndex, new ChangeContextImpl(msgs))).notificationChain;
+    return ((ChangeContextImpl)inverseRemove(otherEnd, propertyNumber, new ChangeContextImpl(msgs))).notificationChain;
   }
   
   public String toString()

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java Wed Feb 21 04:34:19 2007
@@ -90,7 +90,7 @@
    */
   public Object get(int propertyIndex)
   {
-    return eGet(propertyIndex, true, false);
+    return get(DataObjectUtil.getProperty(this, propertyIndex));  
   }
 
   /**
@@ -100,7 +100,7 @@
    */
   public void set(int propertyIndex, Object value)
   {
-    eSet(propertyIndex, value);
+    set(DataObjectUtil.getProperty(this, propertyIndex), value);  
   }
 
   /**
@@ -110,7 +110,7 @@
    */
   public boolean isSet(int propertyIndex)
   {
-    return eIsSet(propertyIndex);
+    return isSet(DataObjectUtil.getProperty(this, propertyIndex));  
   }
 
   /**
@@ -120,7 +120,7 @@
    */
   public void unset(int propertyIndex)
   {
-    eUnset(propertyIndex);
+    unset(DataObjectUtil.getProperty(this, propertyIndex));  
   }
 
   /**
@@ -204,7 +204,7 @@
   }
 
   
-  // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil
+  // Remaining DataObject methods are implemented as straight delegation to DataObjectUtil
 
   /**
    * <!-- begin-user-doc -->

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java Wed Feb 21 04:34:19 2007
@@ -110,15 +110,20 @@
       return (Type)createEClass(typeNumber);
   }
   
-  protected void createProperty(boolean isDataType, Type containingType, int propertyNumber)
+  protected void createProperty(boolean isDataType, Type containingType, int internalPropertyNumber)
   {
     if (isDataType)
-      createEAttribute((EClass)containingType, propertyNumber);
+      createEAttribute((EClass)containingType, internalPropertyNumber);
     else
-      createEReference((EClass)containingType, propertyNumber);
+      createEReference((EClass)containingType, internalPropertyNumber);
   }
   
-  protected void initializeType(Type type, Class instanceClass, String name) //FB TODO regenerate models and then delete this method
+  protected Property getProperty(Type type, int internalPropertyNumber)
+  {
+    return (Property)((EClass)type).getEAllStructuralFeatures().get(internalPropertyNumber);
+  }
+  
+  protected void initializeType(Type type, Class instanceClass, String name)
   {
     initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);   
   }
@@ -142,7 +147,7 @@
   {
     initEReference((EReference)property, (EClassifier)type, (EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/, isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED);
   }
-
+  
   protected void initXSD()
   {
     createDocumentRoot();

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java Wed Feb 21 04:34:19 2007
@@ -224,85 +224,79 @@
   }
   
 
-  
-  private static Property getPropertyByIndex(DataObject dataObject, int propertyIndex) {
-    EObject eObject = (EObject) dataObject;
-    Property property = (Property)eObject.eClass().getEStructuralFeature(propertyIndex);
-    return property;
-  }
-
   public static void setString(DataObject dataObject, int propertyIndex, String value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setString(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setShort(DataObject dataObject, int propertyIndex, short value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setShort(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setLong(DataObject dataObject, int propertyIndex, long value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setLong(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setList(DataObject dataObject, int propertyIndex, List value) {
-    dataObject.set(propertyIndex, value);
+      setList(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setInt(DataObject dataObject, int propertyIndex, int value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setInt(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setFloat(DataObject dataObject, int propertyIndex, float value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setFloat(dataObject,getProperty(dataObject, propertyIndex), value);
   }
  
   public static void setDouble(DataObject dataObject, int propertyIndex, double value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setDouble(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setDate(DataObject dataObject, int propertyIndex, Date value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setDate(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setDataObject(DataObject dataObject, int propertyIndex, DataObject value) {
-    dataObject.set(propertyIndex, value);
+    dataObject.set(getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setChar(DataObject dataObject, int propertyIndex, char value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setChar(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setBytes(DataObject dataObject, int propertyIndex, byte[] value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setBytes(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setByte(DataObject dataObject, int propertyIndex, byte value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setByte(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setBoolean(DataObject dataObject, int propertyIndex, boolean value) {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setBoolean(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setBigInteger(DataObject dataObject, int propertyIndex, BigInteger value)
   {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+      setBigInteger(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static void setBigDecimal(DataObject dataObject, int propertyIndex, BigDecimal value)
   {
-    dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value));
+    setBigDecimal(dataObject,getProperty(dataObject, propertyIndex), value);
   }
   
   public static String getString(DataObject dataObject, int propertyIndex)
   {
-    return getString(dataObject.get(propertyIndex));
+    return getString(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static short getShort(DataObject dataObject, int propertyIndex)
   {
-    return getShort(dataObject.get(propertyIndex));
+    return getShort(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
+
   public static Sequence getSequence(DataObject dataObject, int propertyIndex)
   {
     return (Sequence)dataObject.get(propertyIndex);
@@ -310,67 +304,67 @@
   
   public static long getLong(DataObject dataObject, int propertyIndex)
   {
-    return getLong(dataObject.get(propertyIndex));
+    return getLong(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static List getList(DataObject dataObject, int propertyIndex)
   {
-    return (List)dataObject.get(propertyIndex);
+    return (List)dataObject.get(getProperty(dataObject, propertyIndex));
   }
   
   public static int getInt(DataObject dataObject, int propertyIndex)
   {
-    return getInt(dataObject.get(propertyIndex));
+    return getInt(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static float getFloat(DataObject dataObject, int propertyIndex)
   {
-    return getFloat(dataObject.get(propertyIndex));
+    return getFloat(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static double getDouble(DataObject dataObject, int propertyIndex)
   {
-    return getDouble(dataObject.get(propertyIndex));
+    return getDouble(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static Date getDate(DataObject dataObject, int propertyIndex)
   {
-    return getDate(dataObject.get(propertyIndex));
+    return getDate(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static DataObject getDataObject(DataObject dataObject, int propertyIndex)
   {
-    return (DataObject)dataObject.get(propertyIndex);
+    return (DataObject)dataObject.get(getProperty(dataObject, propertyIndex));
   }
   
   public static char getChar(DataObject dataObject, int propertyIndex)
   {
-    return getChar(dataObject.get(propertyIndex));
+    return getChar(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static byte[] getBytes(DataObject dataObject, int propertyIndex)
   {
-    return getBytes(dataObject.get(propertyIndex));
+    return getBytes(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static byte getByte(DataObject dataObject, int propertyIndex)
   {
-    return getByte(dataObject.get(propertyIndex));
+    return getByte(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static boolean getBoolean(DataObject dataObject, int propertyIndex)
   {
-    return getBoolean(dataObject.get(propertyIndex));
+    return getBoolean(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static BigInteger getBigInteger(DataObject dataObject, int propertyIndex)
   {
-    return getBigInteger(dataObject.get(propertyIndex));
+    return getBigInteger(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static BigDecimal getBigDecimal(DataObject dataObject, int propertyIndex)
   {
-    return getBigDecimal(dataObject.get(propertyIndex));
+    return getBigDecimal(dataObject.get(getProperty(dataObject, propertyIndex)));
   }
   
   public static void detach(DataObject dataObject) {
@@ -382,25 +376,16 @@
     return (DataObject)EcoreUtil.getRootContainer((EObject)dataObject);
   }
   
+  public static boolean isInternalProperty(EStructuralFeature eStructuralFeature)
+  {
+    return FeatureMapUtil.isFeatureMap(eStructuralFeature);
+  }
+
   public static List getInstanceProperties(DataObject dataObject)
   {
-    //TODO maybe optimize this to just return type.getProperties if type.isOpen (isOpen would need to be cached)
-    EObject eDataObject = (EObject) dataObject;
-    List result = new UniqueEList(eDataObject.eClass().getEAllStructuralFeatures());
-    for (int i = 0, count = result.size(); i < count; ++i)
-    {
-      EStructuralFeature eStructuralFeature = (EStructuralFeature)result.get(i);
-      if (!eStructuralFeature.isDerived() && FeatureMapUtil.isFeatureMap(eStructuralFeature))
-      {
-        List features = (List)eDataObject.eGet(eStructuralFeature);
-        for (int j = 0, size = features.size(); j < size; ++j)
-        {
-          FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j);
-          EStructuralFeature entryFeature = entry.getEStructuralFeature();
-          result.add(entryFeature);
-        }
-      }
-    }
+    Type type = dataObject.getType();
+    List result = new UniqueEList(type.getProperties());
+    ((ClassImpl)type).addInstanceProperties((EObject)dataObject, result);
     return result;
   }
   
@@ -2519,6 +2504,7 @@
   public static EClass createDocumentRoot()
   {
     EClass documentRootEClass = EcoreFactory.eINSTANCE.createEClass();
+    documentRootEClass.setName("DocumentRoot");
     ExtendedMetaData.INSTANCE.setName(documentRootEClass, "");
     ExtendedMetaData.INSTANCE.setContentKind(documentRootEClass, ExtendedMetaData.MIXED_CONTENT);
     

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java Wed Feb 21 04:34:19 2007
@@ -536,7 +536,7 @@
     // currently, we require setSequenced to be called first, before anything else is added to the type.
     if (type.isDataType() || !type.getProperties().isEmpty())
     {
-      if (type.getName() != null) // document root is a special case
+      if (type.getName() != "DocumentRoot") // document root is a special case
         throw new IllegalArgumentException();
     }
     

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java Wed Feb 21 04:34:19 2007
@@ -532,7 +532,7 @@
 
     sequence.addText("\n  ");
 
-    Type definedGlobalType = types.getType("http://www.example.com/open", null);
+    Type definedGlobalType = types.getType("http://www.example.com/open", "DocumentRoot");
     
     Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
     quote.setString(definedSymbolProperty, "fbnt");

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java Wed Feb 21 04:34:19 2007
@@ -51,19 +51,19 @@
 
     // The following constants describe the index for the fields in api_test.xsd.
     
-    private static final int STRING_VAL_INDEX = 1;
-    private static final int BOOLEAN_VAL_INDEX = 2;
-    private static final int BYTE_VAL_INDEX = 4;
-    private static final int DECIMAL_VAL_INDEX = 6;
-    private static final int INT_VAL_INDEX = 8;
-    private static final int FLOAT_VAL_INDEX = 9;
-    private static final int DOUBLE_VAL_INDEX = 10;
-    private static final int DATE_VAL_INDEX = 11;
-    private static final int SHORT_VAL_INDEX = 12;
-    private static final int LONG_VAL_INDEX = 13;
-    private static final int BYTES_VAL_INDEX = 15;
-    private static final int INTEGER_VAL_INDEX = 16;
-    private static final int CHAR_VAL_INDEX = 17;
+    private static final int STRING_VAL_INDEX = 0;
+    private static final int BOOLEAN_VAL_INDEX = 1;
+    private static final int BYTE_VAL_INDEX = 3;
+    private static final int DECIMAL_VAL_INDEX = 5;
+    private static final int INT_VAL_INDEX = 7;
+    private static final int FLOAT_VAL_INDEX = 8;
+    private static final int DOUBLE_VAL_INDEX = 9;
+    private static final int DATE_VAL_INDEX = 10;
+    private static final int SHORT_VAL_INDEX = 11;
+    private static final int LONG_VAL_INDEX = 12;
+    private static final int BYTES_VAL_INDEX = 14;
+    private static final int INTEGER_VAL_INDEX = 15;
+    private static final int CHAR_VAL_INDEX = 16;
     
     // The following variables are Method arrays.  Each array refers to a specific get<Type>, but within
     // the array exist the get<Type>(index), get<Type>(property), and get<Type>(path).  Rather than
@@ -886,4 +886,4 @@
     public void testTuscany_836() {
         assertEquals(DataObjectUtil.getBigDecimal(new Long(Long.MAX_VALUE)).longValue(), Long.MAX_VALUE);
     }
-}
\ No newline at end of file
+}

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java?view=diff&rev=509984&r1=509983&r2=509984
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java Wed Feb 21 04:34:19 2007
@@ -122,7 +122,8 @@
         List components = moduleObject.getList("component");
         DataObject componentObject = (DataObject) components.get(0);
         // componentObject.getDataObject("implementation.mock");
-        DataObject implObject = (DataObject) componentObject.getSequence(0).getValue(0);
+        //DataObject implObject = (DataObject) componentObject.getSequence(0).getValue(0);
+        DataObject implObject = componentObject.getDataObject(componentObject.getProperty("implementation.mock")); //FB
         Assert.assertTrue(implObject.getString("myAttr").equals("helloworld.HelloWorldImpl"));
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org