You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/12/07 11:59:44 UTC

svn commit: r483416 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/ test/

Author: robbinspg
Date: Thu Dec  7 02:59:41 2006
New Revision: 483416

URL: http://svn.apache.org/viewvc?view=rev&rev=483416
Log:
Remove restriction of mixing DataObjects from different DataFactory instances in a graph

Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp Thu Dec  7 02:59:41 2006
@@ -1651,69 +1651,6 @@
     return getDASValue(typeuri.c_str(), typenam.c_str(), propertyName.c_str(), name.c_str());
 }
 
-bool DataFactoryImpl::compareTypes(const TypeImpl* t1, const Type& t2)
-{
-    PropertyList pl = t2.getProperties();
-    for (unsigned int i=0;i<pl.size();i++)
-    {
-        PropertyImpl* p = t1->getPropertyImpl(i);
-        if (p == 0) return false;
-        if (p->isMany() != pl[i].isMany()) return false;
-        if (p->isContainment() != pl[i].isContainment()) return false;
-        if (strcmp(   p->getType().getURI(),
-                   pl[i].getType().getURI())) return false;
-        if (strcmp(   p->getType().getName(),
-                   pl[i].getType().getName())) return false;
-    }
-    return true;
-
-}
-bool DataFactoryImpl::checkType(const Type& t)
-{
-    const TypeImpl* t2 = findTypeImpl(t.getURI(),
-                                     t.getName());
- 
-    if (t2 == 0) return false;
- 
-    if (!compareTypes(t2,t)) return false;
-
-    PropertyList pl = t.getProperties();
-    for (unsigned int i=0;i<pl.size();i++)
-    {
-        if (pl[i].getType().isDataObjectType())
-        {
-            if (pl[i].isReference())
-                continue;
-            if (!checkType(pl[i].getType())) return false;
-        }
-    }
-    return true;
-}
- 
-
-// only checks the tree dirctly descended from this object if the
-// object is specified, otherwise validates the whole factory
-
-bool DataFactoryImpl::isCompatible(DataFactory* df, DataObject* d)
-{
-    if (d == 0)
-    {
-        TypeList tl = df->getTypes();
-        for (unsigned int j=0;j<tl.size();j++)
-        {
-            const TypeImpl* t = findTypeImpl(tl[j].getURI(),
-                                        tl[j].getName());
- 
-            if (t == 0) return false;
-            if (!compareTypes(t,tl[j]))return false;
-        }
-        return true;
-    }
-    else
-    {
-        return checkType(d->getType());
-    }
-}
 
 bool DataFactoryImpl::generateInterface(const char* fileroot, const char* factoryname)
 {

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h Thu Dec  7 02:59:41 2006
@@ -663,9 +663,6 @@
     virtual const TypeImpl& getTypeImpl(const SDOString& uri, const SDOString& inTypeName) const;
     virtual const SDOString& getRootElementName() const;
     virtual void setRootElementName(const SDOString& ren);
-    virtual bool checkType(const Type& t);
-    virtual bool isCompatible(DataFactory* df, DataObject* d);
-    virtual bool compareTypes(const TypeImpl* t1, const Type& t2);
 
     virtual bool generateInterface(const char* fileroot, const char* factoryname);
     virtual bool generateInterface(const SDOString& fileroot, const SDOString& factoryname);

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Thu Dec  7 02:59:41 2006
@@ -2336,51 +2336,6 @@
         }
     }
 
-    void DataObjectImpl::transferChildren(DataObject* d, DataFactory* f)
-    {
-        bool isData = false;
-        PropertyList pl = d->getInstanceProperties();
-        for (unsigned int i=0;i<pl.size();i++)
-        {
-            // even primitives need their DF fixed up
-            if (pl[i].getType().isDataType())
-            {
-                 isData = true;
-            }
-
-            if (pl[i].isReference())
-                continue;
-
-            if (!d->isSet(pl[i]) || d->isNull(pl[i]))
-            {
-                continue;
-            }
-            if (pl[i].isMany())
-            {
-                DataObjectList& dl = d->getList(pl[i]);
-                for (unsigned int j=0;j<dl.size();j++)
-                {
-                    
-                    DataObject* d2 = dl[j];
-                    if (d2) {
-                        ((DataObjectImpl*)d2)->setDataFactory(f);
-                        if (!isData)transferChildren(d2,f);
-                    }
-                }
-            }
-            else
-            {
-                DataObject* d3 = d->getDataObject(pl[i]);
-                if (d3)
-                { 
-                    ((DataObjectImpl*)d3)->setDataFactory(f);
-                    if (!isData)transferChildren(d3,f);
-                }
-            }
-        }
-    }
-
-
 
     void DataObjectImpl::checkFactory(DataObjectPtr dob,
         unsigned int propertyIndex)
@@ -2390,13 +2345,6 @@
 
         if (d->getDataFactory() == getDataFactory()) return;
 
