use of com.agiletec.aps.system.common.entity.model.IApsEntity 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));
}
}
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity 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.IApsEntity in project entando-core by entando.
the class EntityTypeConfigAction method addEntityType.
@Override
public String addEntityType() {
try {
String checkEntityManagerResult = this.checkEntityManager();
if (null != checkEntityManagerResult)
return checkEntityManagerResult;
Class entityClass = this.getEntityManager().getEntityClass();
IApsEntity entityType = (IApsEntity) entityClass.newInstance();
this.initSessionParams(entityType, ApsAdminSystemConstants.ADD);
} catch (Throwable t) {
_logger.error("error in addEntityType", t);
// ApsSystemUtils.logThrowable(t, this, "addEntityType");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class EntityTypeConfigAction method editEntityType.
@Override
public String editEntityType() {
try {
String checkEntityManagerResult = this.checkEntityManager();
if (null != checkEntityManagerResult)
return checkEntityManagerResult;
IApsEntity entityType = this.getEntityPrototype(this.getEntityTypeCode());
if (null == entityType) {
String[] args = { this.getEntityTypeCode() };
this.addFieldError("entityTypeCode", this.getText("error.entity.type.null", args));
return INPUT;
}
this.initSessionParams(entityType, ApsAdminSystemConstants.EDIT);
} catch (Throwable t) {
_logger.error("error in editEntityType", t);
// ApsSystemUtils.logThrowable(t, this, "editEntityType");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity 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