public Map < Timestamp , Collection < DiffPart > > getTimestampToRevisionMap ( final int articleID ) throws WikiApiException { Map < Timestamp , Collection < DiffPart > > tsDiffPartsMap = new HashMap < Timestamp , Collection < DiffPart > > ( ) ; try { if ( articleID < 1 ) { throw new IllegalArgumentException ( ) ; } PreparedStatement statement = null ; ResultSet result = null ; RevisionDecoder decoder = new RevisionDecoder ( config . getCharacterSet ( ) ) ; try { // Check if necessary index exists if ( ! indexExists ( "revisions" ) ) { throw new WikiInitializationException ( "Please create an index on revisions(ArticleID) in order to make this query feasible." ) ; } statement = connection . prepareStatement ( "SELECT Timestamp, Revision " + "FROM revisions WHERE ArticleID=?" ) ; ; statement . setInt ( 1 , articleID ) ; result = statement . executeQuery ( ) ; if ( result == null ) { throw new WikiPageNotFoundException ( "The article with the ID " + articleID + " was not found." ) ; } while ( result . next ( ) ) { // Decode String and create Diff-Object boolean binaryData = result . getMetaData ( ) . getColumnType ( 2 ) == Types . LONGVARBINARY ; if ( binaryData ) { decoder . setInput ( result . getBinaryStream ( 2 ) , true ) ; } else { decoder . setInput ( result . getString ( 2 ) ) ; } Diff diff = decoder . decode ( ) ; // Get DiffParts from Diff Object Collection < DiffPart > parts = new LinkedList < DiffPart > ( ) ; Iterator < DiffPart > it = diff . iterator ( ) ; while ( it . hasNext ( ) ) { parts . add ( it . next ( ) ) ; } // Write data from current revision to Map tsDiffPartsMap . put ( new Timestamp ( result . getLong ( 1 ) ) , parts ) ; } } finally { if ( statement != null ) { statement . close ( ) ; } if ( result != null ) { result . close ( ) ; } } return tsDiffPartsMap ; } catch ( WikiApiException e ) { throw e ; } catch ( Exception e ) { throw new WikiApiException ( e ) ; } }
Returns a map of timestamps mapped on the corresponding DiffPart - Collections . Can be used to compile statistics over all changes that have been made in one article .