本文整理汇总了Java中org.alfresco.service.cmr.search.SearchParameters.setRanges方法的典型用法代码示例。如果您正苦于以下问题:Java SearchParameters.setRanges方法的具体用法?Java SearchParameters.setRanges怎么用?Java SearchParameters.setRanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.search.SearchParameters
的用法示例。
在下文中一共展示了SearchParameters.setRanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBuildRangeDate
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildRangeDate() throws UnsupportedEncodingException
{
TimeZone defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
SearchParameters params = new SearchParameters();
params.setSearchTerm("A*");
List<RangeParameters> ranges = new ArrayList<RangeParameters>();
ranges.add(new RangeParameters("created", "2015", "2016", "+1MONTH", true, Collections.emptyList(), Collections.emptyList(), null, null));
params.setRanges(ranges);
StringBuilder urlBuilder = new StringBuilder();
client.buildRangeParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("&facet.range=created"));
assertTrue(url.contains("&f.created.facet.range.start=2015-01-01T00%3A00%3A00.000Z"));
assertTrue(url.contains("&f.created.facet.range.end=2016-12-31T23%3A59%3A59.999Z"));
assertTrue(url.contains("&f.created.facet.range.gap=%2B1MONTH"));
TimeZone.setDefault(defaultTimeZone);
}
示例2: fromRange
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
/**
* Sets the Range Parameters object on search parameters
* @param sp SearchParameters
* @param rangeParams RangeParameters
*/
public void fromRange(SearchParameters sp, List<RangeParameters> ranges)
{
if(ranges != null && !ranges.isEmpty())
{
for(RangeParameters rangeParams : ranges)
{
ParameterCheck.mandatory("ranges", rangeParams);
ParameterCheck.mandatory("field", rangeParams.getField());
ParameterCheck.mandatory("start", rangeParams.getStart());
ParameterCheck.mandatory("end", rangeParams.getEnd());
ParameterCheck.mandatory("gap", rangeParams.getGap());
}
sp.setRanges(ranges);
}
}
示例3: testBuildPivots
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildPivots() throws UnsupportedEncodingException
{
SearchParameters params = new SearchParameters();
params.setSearchTerm("bob");
params.addPivots(Arrays.asList("creator"));
params.setStats(Arrays.asList(
new StatsRequestParameters("created", "piv1", null, null, null,null, null, null, null,
null, null, null, null,null, null, null)
));
List<RangeParameters> ranges = new ArrayList<RangeParameters>();
ranges.add(new RangeParameters("content.size","0","1000000", "10000", true, Collections.emptyList(), Collections.emptyList(), "csize",null));
params.setRanges(ranges);
StringBuilder urlBuilder = new StringBuilder();
client.buildPivotParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("facet.pivot=creator"));
params.addPivots(Arrays.asList("cm:name", "piv1", "csize"));
urlBuilder = new StringBuilder();
client.buildPivotParameters(params, encoder, urlBuilder);
url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("facet.pivot="+ encoder.encode("creator", "UTF-8")));
assertTrue(url.contains("facet.pivot="+ encoder.encode("{! stats=piv1 range=csize}cm:name", "UTF-8")));
}
示例4: testBuildMulitRange
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildMulitRange() throws UnsupportedEncodingException
{
SearchParameters params = new SearchParameters();
params.setSearchTerm("A*");
List<RangeParameters> ranges = new ArrayList<RangeParameters>();
List<String>includes = new ArrayList<String>();
includes.add("upper");
includes.add("outer");
List<String>includes2 = new ArrayList<String>();
includes2.add("lower");
List<String> other = new ArrayList<String>();
other.add("before");
ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, other, includes, null, null));
ranges.add(new RangeParameters("created", "2015-09-29T10:45:15.729Z", "2016-09-29T10:45:15.729Z", "+100DAY", true, other, includes2, null, null));
params.setRanges(ranges);
StringBuilder urlBuilder = new StringBuilder();
client.buildRangeParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("&facet.range=content.size"));
assertTrue(url.contains("&f.content.size.facet.range.start=0"));
assertTrue(url.contains("&f.content.size.facet.range.end=1000000"));
assertTrue(url.contains("&f.content.size.facet.range.gap=10000"));
assertTrue(url.contains("&f.content.size.facet.range.include=upper"));
assertTrue(url.contains("&f.content.size.facet.range.include=outer"));
assertTrue(url.contains("&f.content.size.facet.range.hardend=true"));
assertTrue(url.contains("&facet.range=created"));
assertTrue(url.contains("&f.created.facet.range.start=2015-09-29T10%3A45%3A15.729Z"));
assertTrue(url.contains("&f.created.facet.range.end=2016-09-29T10%3A45%3A15.729Z"));
assertTrue(url.contains("&f.created.facet.range.gap=%2B100DAY"));
assertTrue(url.contains("&f.created.facet.range.other=before"));
assertTrue(url.contains("&f.created.facet.range.include=lower"));
assertTrue(url.contains("&f.created.facet.range.hardend=true"));
}
示例5: testBuildRange
import org.alfresco.service.cmr.search.SearchParameters; //导入方法依赖的package包/类
@Test
public void testBuildRange() throws UnsupportedEncodingException
{
SearchParameters params = new SearchParameters();
params.setSearchTerm("A*");
List<RangeParameters> ranges = new ArrayList<RangeParameters>();
List<String>includes = new ArrayList<String>();
includes.add("upper");
includes.add("outer");
List<String> other = new ArrayList<String>();
other.add("before");
other.add("between");
ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, other, includes, null, null));
params.setRanges(ranges);
StringBuilder urlBuilder = new StringBuilder();
client.buildRangeParameters(params, encoder, urlBuilder);
String url = urlBuilder.toString();
assertNotNull(url);
assertTrue(url.contains("&facet=true"));
assertTrue(url.contains("&facet.range=content.size"));
assertTrue(url.contains("&f.content.size.facet.range.start=0"));
assertTrue(url.contains("&f.content.size.facet.range.end=1000000"));
assertTrue(url.contains("&f.content.size.facet.range.gap=10000"));
assertTrue(url.contains("&f.content.size.facet.range.include=upper"));
assertTrue(url.contains("&f.content.size.facet.range.include=outer"));
assertTrue(url.contains("&f.content.size.facet.range.other=before"));
assertTrue(url.contains("&f.content.size.facet.range.other=between"));
assertTrue(url.contains("&f.content.size.facet.range.hardend=true"));
List<String> filters = new ArrayList<String>();
filters.add("ex1");
ranges.clear();
ranges.add(new RangeParameters("content.size", "0", "1000000", "10000", true, Collections.emptyList(), Collections.emptyList(), "doc", filters));
params.setRanges(ranges);
urlBuilder = new StringBuilder();
client.buildRangeParameters(params, encoder, urlBuilder);
String url2 = urlBuilder.toString();
assertTrue(url2.contains("&facet=true"));
assertTrue(url2.contains("&facet.range="+encoder.encode("{!tag=doc }", "UTF-8")+"content.size"));
assertTrue(url2.contains("&f.content.size.facet.range.start=0"));
assertTrue(url2.contains("&f.content.size.facet.range.end=1000000"));
assertTrue(url2.contains("&f.content.size.facet.range.gap=10000"));
assertFalse(url2.contains("&f.content.size.facet.range.include=upper"));
assertFalse(url2.contains("&f.content.size.facet.range.include=outer"));
assertFalse(url2.contains("&f.content.size.facet.range.other=before"));
assertTrue(url2.contains("&f.content.size.facet.range.hardend=true"));
assertTrue(url2.contains("&facet.range={!ex=ex1}content.size"));
}