use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class MetaFieldController method pageEntityField.
@GetMapping("{entity}/field/{field}")
public ModelAndView pageEntityField(@PathVariable String entity, @PathVariable String field, HttpServletRequest request) {
ModelAndView mv = createModelAndView("/admin/metadata/field-edit");
EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
Field fieldMeta = easyEntity.getRawMeta().getField(field);
EasyField easyField = EasyMetaFactory.valueOf(fieldMeta);
mv.getModel().put("fieldMetaId", easyField.getMetaId());
mv.getModel().put("fieldName", easyField.getName());
mv.getModel().put("fieldLabel", easyField.getLabel());
mv.getModel().put("fieldComments", easyField.getComments());
mv.getModel().put("fieldType", easyField.getDisplayType(false));
mv.getModel().put("fieldTypeLabel", easyField.getDisplayType(true));
mv.getModel().put("fieldNullable", fieldMeta.isNullable());
mv.getModel().put("fieldCreatable", fieldMeta.isCreatable());
mv.getModel().put("fieldUpdatable", fieldMeta.isUpdatable());
mv.getModel().put("fieldRepeatable", fieldMeta.isRepeatable());
mv.getModel().put("fieldQueryable", fieldMeta.isQueryable());
mv.getModel().put("fieldBuildin", easyField.isBuiltin());
mv.getModel().put("fieldDefaultValue", fieldMeta.getDefaultValue());
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
// 明细实体
if (easyEntity.getRawMeta().getMainEntity() != null) {
Field dtmField = MetadataHelper.getDetailToMainField(easyEntity.getRawMeta());
mv.getModel().put("isDetailToMainField", dtmField.equals(fieldMeta));
} else {
mv.getModel().put("isDetailToMainField", false);
}
// 字段类型相关
Type ft = fieldMeta.getType();
if (ft == FieldType.REFERENCE || ft == FieldType.REFERENCE_LIST) {
Entity refEntity = fieldMeta.getReferenceEntity();
mv.getModel().put("fieldRefentity", refEntity.getName());
mv.getModel().put("fieldRefentityLabel", EasyMetaFactory.getLabel(refEntity));
}
// 扩展配置
JSONObject extraAttrs = new JSONObject();
for (Map.Entry<String, Object> e : easyField.getExtraAttrs(true).entrySet()) {
String name = e.getKey();
// 排除私有
if (!name.startsWith("_"))
extraAttrs.put(name, e.getValue());
}
mv.getModel().put("fieldExtConfig", extraAttrs);
return mv;
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class MetaFieldController method page.
@GetMapping("{entity}/fields")
public ModelAndView page(@PathVariable String entity, HttpServletRequest request) {
ModelAndView mv = createModelAndView("/admin/metadata/fields");
EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
mv.getModel().put("nameField", easyEntity.getRawMeta().getNameField().getName());
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
return mv;
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class AutoFillinController method page.
@RequestMapping("{field}/auto-fillin")
public ModelAndView page(@PathVariable String entity, @PathVariable String field) {
ModelAndView mv = createModelAndView("/admin/metadata/auto-fillin");
EasyEntity easyEntity = MetaEntityController.setEntityBase(mv, entity);
Field fieldMeta = easyEntity.getRawMeta().getField(field);
mv.getModel().put("fieldName", fieldMeta.getName());
mv.getModel().put("referenceEntity", fieldMeta.getReferenceEntity().getName());
mv.getModel().put("referenceEntityLabel", EasyMetaFactory.getLabel(fieldMeta.getReferenceEntity()));
return mv;
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class MetaEntityController method pageAdvanced.
@GetMapping("entity/{entity}/advanced")
public ModelAndView pageAdvanced(@PathVariable String entity, HttpServletRequest request) {
ModelAndView mv = createModelAndView("/admin/metadata/entity-advanced");
mv.getModel().put("isSuperAdmin", UserHelper.isSuperAdmin(getRequestUser(request)));
EasyEntity easyEntity = setEntityBase(mv, entity);
// 扩展配置
mv.getModel().put("entityExtConfig", easyEntity.getExtraAttrs(true));
boolean isDetail = easyEntity.getRawMeta().getMainEntity() != null;
boolean isBizz = MetadataHelper.isBizzEntity(easyEntity.getRawMeta());
mv.getModel().put("useListMode", !(isDetail || isBizz));
return mv;
}
use of com.rebuild.core.metadata.easymeta.EasyEntity in project rebuild by getrebuild.
the class FeedsListController method buildItem.
private JSONObject buildItem(Object[] o, ID user) {
JSONObject item = formatBase(o, user);
FeedsScope scope = FeedsScope.parse((String) o[7]);
item.put("scopeRaw", o[7]);
if (scope == FeedsScope.GROUP) {
Team team = Application.getUserStore().getTeam(ID.valueOf((String) o[7]));
item.put("scope", new Object[] { team.getIdentity(), team.getName() });
} else {
item.put("scope", Language.L(scope.getName()));
}
item.put("type", o[8]);
item.put("numComments", FeedsHelper.getNumOfComment((ID) o[0]));
// 相关记录
ID related = (ID) o[9];
if (related != null && MetadataHelper.containsEntity(related.getEntityCode())) {
EasyEntity entity = EasyMetaFactory.valueOf(related.getEntityCode());
String nameValue = FieldValueHelper.getLabelNotry(related);
JSONObject mixValue = FieldValueHelper.wrapMixValue(related, nameValue);
mixValue.put("icon", entity.getIcon());
mixValue.put("entityLabel", entity.getLabel());
item.put("relatedRecord", mixValue);
}
// 更多内容
if (o[10] != null) {
item.put("contentMore", JSON.parse((String) o[10]));
}
return item;
}
Aggregations