Search in sources :

Example 76 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class TestContentBulkCommand method initCategoriesCommand.

private BaseContentPropertyBulkCommand<Category> initCategoriesCommand(String commandBeanName, Collection<String> items, Collection<Category> categories, UserDetails currentUser) {
    ApplicationContext applicationContext = this.getApplicationContext();
    BaseContentPropertyBulkCommand<Category> command = (BaseContentPropertyBulkCommand<Category>) applicationContext.getBean(commandBeanName);
    ContentPropertyBulkCommandContext<Category> context = new ContentPropertyBulkCommandContext<Category>(items, categories, currentUser, new DefaultBulkCommandTracer<String>());
    command.init(context);
    return command;
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Category(com.agiletec.aps.system.services.category.Category)

Example 77 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class AbstractResource method getResourceDOM.

/**
 * Restituisce la classe dom (necessaria per la generazione dell'xml della risorsa)
 * preparata con gli attributi base della risorsa.
 * @return La classe dom preparata con gli attributi base della risorsa.
 */
protected ResourceDOM getResourceDOM() {
    ResourceDOM resourceDom = this.getNewResourceDOM();
    resourceDom.setTypeCode(this.getType());
    resourceDom.setId(this.getId());
    resourceDom.setDescription(this.getDescription());
    resourceDom.setMainGroup(this.getMainGroup());
    resourceDom.setMasterFileName(this.getMasterFileName());
    if (null != this.getCategories()) {
        for (int i = 0; i < this.getCategories().size(); i++) {
            Category cat = (Category) this.getCategories().get(i);
            resourceDom.addCategory(cat.getCode());
        }
    }
    return resourceDom;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ResourceDOM(com.agiletec.plugins.jacms.aps.system.services.resource.parse.ResourceDOM)

Example 78 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class IndexerDAO method createDocument.

/**
 * Crea un oggetto Document pronto per l'indicizzazione da un oggetto Content.
 * @param entity Il contenuto dal quale ricavare il Document.
 * @return L'oggetto Document ricavato dal contenuto.
 * @throws ApsSystemException In caso di errore
 */
protected Document createDocument(IApsEntity entity) throws ApsSystemException {
    Document document = new Document();
    document.add(new StringField(CONTENT_ID_FIELD_NAME, entity.getId(), Field.Store.YES));
    document.add(new TextField(CONTENT_TYPE_FIELD_NAME, entity.getTypeCode(), Field.Store.YES));
    document.add(new StringField(CONTENT_GROUP_FIELD_NAME, entity.getMainGroup(), Field.Store.YES));
    Iterator<String> iterGroups = entity.getGroups().iterator();
    while (iterGroups.hasNext()) {
        String groupName = (String) iterGroups.next();
        document.add(new StringField(CONTENT_GROUP_FIELD_NAME, groupName, Field.Store.YES));
    }
    try {
        EntityAttributeIterator attributesIter = new EntityAttributeIterator(entity);
        while (attributesIter.hasNext()) {
            AttributeInterface currentAttribute = (AttributeInterface) attributesIter.next();
            List<Lang> langs = this.getLangManager().getLangs();
            for (int i = 0; i < langs.size(); i++) {
                Lang currentLang = (Lang) langs.get(i);
                this.indexAttribute(document, currentAttribute, currentLang);
            }
        }
        List<Category> categories = entity.getCategories();
        if (null != categories && !categories.isEmpty()) {
            for (int i = 0; i < categories.size(); i++) {
                Category category = categories.get(i);
                this.indexCategory(document, category);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error creating document", t);
        throw new ApsSystemException("Error creating document", t);
    }
    return document;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Document(org.apache.lucene.document.Document) StringField(org.apache.lucene.document.StringField) TextField(org.apache.lucene.document.TextField) IndexableAttributeInterface(com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface) ResourceAttributeInterface(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.ResourceAttributeInterface) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) EntityAttributeIterator(com.agiletec.aps.system.common.util.EntityAttributeIterator)

Example 79 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class ResourceDAO method addCategoryCode.

private void addCategoryCode(ResourceInterface resource, Category category, Set<String> codes) {
    if (category.getCode().equals(category.getParent().getCode())) {
        return;
    }
    codes.add(category.getCode());
    Category parentCategory = (Category) category.getParent();
    if (null != parentCategory) {
        this.addCategoryCode(resource, parentCategory, codes);
    }
}
Also used : Category(com.agiletec.aps.system.services.category.Category)

Example 80 with Category

use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.

the class EntityWrapper method getCategories.

/**
 * Return the categories list of the entity.
 * @return The list of categories.
 */
public List<Category> getCategories() {
    List<Category> categories = new ArrayList<Category>();
    List<Category> contentCategories = this._entity.getCategories();
    for (int i = 0; i < contentCategories.size(); i++) {
        Category cat = contentCategories.get(i);
        Category clone = cat.getCloneForWrapper();
        clone.setRenderingLang(this._renderingLang);
        categories.add(clone);
    }
    return categories;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList)

Aggregations

Category (com.agiletec.aps.system.services.category.Category)85 ArrayList (java.util.ArrayList)21 ITreeNode (com.agiletec.aps.system.common.tree.ITreeNode)9 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)7 TextAttribute (com.agiletec.aps.system.common.entity.model.attribute.TextAttribute)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 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)4 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 List (java.util.List)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 CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)3 HashSet (java.util.HashSet)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3