{
throw new IllegalArgumentException(
"UUID not specified");
}
SummaryStatBean statBean = new SummaryStatBean();
statBean.setFreq(freq);
String dateType = null;
String dateStart = null;
String dateEnd = null;
int gap = 1;
context.setAutoCommit(false);
for (int i = 0; i < num; i++)
{
switch (freq)
{
case StatSubscription.FREQUENCY_DAILY:
dateType = "DAY";
dateStart = "-" + (num - i);
dateEnd = "-" + (num - 1 - i);
break;
case StatSubscription.FREQUENCY_WEEKLY:
Calendar c = Calendar.getInstance();
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
// se domenica allora vale 1
// se lunedi' vale vale 2, etc
// sabato 7
dateType = "DAY";
gap = 7;
dateStart = "-"
+ (7 * (num - i) + (dayOfWeek - 1 > 0 ? dayOfWeek - 1
: dayOfWeek - 1 + 7));
dateEnd = "-"
+ (7 * (num - i - 1) + (dayOfWeek - 1 > 0 ? dayOfWeek - 1
: dayOfWeek - 1 + 7));
break;
case StatSubscription.FREQUENCY_MONTHLY:
dateType = "MONTH";
dateStart = "-" + (num - i);
dateEnd = "-" + (num - 1 - i);
break;
default:
throw new IllegalArgumentException("Unknow frequency " + freq);
}
Researcher researcher = new Researcher();
Map<String, Map<String,ObjectCount[]>> selectedObject = new HashMap<String, Map<String,ObjectCount[]>>();
Map<String, Map<String,ObjectCount[]>> topObject = new TreeMap<String, Map<String,ObjectCount[]>>();
if (type >= 9)
{
ACrisObject object = as.getEntityByUUID(uuid);
String persistentIdentifier = ResearcherPageUtils
.getPersistentIdentifier(object);
statBean.setObject(object);
statBean.setObjectName(object.getName());
statBean.setObjectURL(ConfigurationManager
.getProperty("dspace.url")
+ "/cris/"
+ object.getPublicPath() + "/" + persistentIdentifier);
statBean.setStatURL(ConfigurationManager
.getProperty("dspace.url")
+ "/cris/stats/"
+ object.getPublicPath()
+ ".html?id="
+ object.getUuid());
statBean.setType(object.getType());
selectedObject = new HashMap<String, Map<String,ObjectCount[]>>();
CrisStatComponentsService statsComponentsService = null;
switch (type)
{
case 9:
statsComponentsService = researcher.getRPStatsComponents();
break;
case 10:
statsComponentsService = researcher.getPJStatsComponents();
break;
case 11:
statsComponentsService = researcher.getOUStatsComponents();
break;
default:
break;
}
selectedObject.put(AStatComponentService._SELECTED_OBJECT, statsComponentsService.getSelectedObjectComponent().getStatsViewComponent().queryFacetDate(statsLogger, object, dateType, dateStart, dateEnd, gap));
selectedObject.get(AStatComponentService._SELECTED_OBJECT).putAll(statsComponentsService.getSelectedObjectComponent().getStatsDownloadComponent().queryFacetDate(statsLogger, object, dateType, dateStart, dateEnd, gap));
for(String key : statsComponentsService.getComponents().keySet()) {
IStatsComponent dual = statsComponentsService.getComponents().get(key).getStatsViewComponent();
topObject.put(key, dual.queryFacetDate(statsLogger, object, dateType, dateStart, dateEnd, gap));
dual = statsComponentsService.getComponents().get(key).getStatsDownloadComponent();
topObject.get(key).putAll(dual.queryFacetDate(statsLogger, object, dateType, dateStart, dateEnd, gap));
}
}
else
{
DSpaceObject dso = HandleManager.resolveToObject(context,
uuid);
if (dso == null)
{
throw new IllegalArgumentException("Invalid handle: "
+ uuid + " DSpace object not found");
}
statBean.setObject(dso);
statBean.setObjectName(dso.getName());
statBean.setObjectURL(ConfigurationManager
.getProperty("dspace.url") + "/handle/" + uuid);
statBean.setType(dso.getType());
switch (dso.getType())
{
case Constants.ITEM:
StatComponentsService serviceItem = researcher.getItemStatsComponents();
retrieveResults(dateType, dateStart, dateEnd, gap,
selectedObject, topObject, dso, serviceItem);
statBean.setStatURL(ConfigurationManager
.getProperty("dspace.url")
+ "/cris/stats/item.html?handle=" + uuid);
break;
case Constants.COLLECTION:
StatComponentsService serviceColl = researcher.getCollectionStatsComponents();
retrieveResults(dateType, dateStart, dateEnd, gap,
selectedObject, topObject, dso, serviceColl);
statBean.setStatURL(ConfigurationManager
.getProperty("dspace.url")
+ "/cris/stats/collection.html?handle=" + uuid);
break;
case Constants.COMMUNITY:
StatComponentsService serviceComm = researcher.getCommunityStatsComponents();
retrieveResults(dateType, dateStart, dateEnd, gap,
selectedObject, topObject, dso, serviceComm);
statBean.setStatURL(ConfigurationManager
.getProperty("dspace.url")
+ "/cris/stats/community.html?handle=" + uuid);
break;
default: