use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceManagerIntegrationTest method getMockResource.
private ResourceDataBean getMockResource(String resourceType, String mainGroup, String resDescrToAdd, String categoryCodeToAdd) {
File file = new File("target/test/entando_logo.jpg");
MockResourceDataBean bean = new MockResourceDataBean();
bean.setFile(file);
bean.setDescr(resDescrToAdd);
bean.setMainGroup(mainGroup);
bean.setResourceType(resourceType);
bean.setMimeType("image/jpeg");
List<Category> categories = new ArrayList<Category>();
ICategoryManager catManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
Category cat = catManager.getCategory(categoryCodeToAdd);
categories.add(cat);
bean.setCategories(categories);
return bean;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_5.
public void testSearchContentsId_5() throws Throwable {
try {
Thread thread = this._searchEngineManager.startReloadContentsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this._searchEngineManager;
Category general_cat2 = this._categoryManager.getCategory("general_cat2");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general_cat2);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
assertTrue(contentsId.isEmpty());
allowedGroup.add(Group.ADMINS_GROUP_NAME);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
String[] expected1 = { "ART111", "ART120" };
this.verify(contentsId, expected1);
Category general_cat1 = this._categoryManager.getCategory("general_cat1");
categories.add(general_cat1);
contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART111" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestDataObjectManager method testGetXML.
public void testGetXML() throws Throwable {
DataObject dataObject = this._dataObjectManager.createDataObject("ART");
dataObject.setId("ART1");
dataObject.setTypeCode("Articolo");
dataObject.setTypeDescription("Articolo");
dataObject.setDescription("descrizione");
dataObject.setStatus(DataObject.STATUS_DRAFT);
dataObject.setMainGroup("free");
Category cat13 = new Category();
cat13.setCode("13");
dataObject.addCategory(cat13);
Category cat19 = new Category();
cat19.setCode("19");
dataObject.addCategory(cat19);
String xml = dataObject.getXML();
assertNotNull(xml);
assertTrue(xml.indexOf("<dataObject id=\"ART1\" typecode=\"Articolo\" typedescr=\"Articolo\">") != -1);
assertTrue(xml.indexOf("<descr>descrizione</descr>") != -1);
assertTrue(xml.indexOf("<status>" + DataObject.STATUS_DRAFT + "</status>") != -1);
assertTrue(xml.indexOf("<category id=\"13\" />") != -1);
assertTrue(xml.indexOf("<category id=\"19\" />") != -1);
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceAction method joinRemoveCategory.
/**
* This method perfoms either the linking of a resource to a category or the
* removal of such association. NOTE: in the current implementation
* operations carried on invalid or unknown categories do not return error
* code on purpose, since the join or unlink process does not take place.
*
* @param isJoin
* if 'true' associates a resource to a category, otherwise remove it
* @param categoryCode
* the string code of the category to work with.
* @return FAILURE if error detected, SUCCESS otherwise.
*/
private String joinRemoveCategory(boolean isJoin, String categoryCode) {
try {
Category category = this.getCategory(categoryCode);
if (category == null)
return SUCCESS;
List<String> categories = this.getCategoryCodes();
if (isJoin) {
if (!categories.contains(categoryCode)) {
categories.add(categoryCode);
}
} else {
categories.remove(categoryCode);
}
} catch (Throwable t) {
_logger.error("error in joinRemoveCategory", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceAction method getCategories.
@Override
public List<Category> getCategories() {
List<Category> categories = new ArrayList<Category>(this.getCategoryCodes().size());
Iterator<String> iter = this.getCategoryCodes().iterator();
while (iter.hasNext()) {
String categoryCode = iter.next();
Category category = this.getCategoryManager().getCategory(categoryCode);
if (null != category)
categories.add(category);
}
return categories;
}
Aggregations