use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class CompositeAttributeConfigAction method saveAttributeElement.
@Override
public String saveAttributeElement() {
try {
CompositeAttribute composite = this.getCompositeAttributeOnEdit();
if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
throw new RuntimeException("The edit operation on this attribute is not supported");
} else {
AttributeInterface attribute = this.getAttributePrototype(this.getAttributeTypeCode());
attribute.setName(this.getAttributeName());
super.fillAttributeFields(attribute);
composite.getAttributes().add(attribute);
composite.getAttributeMap().put(attribute.getName(), attribute);
}
} catch (Throwable t) {
_logger.error("error in saveAttributeElement", t);
// ApsSystemUtils.logThrowable(t, this, "saveAttributeElement");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class CompositeAttributeConfigAction method removeAttributeElement.
@Override
public String removeAttributeElement() {
try {
int elementIndex = this.getAttributeIndex();
CompositeAttribute composite = this.getCompositeAttributeOnEdit();
AttributeInterface attributeToRemove = composite.getAttributes().get(elementIndex);
composite.getAttributes().remove(elementIndex);
composite.getAttributeMap().remove(attributeToRemove.getName());
} catch (Throwable t) {
_logger.error("error in removeAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "removeAttribute");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class CompositeAttributeConfigAction method getAllowedAttributeElementTypes.
public List<AttributeInterface> getAllowedAttributeElementTypes() {
List<AttributeInterface> attributes = new ArrayList<AttributeInterface>();
try {
IEntityManager entityManager = this.getEntityManager();
Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
Iterator<AttributeInterface> attributeIter = attributeTypes.values().iterator();
while (attributeIter.hasNext()) {
AttributeInterface attribute = attributeIter.next();
if (attribute.isSimple()) {
attributes.add(attribute);
}
}
Collections.sort(attributes, new BeanComparator("type"));
} catch (Throwable t) {
_logger.error("Error extracting the allowed types of attribute elements", t);
// ApsSystemUtils.logThrowable(t, this, "getAllowedAttributeElementTypes");
throw new RuntimeException("Error extracting the allowed types of attribute elements", t);
}
return attributes;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class CompositeAttributeConfigAction method saveCompositeAttribute.
@Override
public String saveCompositeAttribute() {
try {
CompositeAttribute composite = this.getCompositeAttributeOnEdit();
IApsEntity entityType = this.getEntityType();
AttributeInterface attribute = (AttributeInterface) entityType.getAttribute(composite.getName());
if (attribute instanceof MonoListAttribute) {
((MonoListAttribute) attribute).setNestedAttributeType(composite);
} else if (!attribute.getName().equals(composite.getName())) {
throw new ApsSystemException("Attribute Name '" + attribute.getName() + "' incompatible with composite Attribute name '" + composite.getName() + "'");
} else if (!attribute.getType().equals(composite.getType())) {
throw new ApsSystemException("Attribute Type '" + attribute.getType() + "' incompatible with composite Attribute type '" + composite.getType() + "'");
}
this.getRequest().getSession().removeAttribute(COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
} catch (Throwable t) {
_logger.error("error in saveAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "saveAttribute");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityAttributeConfigAction method validate.
@Override
public void validate() {
super.validate();
IApsEntity entityType = this.getEntityType();
String attributeName = this.getAttributeName().trim();
if (this.getStrutsAction() == ApsAdminSystemConstants.ADD && null != entityType.getAttribute(attributeName)) {
String[] args = { attributeName };
this.addFieldError("attributeName", this.getText("error.entity.attribute.name.already.exists", args));
}
AttributeInterface attributePrototype = this.getAttributePrototype(this.getAttributeTypeCode());
if (null == attributePrototype) {
String[] args = { this.getAttributeTypeCode() };
this.addFieldError("attributeTypeCode", this.getText("error.entity.attribute.type.invalid", args));
} else {
if ((attributePrototype instanceof EnumeratorAttribute) && (this.getEnumeratorStaticItems() == null || this.getEnumeratorStaticItems().trim().length() == 0) && (null == this.getEnumeratorExtractorBean() || this.getEnumeratorExtractorBean().trim().length() == 0)) {
String[] args = { this.getAttributeTypeCode() };
this.addFieldError("enumeratorStaticItems", this.getText("error.entity.attribute.enumerator.items.missing", args));
}
if ((attributePrototype instanceof AbstractListAttribute) && (StringUtils.isBlank(this.getListNestedType()) || null == this.getAttributePrototype(this.getAttributeTypeCode()))) {
String[] args = { this.getAttributeTypeCode() };
this.addFieldError("listNestedType", this.getText("error.entity.attribute.list.handled.missing", args));
}
}
}
Aggregations