Search in sources :

Example 11 with ITreeNode

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

the class TreeNodeBaseActionHelper method getAllowedTreeRoot.

/**
 * Default implementation of the method. Build a root node cloning the
 * returned tree from the helper.
 *
 * @param groupCodes the groups codes
 * @return the root node
 * @throws ApsSystemException in caso of error
 */
@Override
public ITreeNode getAllowedTreeRoot(Collection<String> groupCodes) throws ApsSystemException {
    ITreeNode currentRoot = this.getRoot();
    TreeNodeWrapper root = this.buildWrapper(currentRoot);
    this.addTreeWrapper(root, currentRoot);
    return root;
}
Also used : ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode)

Example 12 with ITreeNode

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

the class TreeNodeBaseActionHelper method buildCheckNodes.

protected void buildCheckNodes(ITreeNode treeNode, Set<String> nodesToShow, Collection<String> groupCodes) {
    nodesToShow.add(treeNode.getCode());
    ITreeNode parent = treeNode.getParent();
    if (parent != null && parent.getParent() != null && !parent.getCode().equals(treeNode.getCode())) {
        this.buildCheckNodes(parent, nodesToShow, groupCodes);
    }
}
Also used : ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode)

Example 13 with ITreeNode

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

the class CategoryAction method getAvailableNodesForMoveTreeAjax.

public List<TreeNodeWrapper> getAvailableNodesForMoveTreeAjax() {
    List<TreeNodeWrapper> result = new ArrayList<TreeNodeWrapper>();
    try {
        String startCategoryCode = this.getSelectedNode();
        if (StringUtils.isBlank(startCategoryCode)) {
            _logger.warn("required parameter 'selectedNode' missing");
            return result;
        }
        Category nodeToMove = this.getCategory(startCategoryCode);
        if (null == nodeToMove) {
            _logger.warn("category {} is null", startCategoryCode);
            return result;
        }
        // XXX FIX JS
        this.setCategoryCodeToken(super.getParameter("categoryCodeToken"));
        List<Category> searchResult = this.getCategoryManager().searchCategories(this.getCategoryCodeToken());
        if (null == searchResult || searchResult.isEmpty()) {
            return result;
        }
        BeanComparator comparator = new BeanComparator("code");
        Collections.sort(result, comparator);
        int maxIndex = 30;
        String maxParam = super.getParameter("max");
        if (StringUtils.isNotBlank(maxParam) && StringUtils.isNumeric(maxParam)) {
            maxIndex = new Integer(maxParam).intValue();
        }
        Iterator<Category> it = searchResult.iterator();
        while (result.size() < maxIndex && it.hasNext()) {
            ITreeNode candidate = it.next();
            if (!candidate.isChildOf(nodeToMove.getCode()) && !candidate.getCode().equals(nodeToMove.getParentCode())) {
                result.add(new TreeNodeWrapper(candidate, this.getCurrentLang().getCode()));
            }
        }
    } catch (Throwable t) {
        _logger.error("Error on searching categories ajax", t);
        throw new RuntimeException("Error on searching categories ajax", t);
    }
    return result;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) TreeNodeWrapper(com.agiletec.apsadmin.system.TreeNodeWrapper) ArrayList(java.util.ArrayList) BeanComparator(org.apache.commons.beanutils.BeanComparator) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode)

Example 14 with ITreeNode

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

the class AbstractPageActionHelper method buildCheckNodes.

@Override
protected void buildCheckNodes(ITreeNode treeNode, Set<String> nodesToShow, Collection<String> groupCodes) {
    nodesToShow.add(treeNode.getCode());
    ITreeNode parent = treeNode.getParent();
    if (parent == null) {
        return;
    }
    IPage page = this.getPage(parent.getCode());
    if (!this.isPageAllowed(page, groupCodes, false)) {
        nodesToShow.add(AbstractPortalAction.VIRTUAL_ROOT_CODE);
        return;
    }
    if (parent.getParent() != null && !parent.getCode().equals(treeNode.getCode())) {
        this.buildCheckNodes(parent, nodesToShow, groupCodes);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode)

Example 15 with ITreeNode

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

the class TestSearchEngineManager method testSearchContentsId_4.

public void testSearchContentsId_4() throws Throwable {
    try {
        Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
        thread.join();
        SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
        SearchEngineFilter filterByType = new SearchEngineFilter(IIndexerDAO.DATAOBJECT_TYPE_FIELD_NAME, "ART");
        SearchEngineFilter[] filters = { filterByType };
        List<String> allowedGroup = new ArrayList<String>();
        allowedGroup.add(Group.FREE_GROUP_NAME);
        List<String> contentsId = sem.searchEntityId(filters, null, allowedGroup);
        assertNotNull(contentsId);
        String[] expected1 = { "ART180", "ART1", "ART187", "ART121" };
        this.verify(contentsId, expected1);
        Category cat1 = this._categoryManager.getCategory("cat1");
        List<ITreeNode> categories = new ArrayList<ITreeNode>();
        categories.add(cat1);
        contentsId = sem.searchEntityId(filters, categories, allowedGroup);
        assertNotNull(contentsId);
        String[] expected2 = { "ART180" };
        this.verify(contentsId, expected2);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) 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)

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