use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method extractCategoryFormValues.
protected String extractCategoryFormValues() {
String selectedNode = this.getSelectedNode();
try {
Category category = this.getCategory(selectedNode);
if (null == category) {
this.addActionError(this.getText("error.category.selectCategory"));
return "categoryTree";
}
this.setParentCategoryCode(category.getParentCode());
this.setCategoryCode(category.getCode());
this.setTitles(category.getTitles());
} catch (Throwable t) {
_logger.error("error in extractCategoryFormValues", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method delete.
public String delete() {
String selectedNode = this.getSelectedNode();
try {
String check = this.checkDelete();
if (null != check) {
return check;
}
Category currentCategory = this.getCategory(selectedNode);
this.getCategoryManager().deleteCategory(selectedNode);
this.setSelectedNode(currentCategory.getParent().getCode());
} catch (Throwable t) {
_logger.error("error in delete", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method executeMoveTree.
public String executeMoveTree() {
String selectedNode = this.getSelectedNode();
String parentCategoryCode = this.getRequest().getParameter("parentCategoryCode");
try {
String check = this.checkMoveCategory(selectedNode, parentCategoryCode);
if (null != check) {
return check;
}
Category currentCategory = this.getCategory(this.getSelectedNode());
Category parent = this.getCategory(parentCategoryCode);
this.getCategoryManager().moveCategory(currentCategory, parent);
} catch (Throwable t) {
_logger.error("error in move executeMoveTree", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method checkMoveCategory.
protected String checkMoveCategory(String selectedNode, String parentCategoryCode) {
if (this.getCategoryManager().getMoveTreeStatus() != ICategoryManager.STATUS_READY) {
this.addActionError(this.getText("error.category.move.updateReferencesRunning"));
return "categoryTree";
}
Category currentCategory = this.getCategory(this.getSelectedNode());
if (null == currentCategory) {
_logger.info("Required a selected node");
this.addActionError(this.getText("error.category.selectCategory"));
return "categoryTree";
}
if (currentCategory.getCode().equals(this.getCategoryManager().getRoot().getCode())) {
_logger.info("Root category cannot be moved");
this.addActionError(this.getText("error.category.move.rootNotAllowed"));
return "categoryTree";
}
if ("".equals(parentCategoryCode) || null == this.getCategoryManager().getCategory(parentCategoryCode)) {
this.addActionError(this.getText("error.category.move.selectCategoryParent"));
return "categoryTree";
}
Category parent = this.getCategory(parentCategoryCode);
if (null == parent) {
_logger.info("Required a selected node");
this.addActionError(this.getText("error.category.selectCategoryParent"));
return "categoryTree";
}
if (parent.getCode().equals(currentCategory.getParentCode())) {
_logger.debug("trying to move a node under it's own parent..");
return "categoryTree";
}
if (parent.isChildOf(selectedNode)) {
List<String> args = new ArrayList<String>();
args.add(parent.getCode());
args.add(selectedNode);
this.addActionError(this.getText("error.category.move.parentUnderChild.notAllowed"));
return "categoryTree";
}
return null;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method getSubBreadCrumbsTargets.
private void getSubBreadCrumbsTargets(List<Category> categories, Category current) {
categories.add(0, current);
Category parent = current.getParent();
if (parent != null && !parent.getCode().equals(current.getCode())) {
this.getSubBreadCrumbsTargets(categories, parent);
}
}
Aggregations