[commit] r1850 - in trunk: GME/Mga Tests/GPyUnit/GME_310
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Mar 7 11:30:12 CST 2012
Author: ksmyth
Date: Wed Mar 7 11:30:11 2012
New Revision: 1850
Log:
Fix CreateSimpleConnDisp for Ref->Ref->Model case
Modified:
trunk/GME/Mga/MgaConnection.cpp
trunk/Tests/GPyUnit/GME_310/__init__.py
Modified: trunk/GME/Mga/MgaConnection.cpp
==============================================================================
--- trunk/GME/Mga/MgaConnection.cpp Wed Mar 7 11:29:57 2012 (r1849)
+++ trunk/GME/Mga/MgaConnection.cpp Wed Mar 7 11:30:11 2012 (r1850)
@@ -97,17 +97,31 @@
} COMCATCH_IN_TRANSACTION(;)
}
+static CComPtr<IMgaFCOs> GetRefChain(IMgaFCO* fco)
+{
+ CREATEEXCOLLECTION_FOR(MgaFCO, srcrefs);
+
+ CComQIPtr<IMgaReference> ref = fco;
+ while (srcrefs && ref)
+ {
+ srcrefs->Add(ref);
+ CComPtr<IMgaFCO> referred;
+ COMTHROW(ref->get_Referred(&referred));
+ if (referred)
+ {
+ ref.Release();
+ ref = referred;
+ }
+ }
+ return CComQIPtr<IMgaFCOs>(srcrefs);
+}
+
HRESULT FCO::CreateSimpleConnDisp( IMgaMetaRole *metar
, IMgaFCO *srcobj, IMgaFCO *dstobj
, IMgaFCO *srcref, IMgaFCO *dstref
, IMgaFCO **newobj)
{
- CREATEEXCOLLECTION_FOR(MgaFCO, srcrefs);
- CREATEEXCOLLECTION_FOR(MgaFCO, dstrefs);
- if( srcrefs && srcref) srcrefs->Add( CComPtr<IMgaFCO>( srcref));
- if( dstrefs && dstref) dstrefs->Add( CComPtr<IMgaFCO>( dstref));
-
- return CreateSimpleConn( metar, srcobj, dstobj, srcrefs, dstrefs, newobj);
+ return CreateSimpleConn( metar, srcobj, dstobj, GetRefChain(srcref), GetRefChain(dstref), newobj);
}
Modified: trunk/Tests/GPyUnit/GME_310/__init__.py
==============================================================================
--- trunk/Tests/GPyUnit/GME_310/__init__.py Wed Mar 7 11:29:57 2012 (r1849)
+++ trunk/Tests/GPyUnit/GME_310/__init__.py Wed Mar 7 11:30:11 2012 (r1850)
@@ -49,9 +49,41 @@
self.fail("Reference file '%s' does not match output '%s'" % (self.correct_file, self.output_file))
#print "Reference file '%s' matches output '%s'" % (self.correct_file, self.output_file)
+class TestRefportAPI(unittest.TestCase):
+ def __init__(self, *kargs, **kwds):
+ super(TestRefportAPI, self).__init__(*kargs, **kwds)
+
+ def test(self):
+ def _adjacent_file(file):
+ import os.path
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), file)
+ from GPyUnit import util
+ util.register_xmp(_adjacent_file('GME310ModelRefportTest.xmp'))
+
+ with util.disable_early_binding():
+ self.project = DispatchEx("Mga.MgaProject")
+ self.project.Open("MGA=" + _adjacent_file("test1.mga"))
+ self.territory = self.project.BeginTransactionInNewTerr()
+
+ a = self.project.ObjectByPath("/Test1/Folder1/A")
+ b = self.project.ObjectByPath("/Test1/Folder1/A/B")
+ kindAtom = self.project.ObjectByPath("/Test1/Folder1/A/B/KindAtom")
+ self.assertTrue(kindAtom)
+ bref = self.project.ObjectByPath("/Test1/Folder1/A/BRef")
+ brefref = self.project.ObjectByPath("/Test1/Folder1/A/BRefRef")
+ kindConnection = [c for c in a.ChildFCOs if c.Name == "KindConnection"][0]
+ c = a.CreateSimpleConnDisp(kindConnection.MetaRole, kindAtom, kindAtom, None, None)
+ c = a.CreateSimpleConnDisp(kindConnection.MetaRole, kindAtom, kindAtom, bref, brefref)
+
+ self.project.CommitTransaction()
+ self.project.Save("MGA=" + _adjacent_file("TestRefportAPI.mga"))
+ self.territory.Destroy()
+ self.project.Close()
+
def suite():
suite = unittest.TestSuite()
- suite.addTest(TestFolderCopy(input_file="test1.mga", folder_to_copy="/Test1", destination_folder=""))
+ #suite.addTest(TestFolderCopy(input_file="test1.mga", folder_to_copy="/Test1", destination_folder=""))
+ suite.addTest(TestRefportAPI("test"))
return suite
if __name__ == "__main__":
More information about the gme-commit
mailing list