Adding an Edge to a Data Tree

Adding an edge to a data-tree essentially takes an existing relationship and connects the tables together. This allows the data in the child table to be accessed by the parent table. In this example, the relationship is found by searching for relationships on the root table, but you can also create a new relationship. The root of the dataTree determines how the relationship data can be used based on the hierarchy.

            import com.im.commons.progress.*
            import com.im.df.api.util.*

            def structureEty = dataTree.rootVertex.entity

            lock = schema.lockable.obtainLock('Adding edges')
            def envRW = EnvUtils.createDefaultEnvironmentRW(lock, 'Adding edges', true)

            try {
                rel = DIFUtilities.findUsagesInRelationships(structureEty)
                firstRel = rel.get(0)

                def dt1 = DIFUtilities.createDataTreeForEntity(structureEty, envRW)
                dt1.name = 'Structures -> Notations'
                dt1.rootVertex.addEdge(firstRel.forward, env)
            }finally{
                lock?.release()
                envRW?.feedback.finish()
            }
            


Copyright © 1999-2012 ChemAxon Ltd.    All rights reserved.