use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityAttributeConfigAction method getAllowedNestedTypes.
public List<AttributeInterface> getAllowedNestedTypes(AttributeInterface listType) {
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();
boolean simple = attribute.isSimple();
boolean multiLanguage = attribute.isMultilingual();
if ((listType instanceof ListAttribute && simple && !multiLanguage) || (listType instanceof MonoListAttribute && !(attribute instanceof AbstractListAttribute))) {
attributes.add(attribute);
}
}
Collections.sort(attributes, new BeanComparator("type"));
} catch (Throwable t) {
_logger.error("Error while extracting Allowed Nested Types", t);
// ApsSystemUtils.logThrowable(t, this, "getAllowedNestedTypes");
throw new RuntimeException("Error while extracting Allowed Nested Types", t);
}
return attributes;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityAttributeConfigAction method editAttribute.
@Override
public String editAttribute() {
this.setStrutsAction(ApsAdminSystemConstants.EDIT);
this.getRequest().getSession().removeAttribute(ICompositeAttributeConfigAction.COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
this.getRequest().getSession().removeAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM);
this.getRequest().getSession().removeAttribute(IListElementAttributeConfigAction.LIST_ELEMENT_ON_EDIT_SESSION_PARAM);
try {
AttributeInterface attribute = (AttributeInterface) this.getEntityType().getAttribute(this.getAttributeName());
this.valueFormFields(attribute);
if (attribute instanceof AbstractListAttribute) {
AbstractListAttribute listAttribute = (AbstractListAttribute) attribute;
this.setListNestedType(listAttribute.getNestedAttributeTypeCode());
}
} catch (Throwable t) {
_logger.error("error in editAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "editAttribute");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityTypeConfigAction method removeAttribute.
@Override
public String removeAttribute() {
IApsEntity entity = this.updateEntityOnSession();
try {
int elementIndex = this.getAttributeIndex();
List<AttributeInterface> attributes = entity.getAttributeList();
AttributeInterface attributeToRemove = attributes.get(elementIndex);
attributes.remove(elementIndex);
entity.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 EntityTypeConfigAction method addAttribute.
@Override
public String addAttribute() {
this.updateEntityOnSession();
try {
IEntityManager entityManager = this.getEntityManager();
Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
if (null == attributeTypes.get(this.getAttributeTypeCode())) {
String[] args = { this.getAttributeTypeCode() };
this.addFieldError("attributeTypeCode", this.getText("error.attribute.not.exists", args));
return INPUT;
}
} catch (Throwable t) {
_logger.error("error in addAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "addAttribute");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface in project entando-core by entando.
the class EntityTypeConfigAction method moveAttribute.
@Override
public String moveAttribute() {
IApsEntity entity = this.updateEntityOnSession();
try {
int elementIndex = this.getAttributeIndex();
String movement = this.getMovement();
List<AttributeInterface> attributes = entity.getAttributeList();
if (!(elementIndex == 0 && movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) && !(elementIndex == attributes.size() - 1 && movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE))) {
AttributeInterface attributeToMove = attributes.get(elementIndex);
attributes.remove(elementIndex);
if (movement.equals(ApsAdminSystemConstants.MOVEMENT_UP_CODE)) {
attributes.add(elementIndex - 1, attributeToMove);
}
if (movement.equals(ApsAdminSystemConstants.MOVEMENT_DOWN_CODE)) {
attributes.add(elementIndex + 1, attributeToMove);
}
}
} catch (Throwable t) {
_logger.error("error in moveAttribute", t);
// ApsSystemUtils.logThrowable(t, this, "moveAttribute");
return FAILURE;
}
return SUCCESS;
}
Aggregations