use of com.rebuild.core.metadata.easymeta.EasyEntity 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 com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class NavBuilder method addInitNavOnInstall.
/**
* 首次安装添加菜单
*
* @param initEntity
*/
public void addInitNavOnInstall(String[] initEntity) {
JSONArray initNav = replaceLang(NAVS_DEFAULT);
for (String e : initEntity) {
EasyEntity entity = EasyMetaFactory.valueOf(e);
JSONObject navItem = JSONUtils.toJSONObject(NAV_ITEM_PROPS, new String[] { entity.getIcon(), entity.getLabel(), "ENTITY", entity.getName() });
initNav.add(navItem);
}
Record record = RecordBuilder.builder(EntityHelper.LayoutConfig).add("belongEntity", "N").add("shareTo", SHARE_ALL).add("applyType", TYPE_NAV).add("config", initNav.toJSONString()).build(UserService.SYSTEM_USER);
UserContextHolder.setUser(UserService.SYSTEM_USER);
try {
Application.getService(EntityHelper.LayoutConfig).create(record);
} finally {
UserContextHolder.clear();
}
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class EntityController method putEntityMeta.
/**
* @param into
* @param entity
*/
protected void putEntityMeta(ModelAndView into, Entity entity) {
EasyEntity easyMeta = EasyMetaFactory.valueOf(entity);
into.getModel().put("entityName", easyMeta.getName());
into.getModel().put("entityLabel", easyMeta.getLabel());
into.getModel().put("entityIcon", easyMeta.getIcon());
EasyEntity main = null;
EasyEntity detail = null;
if (entity.getMainEntity() != null) {
main = EasyMetaFactory.valueOf(entity.getMainEntity());
detail = EasyMetaFactory.valueOf(entity);
} else if (entity.getDetailEntity() != null) {
main = EasyMetaFactory.valueOf(entity);
detail = EasyMetaFactory.valueOf(entity.getDetailEntity());
} else {
into.getModel().put("mainEntity", easyMeta.getName());
}
if (main != null) {
into.getModel().put("mainEntity", main.getName());
into.getModel().put("mainEntityLabel", main.getLabel());
into.getModel().put("mainEntityIcon", main.getIcon());
into.getModel().put("detailEntity", detail.getName());
into.getModel().put("detailEntityLabel", detail.getLabel());
into.getModel().put("detailEntityIcon", detail.getIcon());
}
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class GeneralListController method pageList.
@GetMapping("list")
public ModelAndView pageList(@PathVariable String entity, HttpServletRequest request, HttpServletResponse response) throws IOException {
final ID user = getRequestUser(request);
final Entity listEntity = checkPageOfEntity(user, entity, response);
if (listEntity == null)
return null;
final EasyEntity easyEntity = EasyMetaFactory.valueOf(listEntity);
// 使用主实体列表配置
final EasyEntity mainEntity = listEntity.getMainEntity() == null ? easyEntity : EasyMetaFactory.valueOf(listEntity.getMainEntity());
String listPage = listEntity.getMainEntity() != null ? "/general/detail-list" : "/general/record-list";
Integer listMode = getIntParameter(request, "forceListMode");
if (listMode == null) {
listMode = ObjectUtils.toInt(mainEntity.getExtraAttr(EasyEntityConfigProps.ADV_LIST_MODE), 1);
}
if (listMode == 2) {
// Mode2
listPage = "/general/record-list2";
}
ModelAndView mv = createModelAndView(listPage, entity, user);
// 列表相关权限
mv.getModel().put(ZeroEntry.AllowCustomDataList.name(), Application.getPrivilegesManager().allow(user, ZeroEntry.AllowCustomDataList));
mv.getModel().put(ZeroEntry.AllowDataExport.name(), Application.getPrivilegesManager().allow(user, ZeroEntry.AllowDataExport));
mv.getModel().put(ZeroEntry.AllowBatchUpdate.name(), Application.getPrivilegesManager().allow(user, ZeroEntry.AllowBatchUpdate));
JSON listConfig = null;
if (listMode == 1) {
listConfig = DataListManager.instance.getFieldsLayout(entity, user);
// 扩展配置
String advListHideFilters = mainEntity.getExtraAttr(EasyEntityConfigProps.ADV_LIST_HIDE_FILTERS);
String advListHideCharts = mainEntity.getExtraAttr(EasyEntityConfigProps.ADV_LIST_HIDE_CHARTS);
mv.getModel().put(EasyEntityConfigProps.ADV_LIST_HIDE_FILTERS, advListHideFilters);
mv.getModel().put(EasyEntityConfigProps.ADV_LIST_HIDE_CHARTS, advListHideCharts);
mv.getModel().put("hideAside", BooleanUtils.toBoolean(advListHideFilters) && BooleanUtils.toBoolean(advListHideCharts));
} else if (listMode == 2) {
listConfig = DataListManager.instance.getFieldsLayoutMode2(listEntity);
// 明细列表
if (listEntity.getMainEntity() != null)
mv.getModel().put("DataListType", "DetailList");
}
mv.getModel().put("DataListConfig", JSON.toJSONString(listConfig));
// 快速查询
mv.getModel().put("quickFieldsLabel", getQuickFieldsLabel(listEntity));
return mv;
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class ModelExtrasController method checkCreates.
@GetMapping("check-creates")
public JSON checkCreates(HttpServletRequest request) {
final ID user = getRequestUser(request);
String entity = getParameter(request, "entity", "");
JSONArray allowed = new JSONArray();
for (String e : entity.split(",")) {
if (!MetadataHelper.containsEntity(e))
continue;
EasyEntity easyEntity = EasyMetaFactory.valueOf(e);
if (!MetadataHelper.hasPrivilegesField(easyEntity.getRawMeta()))
continue;
if (Application.getPrivilegesManager().allow(user, easyEntity.getRawMeta().getEntityCode(), BizzPermission.CREATE)) {
allowed.add(easyEntity.toJSON());
}
}
return allowed;
}
Aggregations