mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
add context to two methods parameters to have monthly statistics localised
This commit is contained in:
@@ -998,7 +998,7 @@ public class SolrLogger
|
|||||||
*/
|
*/
|
||||||
public static ObjectCount[] queryFacetDate(String query,
|
public static ObjectCount[] queryFacetDate(String query,
|
||||||
String filterQuery, int max, String dateType, String dateStart,
|
String filterQuery, int max, String dateType, String dateStart,
|
||||||
String dateEnd, boolean showTotal) throws SolrServerException
|
String dateEnd, boolean showTotal, Context context) throws SolrServerException
|
||||||
{
|
{
|
||||||
QueryResponse queryResponse = query(query, filterQuery, null, 0, max,
|
QueryResponse queryResponse = query(query, filterQuery, null, 0, max,
|
||||||
dateType, dateStart, dateEnd, null, null, false);
|
dateType, dateStart, dateEnd, null, null, false);
|
||||||
@@ -1018,7 +1018,7 @@ public class SolrLogger
|
|||||||
FacetField.Count dateCount = dateFacet.getValues().get(i);
|
FacetField.Count dateCount = dateFacet.getValues().get(i);
|
||||||
result[i] = new ObjectCount();
|
result[i] = new ObjectCount();
|
||||||
result[i].setCount(dateCount.getCount());
|
result[i].setCount(dateCount.getCount());
|
||||||
result[i].setValue(getDateView(dateCount.getName(), dateType));
|
result[i].setValue(getDateView(dateCount.getName(), dateType, context));
|
||||||
}
|
}
|
||||||
if (showTotal)
|
if (showTotal)
|
||||||
{
|
{
|
||||||
@@ -1051,7 +1051,7 @@ public class SolrLogger
|
|||||||
return objCount;
|
return objCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDateView(String name, String type)
|
private static String getDateView(String name, String type, Context context)
|
||||||
{
|
{
|
||||||
if (name != null && name.matches("^[0-9]{4}\\-[0-9]{2}.*"))
|
if (name != null && name.matches("^[0-9]{4}\\-[0-9]{2}.*"))
|
||||||
{
|
{
|
||||||
@@ -1066,7 +1066,7 @@ public class SolrLogger
|
|||||||
Date date = null;
|
Date date = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_8601);
|
SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_8601, context.getCurrentLocale());
|
||||||
date = format.parse(name);
|
date = format.parse(name);
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
@@ -1076,7 +1076,7 @@ public class SolrLogger
|
|||||||
// We should use the dcdate (the dcdate is used when
|
// We should use the dcdate (the dcdate is used when
|
||||||
// generating random data)
|
// generating random data)
|
||||||
SimpleDateFormat format = new SimpleDateFormat(
|
SimpleDateFormat format = new SimpleDateFormat(
|
||||||
DATE_FORMAT_DCDATE);
|
DATE_FORMAT_DCDATE, context.getCurrentLocale());
|
||||||
date = format.parse(name);
|
date = format.parse(name);
|
||||||
}
|
}
|
||||||
catch (ParseException e1)
|
catch (ParseException e1)
|
||||||
@@ -1100,7 +1100,7 @@ public class SolrLogger
|
|||||||
dateformatString = "yyyy";
|
dateformatString = "yyyy";
|
||||||
}
|
}
|
||||||
SimpleDateFormat simpleFormat = new SimpleDateFormat(
|
SimpleDateFormat simpleFormat = new SimpleDateFormat(
|
||||||
dateformatString);
|
dateformatString, context.getCurrentLocale());
|
||||||
if (date != null)
|
if (date != null)
|
||||||
{
|
{
|
||||||
name = simpleFormat.format(date);
|
name = simpleFormat.format(date);
|
||||||
|
@@ -184,7 +184,7 @@ public class StatisticsDataVisits extends StatisticsData
|
|||||||
String query = dataSetQuery.getQueries().get(0).getQuery();
|
String query = dataSetQuery.getQueries().get(0).getQuery();
|
||||||
if(dataSetQuery.getMax() == -1){
|
if(dataSetQuery.getMax() == -1){
|
||||||
// We are asking from our current query all the visits faceted by date
|
// We are asking from our current query all the visits faceted by date
|
||||||
ObjectCount[] results = SolrLogger.queryFacetDate(query, filterQuery, dataSetQuery.getMax(), dateFacet.getDateType(), dateFacet.getStartDate(), dateFacet.getEndDate(), showTotal);
|
ObjectCount[] results = SolrLogger.queryFacetDate(query, filterQuery, dataSetQuery.getMax(), dateFacet.getDateType(), dateFacet.getStartDate(), dateFacet.getEndDate(), showTotal, context);
|
||||||
dataset = new Dataset(1, results.length);
|
dataset = new Dataset(1, results.length);
|
||||||
// Now that we have our results put em in a matrix
|
// Now that we have our results put em in a matrix
|
||||||
for(int j = 0; j < results.length; j++){
|
for(int j = 0; j < results.length; j++){
|
||||||
@@ -201,7 +201,7 @@ public class StatisticsDataVisits extends StatisticsData
|
|||||||
for (int j = 0; j < maxObjectCounts.length; j++) {
|
for (int j = 0; j < maxObjectCounts.length; j++) {
|
||||||
ObjectCount firstCount = maxObjectCounts[j];
|
ObjectCount firstCount = maxObjectCounts[j];
|
||||||
String newQuery = dataSetQuery.getFacetField() + ": " + ClientUtils.escapeQueryChars(firstCount.getValue()) + " AND " + query;
|
String newQuery = dataSetQuery.getFacetField() + ": " + ClientUtils.escapeQueryChars(firstCount.getValue()) + " AND " + query;
|
||||||
ObjectCount[] maxDateFacetCounts = SolrLogger.queryFacetDate(newQuery, filterQuery, dataSetQuery.getMax(), dateFacet.getDateType(), dateFacet.getStartDate(), dateFacet.getEndDate(), showTotal);
|
ObjectCount[] maxDateFacetCounts = SolrLogger.queryFacetDate(newQuery, filterQuery, dataSetQuery.getMax(), dateFacet.getDateType(), dateFacet.getStartDate(), dateFacet.getEndDate(), showTotal, context);
|
||||||
|
|
||||||
|
|
||||||
// Make sure we have a dataSet
|
// Make sure we have a dataSet
|
||||||
|
Reference in New Issue
Block a user