use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_6.
public void testSearchContentsId_6() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.ADMINS_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(contentsId, expected1);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchFacetedContents_1.
public void testSearchFacetedContents_1() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
allowedGroup.add(Group.ADMINS_GROUP_NAME);
FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
assertNotNull(result);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(result.getContentsId(), expected1);
assertEquals(4, result.getOccurrences().size());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryService method updateCategory.
@Override
public CategoryDto updateCategory(CategoryDto categoryDto) {
Category parentCategory = this.getCategoryManager().getCategory(categoryDto.getParentCode());
if (null == parentCategory) {
throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_PARENT_CATEGORY_NOT_FOUND, "parent category", categoryDto.getParentCode());
}
Category category = this.getCategoryManager().getCategory(categoryDto.getCode());
if (null == category) {
throw new RestRourceNotFoundException(CategoryValidator.ERRCODE_CATEGORY_NOT_FOUND, "category", categoryDto.getCode());
}
CategoryDto dto = null;
try {
category.setParentCode(categoryDto.getParentCode());
category.getTitles().clear();
category.getTitles().putAll(categoryDto.getTitles());
this.getCategoryManager().updateCategory(category);
dto = this.getDtoBuilder().convert(this.getCategoryManager().getCategory(categoryDto.getCode()));
} catch (Exception e) {
logger.error("error updating category " + categoryDto.getCode(), e);
throw new RestServerError("error updating category " + categoryDto.getCode(), e);
}
return dto;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class DataObjectDAO method addCategoryCode.
private void addCategoryCode(Category category, Set<String> codes) {
codes.add(category.getCode());
Category parentCategory = (Category) category.getParent();
if (null != parentCategory && !parentCategory.getCode().equals(parentCategory.getParentCode())) {
this.addCategoryCode(parentCategory, codes);
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryValidator method validatePutReferences.
public void validatePutReferences(String categoryCode, CategoryDto request, BindingResult bindingResult) {
if (!StringUtils.equals(categoryCode, request.getCode())) {
bindingResult.rejectValue("code", ERRCODE_URINAME_MISMATCH, new String[] { categoryCode, request.getCode() }, "category.code.mismatch");
throw new ValidationGenericException(bindingResult);
}
Category category = this.getCategoryManager().getCategory(request.getCode());
if (null == category) {
bindingResult.reject(ERRCODE_CATEGORY_NOT_FOUND, new String[] { request.getCode() }, "category.notexists");
throw new RestRourceNotFoundException(bindingResult);
}
Category parent = this.getCategoryManager().getCategory(request.getParentCode());
if (null == parent) {
bindingResult.reject(ERRCODE_PARENT_CATEGORY_NOT_FOUND, new String[] { request.getCode() }, "category.parent.notexists");
throw new RestRourceNotFoundException(bindingResult);
} else if (!parent.getCode().equals(category.getParentCode())) {
bindingResult.reject(ERRCODE_PARENT_CATEGORY_CANNOT_BE_CHANGED, new String[] {}, "category.parent.cannotBeChanged");
}
}
Aggregations