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;
}
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);
}
}
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;
}
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);
}
}
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;
}
}
Aggregations