protected void initialize ( final String _sql ) throws EFapsException { Connection con = null ; try { con = Context . getConnection ( ) ; Statement stmt = null ; long parentId = 0 ; try { stmt = con . createStatement ( ) ; // read run level itself ResultSet rs = stmt . executeQuery ( _sql ) ; if ( rs . next ( ) ) { this . id = rs . getLong ( 1 ) ; parentId = rs . getLong ( 2 ) ; } else { RunLevel . LOG . error ( "RunLevel not found" ) ; } rs . close ( ) ; // read all methods for one run level rs = stmt . executeQuery ( RunLevel . SELECT_DEF_PRE . getCopy ( ) . addPart ( SQLPart . WHERE ) . addColumnPart ( 0 , "RUNLEVELID" ) . addPart ( SQLPart . EQUAL ) . addValuePart ( this . id ) . addPart ( SQLPart . ORDERBY ) . addColumnPart ( 0 , "PRIORITY" ) . getSQL ( ) ) ; /** * Order part of the SQL select statement. */ //private static final String SQL_DEF_POST = " order by PRIORITY"; while ( rs . next ( ) ) { if ( rs . getString ( 3 ) != null ) { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) , rs . getString ( 3 ) . trim ( ) ) ) ; } else { this . cacheMethods . add ( new CacheMethod ( rs . getString ( 1 ) . trim ( ) , rs . getString ( 2 ) . trim ( ) ) ) ; } } rs . close ( ) ; } finally { if ( stmt != null ) { stmt . close ( ) ; } } con . commit ( ) ; con . close ( ) ; RunLevel . ALL_RUNLEVELS . put ( this . id , this ) ; if ( parentId != 0 ) { this . parent = RunLevel . ALL_RUNLEVELS . get ( parentId ) ; if ( this . parent == null ) { this . parent = new RunLevel ( parentId ) ; } } } catch ( final EFapsException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } catch ( final SQLException e ) { RunLevel . LOG . error ( "initialise()" , e ) ; } finally { try { if ( con != null && ! con . isClosed ( ) ) { con . close ( ) ; } } catch ( final SQLException e ) { throw new CacheReloadException ( "Cannot read a type for an attribute." , e ) ; } } }
Reads the id and the parent id of this RunLevel . All defined methods for this run level are loaded . If a parent id is defined the parent is initialized .