public static OrientGraph getGraph ( final boolean autoStartTx , OModifiableBoolean shouldBeShutDown ) { final ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal . instance ( ) . get ( ) ; final OrientBaseGraph result = OrientBaseGraph . getActiveGraph ( ) ; if ( result != null && ( result instanceof OrientGraph ) ) { final ODatabaseDocumentInternal graphDb = result . getRawGraph ( ) ; // CHECK IF THE DATABASE + USER IN TL IS THE SAME IN ORDER TO USE IT if ( canReuseActiveGraph ( graphDb , database ) ) { if ( ! graphDb . isClosed ( ) ) { ODatabaseRecordThreadLocal . instance ( ) . set ( graphDb ) ; if ( autoStartTx && autoTxStartRequired ( graphDb ) ) ( ( OrientGraph ) result ) . begin ( ) ; shouldBeShutDown . setValue ( false ) ; return ( OrientGraph ) result ; } } } // Set it again on ThreadLocal because the getRawGraph() may have set a closed db in the thread-local ODatabaseRecordThreadLocal . instance ( ) . set ( database ) ; shouldBeShutDown . setValue ( true ) ; final OrientGraph g = ( OrientGraph ) OrientGraphFactory . getTxGraphImplFactory ( ) . getGraph ( database , false ) ; if ( autoStartTx && autoTxStartRequired ( database ) ) g . begin ( ) ; return g ; }
Returns a Transactional OrientGraph implementation from the current database in thread local .