Search in sources :

Example 16 with ITreeNode

use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_6.

public void testSearchContentsId_6() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(contentsId, expected1);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 17 with ITreeNode

use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.

the class TestSearchEngineManager method testSearchFacetedContents_1.

public void testSearchFacetedContents_1() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general = this._categoryManager.getCategory("general");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
        assertNotNull(result);
        String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
        this.verify(result.getContentsId(), expected1);
        assertEquals(4, result.getOccurrences().size());
    } catch (Throwable t) {
        throw t;
    }
}
Also used : FacetedContentsResult(org.entando.entando.aps.system.services.searchengine.FacetedContentsResult) Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 18 with ITreeNode

use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.

the class SearcherDAO method createQuery.

protected Query createQuery(SearchEngineFilter[] filters, Collection<ITreeNode> categories, Collection<String> allowedGroups) {
    BooleanQuery mainQuery = new BooleanQuery();
    if (filters != null && filters.length > 0) {
        for (int i = 0; i < filters.length; i++) {
            SearchEngineFilter filter = filters[i];
            Query fieldQuery = this.createQuery(filter);
            mainQuery.add(fieldQuery, BooleanClause.Occur.MUST);
        }
    }
    if (allowedGroups == null) {
        allowedGroups = new HashSet<String>();
    }
    if (!allowedGroups.contains(Group.ADMINS_GROUP_NAME)) {
        if (!allowedGroups.contains(Group.FREE_GROUP_NAME)) {
            allowedGroups.add(Group.FREE_GROUP_NAME);
        }
        BooleanQuery groupsQuery = new BooleanQuery();
        Iterator<String> iterGroups = allowedGroups.iterator();
        while (iterGroups.hasNext()) {
            String group = iterGroups.next();
            TermQuery groupQuery = new TermQuery(new Term(IIndexerDAO.DATAOBJECT_GROUP_FIELD_NAME, group));
            groupsQuery.add(groupQuery, BooleanClause.Occur.SHOULD);
        }
        mainQuery.add(groupsQuery, BooleanClause.Occur.MUST);
    }
    if (null != categories && !categories.isEmpty()) {
        BooleanQuery categoriesQuery = new BooleanQuery();
        Iterator<ITreeNode> cateIter = categories.iterator();
        while (cateIter.hasNext()) {
            ITreeNode category = cateIter.next();
            String path = category.getPath(IIndexerDAO.DATAOBJECT_CATEGORY_SEPARATOR, false);
            TermQuery categoryQuery = new TermQuery(new Term(IIndexerDAO.DATAOBJECT_CATEGORY_FIELD_NAME, path));
            categoriesQuery.add(categoryQuery, BooleanClause.Occur.MUST);
        }
        mainQuery.add(categoriesQuery, BooleanClause.Occur.MUST);
    }
    return mainQuery;
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) TermQuery(org.apache.lucene.search.TermQuery) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) Query(org.apache.lucene.search.Query) PhraseQuery(org.apache.lucene.search.PhraseQuery) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) TermQuery(org.apache.lucene.search.TermQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) TermRangeQuery(org.apache.lucene.search.TermRangeQuery) Term(org.apache.lucene.index.Term)

Example 19 with ITreeNode

use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_5.

public void testSearchContentsId_5() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        Category general_cat2 = this._categoryManager.getCategory("general_cat2");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general_cat2);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        assertTrue(contentsId.isEmpty());
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        String[] expected1 = { "ART111", "ART120" };
        this.verify(contentsId, expected1);
        Category general_cat1 = this._categoryManager.getCategory("general_cat1");
        categories.add(general_cat1);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART111" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) IDataObjectSearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager) SearchEngineManager(org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager) ArrayList(java.util.ArrayList)

Example 20 with ITreeNode

use of com.agiletec.aps.system.common.tree.ITreeNode in project entando-core by entando.

the class TestSearchEngineManager method testSearchContentsId_5.

public void testSearchContentsId_5() throws Throwable {
    try {
        Thread thread = this._searchEngineManager.startReloadContentsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this._searchEngineManager;
        Category general_cat2 = this._categoryManager.getCategory("general_cat2");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(general_cat2);
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        assertTrue(contentsId.isEmpty());
        allowedGroup.add(Group.ADMINS_GROUP_NAME);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        String[] expected1 = { "ART111", "ART120" };
        this.verify(contentsId, expected1);
        Category general_cat1 = this._categoryManager.getCategory("general_cat1");
        categories.add(general_cat1);
        contentsId = sem.searchEntityId(null, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART111" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) ArrayList(java.util.ArrayList)

Aggregations

ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)36 Category (com.agiletec.aps.system.services.category.Category)9 ArrayList (java.util.ArrayList)9 PageTreeAction (com.agiletec.apsadmin.portal.PageTreeAction)7 IDataObjectSearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager)4 SearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager)4 SearchEngineFilter (org.entando.entando.aps.system.services.searchengine.SearchEngineFilter)4 TreeNodeWrapper (com.agiletec.apsadmin.system.TreeNodeWrapper)2 Term (org.apache.lucene.index.Term)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)2 PhraseQuery (org.apache.lucene.search.PhraseQuery)2 Query (org.apache.lucene.search.Query)2 TermQuery (org.apache.lucene.search.TermQuery)2 TermRangeQuery (org.apache.lucene.search.TermRangeQuery)2 FacetedContentsResult (org.entando.entando.aps.system.services.searchengine.FacetedContentsResult)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 IPage (com.agiletec.aps.system.services.page.IPage)1 IPageActionHelper (com.agiletec.apsadmin.portal.helper.IPageActionHelper)1 ValueStack (com.opensymphony.xwork2.util.ValueStack)1