use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class MetadataGetting method references.
// 哪些实体引用了指定实体
@GetMapping("references")
public List<String[]> references(HttpServletRequest request) {
final ID user = getRequestUser(request);
Entity entity = MetadataHelper.getEntity(getParameterNotNull(request, "entity"));
String permission = getParameter(request, "permission");
Permission checkPermission = null;
if (permission != null) {
checkPermission = PrivilegesManager.parse(permission);
}
Set<Entity> references = new HashSet<>();
for (Field field : entity.getReferenceToFields()) {
Entity own = field.getOwnEntity();
if (!(own.getMainEntity() != null || field.getType() == FieldType.ANY_REFERENCE)) {
references.add(own);
}
}
List<String[]> data = new ArrayList<>();
for (Entity e : references) {
if (checkPermission == null || Application.getPrivilegesManager().allow(user, e.getEntityCode(), checkPermission)) {
EasyEntity easy = EasyMetaFactory.valueOf(e);
data.add(new String[] { easy.getName(), easy.getLabel() });
}
}
return data;
}
Aggregations