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);
}
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);
}
}
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);
}
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());
}
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());
}
Aggregations