Search in sources :

Example 21 with IApsEntity

use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.

the class ApsEntityManager method reloadEntityReferences.

protected void reloadEntityReferences(String entityId) {
    try {
        IApsEntity entity = this.getEntity(entityId);
        if (entity != null) {
            this.getEntityDao().reloadEntitySearchRecords(entityId, entity);
        }
        logger.info("Entities search references reloaded {}", entityId);
    } catch (Throwable t) {
        logger.error("Error reloading the entities search references: {}", entityId, t);
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 22 with IApsEntity

use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.

the class ApsEntityManager method createEntityFromXml.

/**
 * Create and populate the entity as specified by its type and XML
 * definition.
 *
 * @param entityTypeCode The Entity Type code.
 * @param xml The XML of the associated entity.
 * @return The populated entity.
 * @throws ApsSystemException If errors detected while retrieving the
 * entity.
 */
protected IApsEntity createEntityFromXml(String entityTypeCode, String xml) throws ApsSystemException {
    try {
        IApsEntity entityPrototype = this.getEntityPrototype(entityTypeCode);
        SAXParserFactory parseFactory = SAXParserFactory.newInstance();
        SAXParser parser = parseFactory.newSAXParser();
        InputSource is = new InputSource(new StringReader(xml));
        EntityHandler handler = this.getEntityHandler();
        handler.initHandler(entityPrototype, this.getXmlAttributeRootElementName(), this.getCategoryManager());
        parser.parse(is, handler);
        return entityPrototype;
    } catch (ParserConfigurationException | SAXException | IOException t) {
        logger.error("Error detected while creating the entity. typecode: {} - xml: {}", entityTypeCode, xml, t);
        throw new ApsSystemException("Error detected while creating the entity", t);
    }
}
Also used : InputSource(org.xml.sax.InputSource) StringReader(java.io.StringReader) SAXParser(javax.xml.parsers.SAXParser) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) EntityHandler(com.agiletec.aps.system.common.entity.parse.EntityHandler) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SAXException(org.xml.sax.SAXException)

Example 23 with IApsEntity

use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.

the class ApsEntityManager method getEntityPrototypes.

@Override
public Map<String, IApsEntity> getEntityPrototypes() {
    Map<String, IApsEntity> prototypes = new HashMap<>();
    Map<String, IApsEntity> mainPrototypes = this.getEntityTypes();
    Iterator<String> iter = mainPrototypes.keySet().iterator();
    while (iter.hasNext()) {
        String code = iter.next();
        IApsEntity mainPrototype = mainPrototypes.get(code);
        prototypes.put(code, mainPrototype.getEntityPrototype());
    }
    return prototypes;
}
Also used : HashMap(java.util.HashMap) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity)

Example 24 with IApsEntity

use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.

the class ContentFinderAction method createBaseFilters.

@SuppressWarnings("rawtypes")
protected void createBaseFilters() {
    try {
        int initSize = this.getFilters().length;
        ContentFinderSearchInfo searchInfo = getContentSearchInfo();
        EntitySearchFilter[] roleFilters = this.getEntityActionHelper().getRoleFilters(this);
        this.addFilters(roleFilters);
        IApsEntity prototype = this.getEntityPrototype();
        searchInfo.removeFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY);
        searchInfo.removeFilterByPrefix(ContentFinderSearchInfo.ATTRIBUTE_FILTER);
        if (null != prototype) {
            EntitySearchFilter filterToAdd = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, prototype.getTypeCode(), false);
            this.addFilter(filterToAdd);
            searchInfo.addFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, filterToAdd);
            EntitySearchFilter[] filters = this.getEntityActionHelper().getAttributeFilters(this, prototype);
            this.addFilters(filters);
            searchInfo.addAttributeFilters(filters);
        }
        this.setAddedAttributeFilter(this.getFilters().length > initSize);
    } catch (Throwable t) {
        _logger.error("Error while creating entity filters", t);
        throw new RuntimeException("Error while creating entity filters", t);
    }
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter)

Example 25 with IApsEntity

use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.

the class AbstractApsEntityFinderAction method getEntityPrototypes.

public List<IApsEntity> getEntityPrototypes() {
    List<IApsEntity> entityPrototypes = null;
    try {
        Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
        entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
        BeanComparator comparator = new BeanComparator("typeDescr");
        Collections.sort(entityPrototypes, comparator);
    } catch (Throwable t) {
        _logger.error("Error while extracting entity prototypes", t);
        throw new RuntimeException("Error while extracting entity prototypes", t);
    }
    return entityPrototypes;
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) BeanComparator(org.apache.commons.beanutils.BeanComparator)

Aggregations

IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)70 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)24 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)16 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)12 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)11 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)11 ArrayList (java.util.ArrayList)9 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)6 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)5 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)4 Lang (com.agiletec.aps.system.services.lang.Lang)4 List (java.util.List)4 BeanComparator (org.apache.commons.beanutils.BeanComparator)4 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)3 ListAttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.ListAttributeInterface)3 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)3 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 Widget (com.agiletec.aps.system.services.page.Widget)2 ApsProperties (com.agiletec.aps.util.ApsProperties)2 EntityAttributeConfigAction (com.agiletec.apsadmin.system.entity.type.EntityAttributeConfigAction)2