use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class JAXBResource method createBataBean.
public BaseResourceDataBean createBataBean(ICategoryManager categoryManager) throws Throwable {
BaseResourceDataBean bean = new BaseResourceDataBean();
if (null != this.getCategories()) {
List<Category> categories = new ArrayList<>();
for (int i = 0; i < this.getCategories().size(); i++) {
String categoryCode = this.getCategories().get(i);
Category category = categoryManager.getCategory(categoryCode);
if (null != category) {
categories.add(category);
}
}
bean.setCategories(categories);
}
bean.setDescr(this.getDescription());
bean.setFileName(this.getFileName());
bean.setMainGroup(this.getMainGroup());
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String mimeType = fileNameMap.getContentTypeFor(this.getFileName());
bean.setMimeType(mimeType);
bean.setResourceType(this.getTypeCode());
bean.setResourceId(this.getId());
if (null != this.getBase64()) {
File file = this.byteArrayToFile();
bean.setFile(file);
}
return bean;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class JoinCategoryBulkCommand method apply.
@Override
protected boolean apply(Content content) throws ApsSystemException {
Collection<Category> categories = this.getItemProperties();
if (null == categories || categories.isEmpty()) {
this.getTracer().traceError(content.getId(), ApsCommandErrorCode.PARAMS_NOT_VALID);
return false;
} else {
for (Category category : categories) {
if (null != category && !category.getCode().equals(category.getParentCode())) {
content.addCategory(category);
}
}
this.getApplier().saveContent(content);
this.getTracer().traceSuccess(content.getId());
}
return true;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class RemoveCategoryBulkCommand method apply.
@Override
protected boolean apply(Content content) throws ApsSystemException {
Collection<Category> categories = this.getItemProperties();
if (null == categories || categories.isEmpty()) {
this.getTracer().traceError(content.getId(), ApsCommandErrorCode.PARAMS_NOT_VALID);
return false;
} else {
for (Category category : categories) {
if (null != category && !category.getCode().equals(category.getParentCode())) {
content.removeCategory(category);
}
}
this.getApplier().saveContent(content);
this.getTracer().traceSuccess(content.getId());
}
return true;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ResourceHandler method startCategory.
private void startCategory(Attributes attributes, String tagName) throws SAXException {
String categoryCode = extractXmlAttribute(attributes, "id", tagName, true);
Category category = this._categoryManager.getCategory(categoryCode);
if (null != category) {
this.getCurrentResource().addCategory(category);
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_4.
public void testSearchContentsId_4() throws Throwable {
try {
Thread thread = this._searchEngineManager.startReloadContentsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this._searchEngineManager;
SearchEngineFilter filterByType = new SearchEngineFilter(IIndexerDAO.CONTENT_TYPE_FIELD_NAME, "ART");
SearchEngineFilter[] filters = { filterByType };
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(filters, null, allowedGroup);
assertNotNull(contentsId);
String[] expected1 = { "ART180", "ART1", "ART187", "ART121" };
this.verify(contentsId, expected1);
Category cat1 = this._categoryManager.getCategory("cat1");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(cat1);
contentsId = sem.searchEntityId(filters, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART180" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
Aggregations