use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method moveTree.
public String moveTree() {
String selectedNode = this.getSelectedNode();
String parentCategoryCode = this.getRequest().getParameter("parentCategoryCode");
try {
String check = this.checkMoveCategory(selectedNode, parentCategoryCode);
if (null != check) {
return check;
}
this.extractReferencingObjectsForMove(this.getSelectedNode());
if (null != this.getReferences() && this.getReferences().size() > 0) {
return "moveReferences";
}
Category currentCategory = this.getCategory(this.getSelectedNode());
Category parent = this.getCategory(parentCategoryCode);
this.getCategoryManager().moveCategory(currentCategory, parent);
} catch (Throwable t) {
_logger.error("error in move category", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryActionHelper method buildNewCategory.
@Override
public Category buildNewCategory(String code, String parentCode, ApsProperties titles) throws ApsSystemException {
Category category = new Category();
try {
category.setParentCode(parentCode);
category.setTitles(titles);
String newCategoryCode = code;
if (null != newCategoryCode && newCategoryCode.trim().length() > 0) {
category.setCode(newCategoryCode);
} else {
String defaultLangCode = this.getLangManager().getDefaultLang().getCode();
String defaultTitle = category.getTitles().getProperty(defaultLangCode);
String categoryCode = this.buildCode(defaultTitle, "category", 25);
category.setCode(categoryCode);
}
} catch (Throwable t) {
_logger.error("Error creating new category", t);
throw new ApsSystemException("Error creating new category", t);
}
return category;
}
use of com.agiletec.aps.system.services.category.Category 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;
}
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(), this.getCategoryManager()) && !candidate.getCode().equals(nodeToMove.getParentCode())) {
ITreeNode parent = this.getCategoryManager().getNode(candidate.getParentCode());
result.add(new TreeNodeWrapper(candidate, parent, this.getCurrentLang().getCode(), this.getCategoryManager()));
}
}
} 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.services.category.Category in project entando-core by entando.
the class CategoryAction method getBreadCrumbsTargets.
public List<Category> getBreadCrumbsTargets(String categoryCode) {
Category category = this.getCategoryManager().getCategory(categoryCode);
if (null == category) {
return null;
}
List<Category> categories = new ArrayList<>();
this.getSubBreadCrumbsTargets(categories, category);
return categories;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryManagerCacheWrapper method createRoot.
protected Category createRoot(ILangManager langManager) {
Category root = new Category();
root.setCode("home");
root.setParentCode("home");
List<Lang> langs = langManager.getLangs();
ApsProperties titles = new ApsProperties();
for (Lang lang : langs) {
titles.setProperty(lang.getCode(), "Home");
}
root.setTitles(titles);
return root;
}
Aggregations