Package org.dspace.app.statistics
Class ReportGenerator
- java.lang.Object
-
- org.dspace.app.statistics.ReportGenerator
-
public class ReportGenerator extends Object
This class performs the action of coordinating a usage report being generated using the standard internal aggregation file format as a basis. All it's configuration information must come from that file. There is the opportunity for different output format options such as HTML. Use the -help flag for more information- Author:
- Richard Jones
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetItemInfo(Context context, String handle)get the information for the item with the given handlestatic voidmain(String[] argv)main method to be run from command line.static StatisticsprepareStats(Map<String,String> aggregator, boolean sort, boolean translate)a standard stats block preparation method for use when an aggregator has to be put out in its entirity.static voidprocessReport(Context context, String myFormat, String myInput, String myOutput, String myMap)using the pre-configuration information passed here, read in the aggregation data and output a file containing the report in the requested format this method is retained for backwards compatibility, but delegates the actual wprk to a new methodstatic voidprocessReport(Context context, Report report, String myInput)using the pre-configuration information passed here, read in the aggregation data and output a file containing the report in the requested formatstatic voidreadInput(String input)read the input file and populate all the class globals with the contents The values that come from this file form the basis of the analysis reportstatic voidreadMap(String map)read in the action map file which converts log file line actions into actions which are more understandable to humansstatic voidsetParameters(String myInput)set the passed parameters up as global class variables.static Stringtranslate(String text)look the given text up in the action map table and return a translated value if one exists.static voidusage()output the usage information to the terminal
-
-
-
Method Detail
-
main
public static void main(String[] argv) throws Exception, SQLException
main method to be run from command line. See usage information for details as to how to use the command line flags- Parameters:
argv- the command line arguments given- Throws:
Exception- on generic exceptionSQLException- An exception that provides information on a database access error or other errors.
-
processReport
public static void processReport(Context context, String myFormat, String myInput, String myOutput, String myMap) throws Exception, SQLException
using the pre-configuration information passed here, read in the aggregation data and output a file containing the report in the requested format this method is retained for backwards compatibility, but delegates the actual wprk to a new method- Parameters:
context- the DSpace context in which this action is performedmyFormat- the desired output format (currently on HTML supported)myInput- the aggregation file to be turned into a reportmyOutput- the file into which to write the reportmyMap- the map- Throws:
Exception- if errorSQLException- if database error
-
processReport
public static void processReport(Context context, Report report, String myInput) throws Exception, SQLException
using the pre-configuration information passed here, read in the aggregation data and output a file containing the report in the requested format- Parameters:
context- contextreport- reportmyInput- input- Throws:
Exception- if errorSQLException- if database error
-
prepareStats
public static Statistics prepareStats(Map<String,String> aggregator, boolean sort, boolean translate)
a standard stats block preparation method for use when an aggregator has to be put out in its entirity. This method will not be able to deal with complex cases, although it will perform sorting by value and translations as per the map file if requested- Parameters:
aggregator- the aggregator that should be convertedsort- should the resulting stats be sorted by valuetranslate- translate the stat name using the map file- Returns:
- a Statistics object containing all the relevant information
-
translate
public static String translate(String text)
look the given text up in the action map table and return a translated value if one exists. If no translation exists the original text is returned- Parameters:
text- the text to be translated- Returns:
- a string containing either the translated text or the original text
-
readMap
public static void readMap(String map) throws IOException
read in the action map file which converts log file line actions into actions which are more understandable to humans- Parameters:
map- the map file- Throws:
IOException- if IO error
-
setParameters
public static void setParameters(String myInput)
set the passed parameters up as global class variables. This has to be done in a separate method because the API permits for running from the command line with args or calling the processReport method statically from elsewhere- Parameters:
myInput- regex for log file names
-
readInput
public static void readInput(String input) throws IOException, ParseException
read the input file and populate all the class globals with the contents The values that come from this file form the basis of the analysis report- Parameters:
input- the aggregator file- Throws:
IOException- if IO errorParseException- if parse error
-
getItemInfo
public static String getItemInfo(Context context, String handle) throws SQLException
get the information for the item with the given handle- Parameters:
context- the DSpace context we are operating underhandle- the handle of the item being looked up, in the form 1234/567 and so forth- Returns:
- a string containing a reference (almost citation) to the article
- Throws:
SQLException- if database error
-
usage
public static void usage()
output the usage information to the terminal
-
-