use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class BaseContentDispenser method getBaseRenderizationInfo.
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx, boolean cacheable) {
ContentRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
Content contentToRender = this.getContentManager().loadContent(contentId, true, cacheable);
String renderedContent = this.buildRenderedContent(contentToRender, modelId, langCode, reqCtx);
if (null != renderedContent && renderedContent.trim().length() > 0) {
List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
renderInfo = new ContentRenderizationInfo(contentToRender, renderedContent, modelId, langCode, roles);
}
}
} catch (Throwable t) {
_logger.error("Error while rendering content {}", contentId, t);
return null;
}
return renderInfo;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class EntityActionHelper method getRoleFilters.
@Override
public EntitySearchFilter[] getRoleFilters(AbstractApsEntityFinderAction entityFinderAction) {
EntitySearchFilter[] filters = new EntitySearchFilter[0];
List<AttributeRole> attributeRoles = entityFinderAction.getAttributeRoles();
if (null != attributeRoles) {
for (int i = 0; i < attributeRoles.size(); i++) {
AttributeRole attributeRole = attributeRoles.get(i);
if (AttributeRole.FormFieldTypes.TEXT.equals(attributeRole.getFormFieldType())) {
String insertedText = entityFinderAction.getSearchFormFieldValue(attributeRole.getName() + "_textFieldName");
if (null != insertedText && insertedText.trim().length() > 0) {
EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), insertedText.trim(), true);
filters = this.addFilter(filters, filterToAdd);
}
} else if (AttributeRole.FormFieldTypes.DATE.equals(attributeRole.getFormFieldType())) {
Date dateStart = this.getDateSearchFormValue(entityFinderAction, attributeRole.getName(), "_dateStartFieldName", true);
Date dateEnd = this.getDateSearchFormValue(entityFinderAction, attributeRole.getName(), "_dateEndFieldName", false);
if (null != dateStart || null != dateEnd) {
EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), dateStart, dateEnd);
filters = this.addFilter(filters, filterToAdd);
}
} else if (AttributeRole.FormFieldTypes.BOOLEAN.equals(attributeRole.getFormFieldType())) {
String booleanValue = entityFinderAction.getSearchFormFieldValue(attributeRole.getName() + "_booleanFieldName");
if (null != booleanValue && booleanValue.trim().length() > 0) {
EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), booleanValue, false);
filters = this.addFilter(filters, filterToAdd);
}
} else if (AttributeRole.FormFieldTypes.NUMBER.equals(attributeRole.getFormFieldType())) {
BigDecimal numberStart = this.getNumberSearchFormValue(entityFinderAction, attributeRole.getName(), "_numberStartFieldName", true);
BigDecimal numberEnd = this.getNumberSearchFormValue(entityFinderAction, attributeRole.getName(), "_numberEndFieldName", false);
if (null != numberStart || null != numberEnd) {
EntitySearchFilter filterToAdd = EntitySearchFilter.createRoleFilter(attributeRole.getName(), numberStart, numberEnd);
filters = this.addFilter(filters, filterToAdd);
}
}
}
}
return filters;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class AbstractBaseEntityAttributeConfigAction method getAttributeRoles.
protected List<AttributeRole> getAttributeRoles(String attributeTypeCode) {
List<AttributeRole> rolesByType = new ArrayList<AttributeRole>();
List<AttributeRole> roles = this.getEntityManager().getAttributeRoles();
if (null == roles) {
return rolesByType;
}
for (int i = 0; i < roles.size(); i++) {
AttributeRole role = roles.get(i);
if (role.getAllowedAttributeTypes().contains(attributeTypeCode)) {
rolesByType.add(role);
}
}
return rolesByType;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class AbstractBaseEntityAttributeConfigAction method getFreeAttributeRoleNames.
/**
* Return the list of the attribute role not in use on the entity type on edit.
* @return The list of the free attribute roles.
*/
public List<AttributeRole> getFreeAttributeRoleNames() {
List<AttributeRole> freeRoles = new ArrayList<AttributeRole>();
List<AttributeRole> roles = this.getAttributeRoles(this.getAttributeTypeCode());
if (null == roles) {
return freeRoles;
}
for (int i = 0; i < roles.size(); i++) {
AttributeRole role = roles.get(i);
AttributeInterface utilizer = this.getEntityType().getAttributeByRole(role.getName());
if (null == utilizer || utilizer.getName().equals(this.getAttributeName())) {
freeRoles.add(role);
}
}
return freeRoles;
}
use of com.agiletec.aps.system.common.entity.model.attribute.AttributeRole in project entando-core by entando.
the class EntityAttributeConfigAction method addAttributeRole.
@Override
public String addAttributeRole() {
try {
String attributeRoleName = this.getAttributeRoleName();
if (null == this.getAttributeRoles()) {
this.setAttributeRoles(new ArrayList<String>());
}
List<AttributeRole> allowedRoles = this.getAttributeRoles(this.getAttributeTypeCode());
boolean allowed = false;
if (null != allowedRoles) {
for (int i = 0; i < allowedRoles.size(); i++) {
AttributeRole role = allowedRoles.get(i);
if (role.getName().equals(this.getAttributeRoleName())) {
allowed = true;
break;
}
}
}
if (!allowed) {
// TODO ADD FIELD ERRORS - Role not allowed for type ...
return SUCCESS;
}
if (!this.getAttributeRoles().contains(attributeRoleName)) {
this.getAttributeRoles().add(attributeRoleName);
}
} catch (Throwable t) {
_logger.error("error in addAttributeRole", t);
// ApsSystemUtils.logThrowable(t, this, "addAttributeRole");
return FAILURE;
}
return SUCCESS;
}
Aggregations