mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75005: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 70182: WIP, allows date ranges for solr stats queries git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75334 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -10,6 +10,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The results of executing a solr stats query
|
||||
@@ -31,10 +32,13 @@ public class SolrStatsResult implements JSONResult, StatsResultSet
|
||||
private Long mean;
|
||||
|
||||
private List<StatsResultStat> stats;
|
||||
public SolrStatsResult(JSONObject json)
|
||||
private boolean nameIsADate;
|
||||
|
||||
public SolrStatsResult(JSONObject json, boolean nameIsADate)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.nameIsADate = nameIsADate;
|
||||
stats = new ArrayList<>();
|
||||
processJson(json);
|
||||
}
|
||||
@@ -109,7 +113,7 @@ public class SolrStatsResult implements JSONResult, StatsResultSet
|
||||
*/
|
||||
private StatsResultStat processStat(String name, JSONObject facetVal) throws JSONException
|
||||
{
|
||||
return new StatsResultStat(name,
|
||||
return new StatsResultStat(nameIsADate?formatAsDate(name):name,
|
||||
facetVal.getLong("sum"),
|
||||
facetVal.getLong("count"),
|
||||
facetVal.getLong("min"),
|
||||
@@ -117,6 +121,29 @@ public class SolrStatsResult implements JSONResult, StatsResultSet
|
||||
facetVal.getLong("mean"));
|
||||
}
|
||||
|
||||
public static String formatAsDate(String name)
|
||||
{
|
||||
if (StringUtils.hasText(name))
|
||||
{
|
||||
try
|
||||
{
|
||||
//LocalDate d = LocalDate.parse(name);
|
||||
//return d.toString();
|
||||
return name.substring(0,10);
|
||||
}
|
||||
catch (IllegalArgumentException iae)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Can't parse reponse: "+iae.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Default
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@@ -214,7 +214,7 @@ public class SolrQueryHTTPClient implements BeanFactoryAware
|
||||
* @param searchParameters
|
||||
* @return SolrStatsResult
|
||||
*/
|
||||
public SolrStatsResult executeStatsQuery(StatsParameters searchParameters)
|
||||
public SolrStatsResult executeStatsQuery(final StatsParameters searchParameters)
|
||||
{
|
||||
if(repositoryState.isBootstrapping())
|
||||
{
|
||||
@@ -235,7 +235,7 @@ public class SolrQueryHTTPClient implements BeanFactoryAware
|
||||
@Override
|
||||
public SolrStatsResult getResult(JSONObject json)
|
||||
{
|
||||
return new SolrStatsResult(json);
|
||||
return new SolrStatsResult(json, searchParameters.isDateSearch());
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user