Add code-comment for the ES classes

Also removed an unused function in report generator
This commit is contained in:
Peter Dietz
2012-09-19 00:40:24 -04:00
parent 52b499f2dc
commit f3b3f73b80
4 changed files with 7 additions and 86 deletions

View File

@@ -40,11 +40,8 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by IntelliJ IDEA.
* User: peterdietz
* Date: 4/20/12
* Time: 3:28 PM
* To change this template use File | Settings | File Templates.
* Provides the usage statistics in CSV form
* @author Peter Dietz (pdietz84@gmail.com)
*/
public class CSVOutputter extends AbstractReader implements Recyclable
{

View File

@@ -37,11 +37,9 @@ import java.util.*;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User: peterdietz
* Date: 3/7/12
* Time: 11:54 AM
* To change this template use File | Settings | File Templates.
* Usage Statistics viewer, powered by Elastic Search.
* Allows for the user to dig deeper into the statistics for topDownloads, topCountries, etc.
* @author Peter Dietz (pdietz84@gmail.com)
*/
public class ElasticSearchStatsViewer extends AbstractDSpaceTransformer {
private static Logger log = Logger.getLogger(ElasticSearchStatsViewer.class);

View File

@@ -26,6 +26,7 @@ import java.util.Map;
* Use a form to dynamically generate a variety of reports.
*
* @author "Ryan McGowan" ("mcgowan.98@osu.edu")
* @author Peter Dietz (pdietz84@gmail.com)
* @version
*/
public class ReportGenerator
@@ -153,77 +154,4 @@ public class ReportGenerator
}
}
/**
* Checks the parameters of the given request to see if they fit the
* necessary criteria to run generate a report. The following must be true:
*
* * from - Must be convertable to a valid date that is greater than the
* miniumum date and also less than or equal to the current date.
* * to - Must be convertable to a valid date that is greater than from
* and equal to or less than the current date.
*
* @return A map of valid parameters to their values.
* @throws InvalidFormatException
* @throws ParseException
*/
private Map<String,String> checkAndNormalizeParameters(Map<String,String> params) {
try {
//Create dateValidator and min and max dates
DateValidator dateValidator = new DateValidator(false, DateFormat.SHORT);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Date maximumDate = new Date();
Date minimumDate = dateFormat.parse(ReportGenerator.MINIMUM_DATE);
//Check the to and from dates
Date fromDate = null;
Date toDate = null;
boolean validToAndFrom = true;
boolean hasFrom = params.containsKey("from") && params.get("from").length() > 0;
boolean hasTo = params.containsKey("to") && params.get("to").length() > 0;
if (hasFrom || hasTo) {
if (hasFrom) {
fromDate = tryParse(params.get("from"));
params.put("from", dateFormat.format(fromDate));
validToAndFrom = validToAndFrom && dateValidator.compareDates(minimumDate, fromDate, null) <= 0;
}
if (hasTo) {
toDate = tryParse(params.get("to"));
params.put("to", dateFormat.format(toDate));
validToAndFrom = validToAndFrom && dateValidator.compareDates(toDate, maximumDate, null) <= 0;
}
if (hasFrom && hasTo) {
//Make sure hasFrom <= hasTo
validToAndFrom = validToAndFrom && dateValidator.compareDates(fromDate, toDate, null) <= 0;
} else if (hasFrom && !hasTo) {
//Make sure hasFrom <= the max date
validToAndFrom = validToAndFrom && dateValidator.compareDates(fromDate, maximumDate, null) <= 0;
} else {
//hasTo && !hasFrom
//Make sure hasTo >= the min date
validToAndFrom = validToAndFrom && dateValidator.compareDates(minimumDate, toDate, null) <= 0;
}
// Short circuit if the to and from dates are not valid
if (!validToAndFrom) {
log.error("To and from dates are not within max/min or are not in order. "+ params.get("from") + " -> " + params.get("to"));
return null;
}
//Check fiscal
if (params.containsKey("fiscal")) {
log.debug("fiscal: " + params.get("fiscal"));
if (Integer.parseInt(params.get("fiscal")) != 1) {
log.error("Fiscal field did not contain a proper value: " + params.get("fiscal"));
}
}
}
return params;
} catch (ParseException e) {
log.error("ParseFormatException likely means a date format failed. "+e.getMessage()); //To change body of catch statement use File | Settings | File Templates.
return null;
}
}
}

View File

@@ -20,9 +20,7 @@ import java.util.Map;
/**
* Part of cocoon authentication for resource. Requires that user (eperson) is a member of a specified group.
*
* Author: Peter Dietz dietz.72@osu.edu - The Ohio State University Libraries
* Date: 5/11/12
* Time: 2:29 PM
* @author Peter Dietz (pdietz84@gmailcom)
*/
public class SpecifiedGroupAuthenticatedSelector implements Selector {
private static Logger log = Logger.getLogger(SpecifiedGroupAuthenticatedSelector.class);