Search in sources :

Example 1 with EmptyResultSet

use of org.alfresco.repo.search.EmptyResultSet in project alfresco-repository by Alfresco.

the class VirtualQueryImplTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    query = new VirtualQueryImpl(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString(), SearchService.LANGUAGE_FTS_ALFRESCO, QUERY_TEST_STRING_QUERY);
    mockitoActualEnvironment = Mockito.mock(ActualEnvironment.class);
    Mockito.when(mockitoActualEnvironment.query(Mockito.any(SearchParameters.class))).thenReturn(new EmptyResultSet());
    mockitoPrefixResolver = Mockito.mock(NamespacePrefixResolver.class);
    Mockito.when(mockitoPrefixResolver.getNamespaceURI(TST_PREFIX)).thenReturn(TEST_URI);
    Mockito.when(mockitoPrefixResolver.getPrefixes(TEST_URI)).thenReturn(Arrays.asList(TST_PREFIX));
    Mockito.when(mockitoActualEnvironment.getNamespacePrefixResolver()).thenReturn(mockitoPrefixResolver);
    testQName1 = QName.createQName(TST_PREFIX, TEST_LOCAL_NAME_1, mockitoPrefixResolver);
    testQName2 = QName.createQName(TST_PREFIX, TEST_LOCAL_NAME_2, mockitoPrefixResolver);
    NodeRef n1 = new NodeRef("workspace://SpacesStore/17c8f11d-0936-4295-88a0-12b85764c76f");
    NodeRef n2 = new NodeRef("workspace://SpacesStore/27c8f11d-0936-4295-88a0-12b85764c76f");
    nodeOneReference = ((VirtualProtocol) Protocols.VIRTUAL.protocol).newReference(n1, "/1", n2);
}
Also used : ActualEnvironment(org.alfresco.repo.virtual.ActualEnvironment) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) NodeRef(org.alfresco.service.cmr.repository.NodeRef) EmptyResultSet(org.alfresco.repo.search.EmptyResultSet) NamespacePrefixResolver(org.alfresco.service.namespace.NamespacePrefixResolver)

Example 2 with EmptyResultSet

use of org.alfresco.repo.search.EmptyResultSet in project alfresco-remote-api by Alfresco.

the class ResultMapperTests method testNoResults.

@Test
public void testNoResults() throws Exception {
    SearchRequestContext searchRequest = SearchRequestContext.from(SearchQuery.EMPTY);
    CollectionWithPagingInfo<Node> collection = mapper.toCollectionWithPagingInfo(EMPTY_PARAMS, searchRequest, null, new EmptyResultSet());
    assertNotNull(collection);
    assertFalse(collection.hasMoreItems());
    assertTrue(collection.getTotalItems() < 1);
    assertNull(collection.getContext());
}
Also used : EmptyResultSet(org.alfresco.repo.search.EmptyResultSet) Node(org.alfresco.rest.api.model.Node) SearchRequestContext(org.alfresco.rest.api.search.context.SearchRequestContext) Test(org.junit.Test)

Example 3 with EmptyResultSet

use of org.alfresco.repo.search.EmptyResultSet in project alfresco-repository by Alfresco.

the class VirtualQueryImpl method perform.

/**
 * @deprecated will be replaced by
 *             {@link #perform(ActualEnvironment, VirtualQueryConstraint,Reference)}
 *             once complex constrains are implemented
 */
@Override
public PagingResults<Reference> perform(ActualEnvironment environment, boolean files, boolean folders, String pattern, Set<QName> searchTypeQNames, Set<QName> ignoreTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, PagingRequest pagingRequest, Reference parentReference) throws VirtualizationException {
    if (!files && !folders) {
        if (logger.isDebugEnabled()) {
            logger.debug("Deprecated query  will be skipped due do incompatible types request.");
        }
        return asPagingResults(environment, pagingRequest, new EmptyResultSet(), parentReference);
    } else {
        VirtualQueryConstraint constraint = BasicConstraint.INSTANCE;
        constraint = new FilesFoldersConstraint(constraint, files, folders);
        if (pattern != null) {
            constraint = new NamePatternPropertyValueConstraint(constraint, ContentModel.PROP_NAME, pattern, environment.getNamespacePrefixResolver());
        }
        constraint = new IgnoreConstraint(constraint, ignoreTypeQNames, ignoreAspectQNames);
        constraint = new PagingRequestConstraint(constraint, pagingRequest);
        constraint = new SortConstraint(constraint, sortProps);
        return perform(environment, constraint, null, parentReference);
    }
}
Also used : EmptyResultSet(org.alfresco.repo.search.EmptyResultSet)

Aggregations

EmptyResultSet (org.alfresco.repo.search.EmptyResultSet)3 ActualEnvironment (org.alfresco.repo.virtual.ActualEnvironment)1 Node (org.alfresco.rest.api.model.Node)1 SearchRequestContext (org.alfresco.rest.api.search.context.SearchRequestContext)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)1 NamespacePrefixResolver (org.alfresco.service.namespace.NamespacePrefixResolver)1 Test (org.junit.Test)1