-        // Temporary alteration to test the feasibility and
-        // problems associated with allowing data object 'migration'
-        // lets move this one and all its children to the factory of the
-        // new parent if the factories are compatible.
-        
-        DataFactoryImpl* f = (DataFactoryImpl*)getDataFactory();
-
         if (d->getContainer() != 0)
         {
             string msg("Insertion of object from another factory is only allowed if the parent is null: ");
@@ -2414,29 +2362,6 @@
                 msg.c_str());
         }
 
-        if (f->isCompatible(d->getDataFactory(),d))
-        {
-            d->setDataFactory(getDataFactory());
-            transferChildren(d,getDataFactory());
-            return;
-        }
-
-
-        // This is the default position....
-        
-        string msg("Insertion from incompatible factory ");
-        const Type& t = d->getType();
-        msg += t.getURI();
-        msg += "#";
-        msg += t.getName();
-        msg += " into property ";
-        msg += getProperty(propertyIndex).getName();
-        msg += " of ";
-        msg += getType().getURI();
-        msg += "#";
-        msg += getType().getName();
-        SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
-            msg.c_str());
     }
 
 

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Thu Dec  7 02:59:41 2006
@@ -591,7 +591,6 @@
     virtual const PropertyImpl* defineList(const char* propname);
     virtual void  undefineProperty(unsigned int index);
     virtual const TypeImpl& getTypeImpl();
-    virtual void transferChildren(DataObject* d, DataFactory* f);
     virtual void setDataFactory(DataFactory *df);
 
     virtual std::ostream& printSelf(std::ostream &os);

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp Thu Dec  7 02:59:41 2006
@@ -280,13 +280,6 @@
 
         if (d->getDataFactory() == theFactory) return;
 
-        // temporary experiment with allowing data objects
-        // to move from factory to factory if the type is 
-        // nominally present, and the type systems match
-
-        DataFactoryImpl* f = (DataFactoryImpl*)theFactory;
-
-
         if (d->getContainer() != 0)
         {
             std::string msg("Insertion of object into list from another factory is only allowed if the parent is null: ");
@@ -304,31 +297,6 @@
             SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
             msg.c_str());
         }
-
-        if (f->isCompatible(d->getDataFactory(),d))
-        {
-            d->setDataFactory(theFactory);
-            // we will also need to transfer any children - assuming they
-            // are ok in the new factory!!
-            d->transferChildren(d,theFactory);
-            return;
-        }
-
-        std::string msg("Insertion into list from incompatible factory:");
-        
-        const Type& t = d->getType();
-        msg += t.getURI();
-        msg += "#";
-        msg += t.getName();
-        msg += " into property  ";
-        msg += container->getProperty(pindex).getName();
-        msg += " of type ";
-        msg += typeURI;
-        msg += "#";
-        msg += typeName;
-        SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException,
-            msg.c_str());
-
     }
 
 

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Thu Dec  7 02:59:41 2006
@@ -46,6 +46,8 @@
     int totaltests=0;
     int value = 0;
 
+    // TEST ( sdotest::upandatom() );
+
     /* TEST ( sdotest::xhtml1() ); */
     TEST ( sdotest::scopetest() );
     TEST ( sdotest::xsdtosdo() );

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Thu Dec  7 02:59:41 2006
@@ -201,4 +201,5 @@
         static int cdatatest();
         static int cloneopentest();
         static int tuscany963();
+        static int upandatom();
 };

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?view=diff&rev=483416&r1=483415&r2=483416
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Thu Dec  7 02:59:41 2006
@@ -418,10 +418,11 @@
 
     if (!transferto(root,f2, false)) return 0;
     if (!transferto(root,f3, true)) return 0;
-    if (!transferto(root,f4, true)) return 0;
-    if (!transferto(root,f5, true)) return 0;
-    if (!transferto(root,f6, true)) return 0;
-    if (!transferto(root,f7, true)) return 0;
+    // Following 4 tests do not now cause an error
+    if (!transferto(root,f4, false)) return 0; 
+    if (!transferto(root,f5, false)) return 0;
+    if (!transferto(root,f6, false)) return 0;
+    if (!transferto(root,f7, false)) return 0;
 
     // finally, lets move one which has a parent and cant be moved.
 
@@ -1512,6 +1513,34 @@
     catch (SDORuntimeException e)
     {
         cout << "Exception in tuscany963" << e << endl;
+        return 0;
+    }
+}
+
+int sdotest::upandatom()
+{
+
+
+    try {
+        DataFactoryPtr mdg  = DataFactory::getDataFactory();
+        DataFactoryPtr df  = DataFactory::getDataFactory();
+        
+        XSDHelperPtr xsh = HelperProvider::getXSDHelper(mdg);
+        xsh->defineFile("Atom/Atom1.0.xsd");
+
+        XSDHelperPtr xh = HelperProvider::getXSDHelper(df); 
+        xh->defineFile("Atom/Atom1.0.xsd");
+
+        DataObjectPtr block = mdg->create("http://www.w3.org/1999/xhtml", "Block");
+        DataObjectPtr div = df->create("http://www.w3.org/1999/xhtml", "div");
+
+        block->setDataObject("div", div);
+        return 1;
+        
+    }
+    catch (SDORuntimeException e)
+    {
+        cout << "Exception in upandatom" << e << endl;
         return 0;
     }
 }



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