Search in sources :

Example 1 with Category

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;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList) FileNameMap(java.net.FileNameMap) BaseResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.model.BaseResourceDataBean) File(java.io.File)

Example 2 with Category

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;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 3 with Category

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;
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 4 with Category

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);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 5 with 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;
    }
}
Also used : SearchEngineFilter(org.entando.entando.aps.system.services.searchengine.SearchEngineFilter) Category(com.agiletec.aps.system.services.category.Category) ITreeNode(com.agiletec.aps.system.common.tree.ITreeNode) ArrayList(java.util.ArrayList)

Aggregations

Category (com.agiletec.aps.system.services.category.Category)91 ArrayList (java.util.ArrayList)23 ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)9 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)6 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)6 List (java.util.List)6 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)5 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)5 RestServerError (org.entando.entando.aps.system.exception.RestServerError)5 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)4 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 IDataObjectSearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.IDataObjectSearchEngineManager)4 SearchEngineManager (org.entando.entando.aps.system.services.dataobjectsearchengine.SearchEngineManager)4 Cache (org.springframework.cache.Cache)4 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 HashSet (java.util.HashSet)3