Search in sources :

Example 1 with Template

use of org.alfresco.rest.api.search.model.Template in project alfresco-remote-api by Alfresco.

the class SearchMapper method fromTemplate.

/**
 * SearchParameters from List<Template>
 * @param sp SearchParameters
 * @param templates List<Template>
 */
public void fromTemplate(SearchParameters sp, List<Template> templates) {
    if (templates != null && !templates.isEmpty()) {
        for (Template aTemplate : templates) {
            ParameterCheck.mandatoryString("template name", aTemplate.getName());
            ParameterCheck.mandatoryString("template template", aTemplate.getTemplate());
            sp.addQueryTemplate(aTemplate.getName(), aTemplate.getTemplate());
        }
    }
}
Also used : Template(org.alfresco.rest.api.search.model.Template)

Example 2 with Template

use of org.alfresco.rest.api.search.model.Template in project alfresco-remote-api by Alfresco.

the class SearchMapperTests method fromTemplate.

@Test
public void fromTemplate() throws Exception {
    SearchParameters searchParameters = new SearchParameters();
    // Doesn't error
    searchMapper.fromTemplate(searchParameters, null);
    searchMapper.fromTemplate(searchParameters, Arrays.asList(new Template("hedge", "hog"), new Template("king", "kong"), new Template("bish", "bash")));
    assertEquals(3, searchParameters.getQueryTemplates().size());
    assertEquals("hog", searchParameters.getQueryTemplates().get("hedge"));
    assertEquals("kong", searchParameters.getQueryTemplates().get("king"));
    assertEquals("bash", searchParameters.getQueryTemplates().get("bish"));
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) Template(org.alfresco.rest.api.search.model.Template) Test(org.junit.Test)

Aggregations

Template (org.alfresco.rest.api.search.model.Template)2 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)1 Test (org.junit.Test)1