public Map < Long , String > getFormDefinitionIdAndTitle ( ) { //When already cached, use the cached value... if ( ! LOCAL_MAPPING . isEmpty ( ) ) { Map < Long , String > returnVal = new HashMap <> ( LOCAL_MAPPING ) ; //The id's are outdated... if ( System . currentTimeMillis ( ) > timeToUpdateAgain ) { synchronized ( LOCAL_MAPPING ) { LOCAL_MAPPING . clear ( ) ; } } return returnVal ; } //Only allow one thread to set the local mapping... synchronized ( LOCAL_MAPPING ) { if ( ! LOCAL_MAPPING . isEmpty ( ) ) { return new HashMap <> ( LOCAL_MAPPING ) ; } PreparedStatement preparedStatement = null ; ResultSet resultSet = null ; try { ISyntax syntax = SyntaxFactory . getInstance ( ) . getSyntaxFor ( this . getSQLTypeFromConnection ( ) , ISyntax . ProcedureMapping . FormDefinition . GetFormDefinitions ) ; preparedStatement = this . getConnection ( ) . prepareStatement ( syntax . getPreparedStatement ( ) ) ; resultSet = preparedStatement . executeQuery ( ) ; //Iterate each of the form containers... while ( resultSet . next ( ) ) { Long id = resultSet . getLong ( 1 ) ; String title = resultSet . getString ( 2 ) ; LOCAL_MAPPING . put ( id , title ) ; } //Update in 10 mins... timeToUpdateAgain = ( System . currentTimeMillis ( ) + TimeUnit . MINUTES . toMillis ( 10 ) ) ; } // catch ( SQLException sqlError ) { throw new FluidSQLException ( sqlError ) ; } // finally { this . closeStatement ( preparedStatement , resultSet ) ; } return new HashMap <> ( LOCAL_MAPPING ) ; } }
Retrieves the Form Definition and Title mapping currently stored in Fluid .