Search in sources :

Example 6 with CategoryUtilizer

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

the class TestUtilizer method testGetCategoryUtilizers.

public void testGetCategoryUtilizers() throws Throwable {
    String[] names = this.getApplicationContext().getBeanNamesForType(CategoryUtilizer.class);
    assertTrue(names.length >= 2);
    for (int i = 0; i < names.length; i++) {
        CategoryUtilizer service = (CategoryUtilizer) this.getApplicationContext().getBean(names[i]);
        List utilizers = service.getCategoryUtilizers("evento");
        if (names[i].equals("DataTypeManager")) {
            assertTrue(utilizers.size() == 2);
        }
    }
}
Also used : CategoryUtilizer(com.agiletec.aps.system.services.category.CategoryUtilizer) List(java.util.List)

Example 7 with CategoryUtilizer

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

the class CategoryActionHelper method getReferencingObjectsForMove.

@Override
public Map getReferencingObjectsForMove(Category category, HttpServletRequest request) throws ApsSystemException {
    Map<String, List> references = new HashMap<String, List>();
    try {
        String[] defNames = ApsWebApplicationUtils.getWebApplicationContext(request).getBeanNamesForType(CategoryUtilizer.class);
        for (int i = 0; i < defNames.length; i++) {
            Object service = null;
            try {
                service = ApsWebApplicationUtils.getWebApplicationContext(request).getBean(defNames[i]);
            } catch (Throwable t) {
                _logger.error("error checking Referencing Objects", t);
                service = null;
            }
            if (service != null) {
                CategoryUtilizer categoryUtilizer = (CategoryUtilizer) service;
                List utilizers = categoryUtilizer.getCategoryUtilizersForReloadReferences(category.getCode());
                if (utilizers != null && !utilizers.isEmpty()) {
                    references.put(categoryUtilizer.getName() + "Utilizers", utilizers);
                }
            }
        }
    } catch (Throwable t) {
        throw new ApsSystemException("Error in getReferencingObjectsForMove", t);
    }
    return references;
}
Also used : HashMap(java.util.HashMap) CategoryUtilizer(com.agiletec.aps.system.services.category.CategoryUtilizer) List(java.util.List) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 8 with CategoryUtilizer

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

the class CategoryActionHelper method getReferencingObjects.

@Override
public Map getReferencingObjects(Category category, HttpServletRequest request) throws ApsSystemException {
    Map<String, List> references = new HashMap<String, List>();
    try {
        String[] defNames = ApsWebApplicationUtils.getWebApplicationContext(request).getBeanNamesForType(CategoryUtilizer.class);
        for (int i = 0; i < defNames.length; i++) {
            Object service = null;
            try {
                service = ApsWebApplicationUtils.getWebApplicationContext(request).getBean(defNames[i]);
            } catch (Throwable t) {
                _logger.error("error checking Referencing Objects", t);
                service = null;
            }
            if (service != null) {
                CategoryUtilizer categoryUtilizer = (CategoryUtilizer) service;
                List utilizers = categoryUtilizer.getCategoryUtilizers(category.getCode());
                if (utilizers != null && !utilizers.isEmpty()) {
                    references.put(categoryUtilizer.getName() + "Utilizers", utilizers);
                }
            }
        }
    } catch (Throwable t) {
        throw new ApsSystemException("Errore in hasReferencingObjects", t);
    }
    return references;
}
Also used : HashMap(java.util.HashMap) CategoryUtilizer(com.agiletec.aps.system.services.category.CategoryUtilizer) List(java.util.List) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

CategoryUtilizer (com.agiletec.aps.system.services.category.CategoryUtilizer)8 List (java.util.List)7 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 RestServerError (org.entando.entando.aps.system.exception.RestServerError)3 Category (com.agiletec.aps.system.services.category.Category)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)2 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)1 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)1