Search in sources :

Example 16 with AttributeInterface

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

the class UserFilterOptionBean method extractFormParameters.

protected void extractFormParameters(HttpServletRequest request) throws Throwable {
    String[] formFieldNames = null;
    try {
        String frameIdSuffix = (null != this.getCurrentFrame()) ? "_frame" + this.getCurrentFrame().toString() : "";
        if (!this.isAttributeFilter()) {
            if (this.getKey().equals(KEY_FULLTEXT)) {
                String fieldName = TYPE_METADATA + "_fulltext" + frameIdSuffix;
                String[] fieldsSuffix = { "", "_option", "_attachSearch" };
                formFieldNames = this.extractParams(fieldName, fieldsSuffix, frameIdSuffix, request);
            } else if (this.getKey().equals(KEY_CATEGORY)) {
                formFieldNames = new String[1];
                formFieldNames[0] = TYPE_METADATA + "_category" + frameIdSuffix;
                String value = request.getParameter(formFieldNames[0]);
                this.addFormValue(formFieldNames[0], value, formFieldNames.length);
            }
        } else {
            AttributeInterface attribute = this.getAttribute();
            if (attribute instanceof ITextAttribute) {
                String[] fieldsSuffix = { "_textFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
            } else if (attribute instanceof DateAttribute) {
                String[] fieldsSuffix = { "_dateStartFieldName", "_dateEndFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
                this.checkRange(formFieldNames);
            } else if (attribute instanceof BooleanAttribute) {
                String[] fieldsSuffix = { "_booleanFieldName", "_booleanFieldName_ignore", "_booleanFieldName_control" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
            } else if (attribute instanceof NumberAttribute) {
                String[] fieldsSuffix = { "_numberStartFieldName", "_numberEndFieldName" };
                formFieldNames = this.extractAttributeParams(fieldsSuffix, frameIdSuffix, request);
                this.checkRange(formFieldNames);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting form parameters", t);
        throw new ApsSystemException("Error extracting form parameters", t);
    }
    this.setFormFieldNames(formFieldNames);
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 17 with AttributeInterface

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

the class EntityTypeDOM method fillEntityType.

/**
 * Map the structure of an Entity Type with the attributes defined in its
 * XML configuration item. This method must be extended to implement
 * particular operations that apply to the specific structure of (an
 * eventually customized) entity class that must be handled by the native
 * Entity manager. That class must implement the IApsEntity interface.
 *
 * @param entityType The entity type to map.
 * @param currentContentElem The XML that configures the Entity Type.
 * @throws ApsSystemException If errors are detected during the parsing
 * process.
 */
protected void fillEntityType(IApsEntity entityType, Element currentContentElem) throws ApsSystemException {
    try {
        if (null == currentContentElem.getChild("attributes")) {
            return;
        }
        List<Element> attributeElements = currentContentElem.getChild("attributes").getChildren();
        for (Element currentAttrElem : attributeElements) {
            AttributeInterface attribute = this.createAttribute(currentAttrElem);
            attribute.setParentEntity(entityType);
            entityType.addAttribute(attribute);
            _logger.debug("The Attribute {} of type {} was successfully inserted in the Entity Type {}", attribute.getName(), attribute.getType(), entityType.getTypeCode());
        }
    } catch (Throwable t) {
        throw new ApsSystemException("Configuration error of the Entity Type " + entityType.getTypeCode() + " detected", t);
    }
}
Also used : Element(org.jdom.Element) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 18 with AttributeInterface

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

the class EntityTypeDOM method initDom.

protected Document initDom(String xml, String entityManagerName) throws ApsSystemException {
    if (null != entityManagerName) {
        ExtraAttributeLoader loader = new ExtraAttributeLoader();
        Map<String, AttributeInterface> extraAttributes = loader.extractAttributes(this.getBeanFactory(), entityManagerName);
        if (null != extraAttributes) {
            this.getAttributeTypes().putAll(extraAttributes);
        }
    }
    this.setEntityManagerName(entityManagerName);
    return this.decodeDOM(xml);
}
Also used : ExtraAttributeLoader(com.agiletec.aps.system.common.entity.loader.ExtraAttributeLoader) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 19 with AttributeInterface

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

the class TestJacmsEntityTypeConfigAction method testMoveAttribute.

public void testMoveAttribute() throws Throwable {
    String result = this.executeEditEntityPrototype("ART", JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IApsEntity contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    List<AttributeInterface> attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(2).getName());
    assertEquals("CorpoTesto", attributes.get(3).getName());
    this.initAction("/do/jacms/Entity", "moveAttribute");
    this.addParameter("attributeIndex", "2");
    this.addParameter("movement", ApsAdminSystemConstants.MOVEMENT_DOWN_CODE);
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(3).getName());
    assertEquals("CorpoTesto", attributes.get(2).getName());
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 20 with AttributeInterface

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

the class TestJacmsEntityTypeConfigAction method testRemoveAttribute.

public void testRemoveAttribute() throws Throwable {
    String result = this.executeEditEntityPrototype("ART", JacmsSystemConstants.CONTENT_MANAGER);
    assertEquals(Action.SUCCESS, result);
    IApsEntity contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    List<AttributeInterface> attributes = contentType.getAttributeList();
    assertEquals(7, attributes.size());
    assertEquals("VediAnche", attributes.get(2).getName());
    assertEquals("CorpoTesto", attributes.get(3).getName());
    this.initAction("/do/jacms/Entity", "removeAttribute");
    this.addParameter("attributeIndex", "2");
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    contentType = (IApsEntity) this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM);
    assertNotNull(contentType);
    attributes = contentType.getAttributeList();
    assertEquals(6, attributes.size());
    assertEquals("CorpoTesto", attributes.get(2).getName());
}
Also used : IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Aggregations

AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)147 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)55 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)38 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)37 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)22 ArrayList (java.util.ArrayList)18 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)17 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)16 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)14 NumberAttribute (com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute)12 ListAttribute (com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)11 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)10 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)10 HttpSession (javax.servlet.http.HttpSession)10 EntityAttributeIterator (com.agiletec.aps.system.common.util.EntityAttributeIterator)9 IEntityManager (com.agiletec.aps.system.common.entity.IEntityManager)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)7 Lang (com.agiletec.aps.system.services.lang.Lang)7 Date (java.util.Date)7