use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class PageFinderAction method searchPages.
public List<IPage> searchPages() {
List<IPage> result = null;
try {
List<String> allowedGroupCodes = this.getAllowedGroupCodes();
result = this.getPageManager().searchPages(this.getPageCodeToken(), allowedGroupCodes);
BeanComparator comparator = new BeanComparator("code");
Collections.sort(result, comparator);
if (result != null) {
if (result.size() > 0) {
this.setFirstNode(result.get(0));
}
Collection<String> resultCodes = new ArrayList<>();
for (IPage page : result) {
resultCodes.add(page.getCode());
}
this.setResultCodes(resultCodes);
}
} catch (Throwable t) {
_logger.error("Error on searching pages", t);
throw new RuntimeException("Error on searching pages", t);
}
return result;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class BaseAction method getActualAllowedGroups.
protected List<Group> getActualAllowedGroups() {
if (null != this._actualAllowedGroups) {
return _actualAllowedGroups;
}
this._actualAllowedGroups = new ArrayList<Group>();
UserDetails currentUser = this.getCurrentUser();
if (null == currentUser || null == this.getRequiredPermissions()) {
return this._actualAllowedGroups;
}
Iterator<String> iter = this.getRequiredPermissions().iterator();
while (iter.hasNext()) {
String permissionName = iter.next();
List<Group> groupsByPermission = this.getAuthorizationManager().getGroupsByPermission(currentUser, permissionName);
if (null != groupsByPermission) {
for (int i = 0; i < groupsByPermission.size(); i++) {
Group group = groupsByPermission.get(i);
if (null != group && !this._actualAllowedGroups.contains(group)) {
this._actualAllowedGroups.add(group);
}
}
}
}
Collections.sort(this._actualAllowedGroups, new BeanComparator("description"));
return this._actualAllowedGroups;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class EntityTypeConfigAction method getAttributeTypes.
public List<AttributeInterface> getAttributeTypes() {
List<AttributeInterface> attributes = null;
try {
IEntityManager entityManager = this.getEntityManager();
Map<String, AttributeInterface> attributeTypes = entityManager.getEntityAttributePrototypes();
attributes = new ArrayList<AttributeInterface>(attributeTypes.values());
Collections.sort(attributes, new BeanComparator("type"));
} catch (Throwable t) {
_logger.error("Error while extracting attribute Types", t);
// ApsSystemUtils.logThrowable(t, this, "getAttributeTypes");
throw new RuntimeException("Error while extracting attribute Types", t);
}
return attributes;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class EntityTypesAction method getEntityPrototypes.
@Override
public List<IApsEntity> getEntityPrototypes() {
List<IApsEntity> entityPrototypes = null;
try {
Map<String, IApsEntity> modelMap = this.getEntityManager().getEntityPrototypes();
entityPrototypes = new ArrayList<IApsEntity>(modelMap.values());
BeanComparator comparator = new BeanComparator("typeDescr");
Collections.sort(entityPrototypes, comparator);
} catch (Throwable t) {
_logger.error("Error on extracting entity prototypes", t);
// ApsSystemUtils.logThrowable(t, this, "getEntityPrototypes");
throw new RuntimeException("Error on extracting entity prototypes", t);
}
return entityPrototypes;
}
use of org.apache.commons.beanutils.BeanComparator in project entando-core by entando.
the class HookPointTag method extractElements.
private List<HookPointElementContainer> extractElements(HttpServletRequest request) {
WebApplicationContext wac = ApsWebApplicationUtils.getWebApplicationContext(request);
String[] beanNames = wac.getBeanNamesForType(HookPointElementContainer.class);
List<HookPointElementContainer> containers = new ArrayList<HookPointElementContainer>();
for (int i = 0; i < beanNames.length; i++) {
HookPointElementContainer container = (HookPointElementContainer) wac.getBean(beanNames[i]);
if (null != container && null != container.getHookPointKey() && container.getHookPointKey().equals(this.getKey())) {
containers.add(container);
}
}
BeanComparator comparator = new BeanComparator("priority");
Collections.sort(containers, comparator);
return containers;
}
Aggregations