mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
Add code-comment for the ES classes
Also removed an unused function in report generator
This commit is contained in:
@@ -40,11 +40,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Provides the usage statistics in CSV form
|
||||||
* User: peterdietz
|
* @author Peter Dietz (pdietz84@gmail.com)
|
||||||
* Date: 4/20/12
|
|
||||||
* Time: 3:28 PM
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
*/
|
||||||
public class CSVOutputter extends AbstractReader implements Recyclable
|
public class CSVOutputter extends AbstractReader implements Recyclable
|
||||||
{
|
{
|
||||||
|
@@ -37,11 +37,9 @@ import java.util.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Usage Statistics viewer, powered by Elastic Search.
|
||||||
* User: peterdietz
|
* Allows for the user to dig deeper into the statistics for topDownloads, topCountries, etc.
|
||||||
* Date: 3/7/12
|
* @author Peter Dietz (pdietz84@gmail.com)
|
||||||
* Time: 11:54 AM
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
*/
|
||||||
public class ElasticSearchStatsViewer extends AbstractDSpaceTransformer {
|
public class ElasticSearchStatsViewer extends AbstractDSpaceTransformer {
|
||||||
private static Logger log = Logger.getLogger(ElasticSearchStatsViewer.class);
|
private static Logger log = Logger.getLogger(ElasticSearchStatsViewer.class);
|
||||||
|
@@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
* Use a form to dynamically generate a variety of reports.
|
* Use a form to dynamically generate a variety of reports.
|
||||||
*
|
*
|
||||||
* @author "Ryan McGowan" ("mcgowan.98@osu.edu")
|
* @author "Ryan McGowan" ("mcgowan.98@osu.edu")
|
||||||
|
* @author Peter Dietz (pdietz84@gmail.com)
|
||||||
* @version
|
* @version
|
||||||
*/
|
*/
|
||||||
public class ReportGenerator
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -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.
|
* 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
|
* @author Peter Dietz (pdietz84@gmailcom)
|
||||||
* Date: 5/11/12
|
|
||||||
* Time: 2:29 PM
|
|
||||||
*/
|
*/
|
||||||
public class SpecifiedGroupAuthenticatedSelector implements Selector {
|
public class SpecifiedGroupAuthenticatedSelector implements Selector {
|
||||||
private static Logger log = Logger.getLogger(SpecifiedGroupAuthenticatedSelector.class);
|
private static Logger log = Logger.getLogger(SpecifiedGroupAuthenticatedSelector.class);
|
||||||
|
Reference in New Issue
Block a user