use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceAction method detail.
public String detail() {
try {
ResourceInterface resource = this.loadResource(this.getResourceId());
if (null == resource) {
return INPUT;
}
this.setResourceTypeCode(resource.getType());
this.setDescr(resource.getDescription());
List<Category> resCategories = resource.getCategories();
for (int i = 0; i < resCategories.size(); i++) {
Category resCat = resCategories.get(i);
this.getCategoryCodes().add(resCat.getCode());
}
this.setMainGroup(resource.getMainGroup());
} catch (Throwable t) {
_logger.error("error in detail", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentCategoryBulkAction method join.
public String join() {
try {
String categoryCode = this.getCategoryCode();
Category category = this.getCategoryManager().getCategory(categoryCode);
if (null != category && !category.isRoot()) {
this.getCategoryCodes().add(categoryCode);
}
} catch (Throwable t) {
_logger.error("Error joining category for bulk action", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentBulkActionHelper method getCategoriesToManage.
@Override
public List<Category> getCategoriesToManage(Collection<String> categoryCodes, ValidationAware validation, TextProvider textProvider) {
boolean allowed = true;
List<Category> categories = new ArrayList<Category>();
if (categoryCodes == null || categoryCodes.isEmpty()) {
validation.addActionError(textProvider.getText("error.bulk.categories.empty"));
allowed = false;
} else {
ICategoryManager categoryManager = this.getCategoryManager();
for (String categoryCode : categoryCodes) {
Category category = categoryManager.getCategory(categoryCode);
if (category == null || category.isRoot()) {
validation.addActionError(textProvider.getText("error.bulk.categories.notAllowed", new String[] { categoryCode }));
allowed = false;
} else {
categories.add(category);
}
}
}
return allowed ? categories : null;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestCategoryAction method testAddCategory_2.
public void testAddCategory_2() throws Throwable {
String expectedCategoryCode = "titolo_italiano";
assertNull(this._categoryManager.getCategory(expectedCategoryCode));
try {
Map<String, String> params = new HashMap<String, String>();
params.put("parentCategoryCode", this._categoryManager.getRoot().getCode());
params.put("strutsAction", "1");
params.put("langit", "Titolo Italiano");
params.put("langen", "English Title");
String result = this.executeSaveCategory("admin", params);
assertEquals(Action.SUCCESS, result);
Category category = this._categoryManager.getCategory(expectedCategoryCode);
assertNotNull(category);
assertEquals("Titolo Italiano", category.getTitles().getProperty("it"));
assertEquals(this._categoryManager.getRoot().getCode(), category.getParent().getCode());
} catch (Throwable t) {
throw t;
} finally {
this._categoryManager.deleteCategory(expectedCategoryCode);
assertNull(this._categoryManager.getCategory(expectedCategoryCode));
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestCategoryAction method testCategoryDetails_2.
public void testCategoryDetails_2() throws Throwable {
String categoryCode = "general_cat1";
Category category = this._categoryManager.getCategory(categoryCode);
assertNotNull(category);
try {
String result = this.executeCategoryDetail("admin", categoryCode);
assertEquals(Action.SUCCESS, result);
CategoryAction action = (CategoryAction) this.getAction();
assertEquals(category.getCode(), action.getCategoryCode());
assertEquals(category.getTitle("it"), action.getTitles().get("it"));
assertEquals(category.getTitle("en"), action.getTitles().get("en"));
assertNotNull(action.getReferences());
assertEquals(2, action.getReferences().size());
} catch (Throwable t) {
throw t;
}
}
Aggregations