use of cn.devezhao.persist4j.metadata.BaseMeta in project rebuild by getrebuild.
the class MetadataSorter method sortEntities.
/**
* 用户权限内*可读*实体
*
* @param user
* @param usesBizz 是否包括内置 BIZZ 实体
* @param usesDetail 是否包括明细实体
* @return
*/
public static Entity[] sortEntities(ID user, boolean usesBizz, boolean usesDetail) {
List<BaseMeta> entities = new ArrayList<>();
for (Entity e : MetadataHelper.getEntities()) {
if (!e.isQueryable())
continue;
if (!usesDetail && e.getMainEntity() != null)
continue;
EasyEntity easyEntity = EasyMetaFactory.valueOf(e);
if (easyEntity.isBuiltin() && !easyEntity.isPlainEntity())
continue;
Entity checkEntity = e;
if (usesDetail && e.getMainEntity() != null)
checkEntity = e.getMainEntity();
if (user == null || !MetadataHelper.hasPrivilegesField(checkEntity)) {
entities.add(e);
} else if (Application.getPrivilegesManager().allowRead(user, checkEntity.getEntityCode())) {
entities.add(e);
}
}
sortByLabel(entities);
if (usesBizz) {
entities.add(MetadataHelper.getEntity(EntityHelper.User));
entities.add(MetadataHelper.getEntity(EntityHelper.Department));
entities.add(MetadataHelper.getEntity(EntityHelper.Role));
entities.add(MetadataHelper.getEntity(EntityHelper.Team));
}
return entities.toArray(new Entity[0]);
}
use of cn.devezhao.persist4j.metadata.BaseMeta in project rebuild by getrebuild.
the class MetadataSorter method sortByLevel.
/**
* 按字段分类排序
*
* @param fields
*/
static Field[] sortByLevel(List<BaseMeta> fields) {
List<BaseMeta> othersFields = new ArrayList<>();
List<BaseMeta> commonsFields = new ArrayList<>();
List<BaseMeta> approvalFields = new ArrayList<>();
for (BaseMeta field : fields) {
if (MetadataHelper.isApprovalField(field.getName())) {
approvalFields.add(field);
} else if (MetadataHelper.isCommonsField((Field) field)) {
commonsFields.add(field);
} else {
othersFields.add(field);
}
}
sortByLabel(othersFields);
List<BaseMeta> allFields = new ArrayList<>(othersFields);
sortByLabel(commonsFields);
allFields.addAll(commonsFields);
sortByLabel(approvalFields);
allFields.addAll(approvalFields);
return allFields.toArray(new Field[0]);
}
Aggregations