use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class MetaSchemaGenerator method performPickList.
private JSON performPickList(Field field) {
ConfigBean[] entries = PickListManager.instance.getPickListRaw(field.getOwnEntity().getName(), field.getName(), false);
JSONArray items = new JSONArray();
for (ConfigBean e : entries) {
items.add(new Object[] { e.getString("text"), e.getBoolean("default"), e.getLong("mask") });
}
return items;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ChartDataController method viewChartSource.
/**
* @param response
* @throws IOException
* @see DataListBuilderImpl
*/
@RequestMapping("view-chart-source")
public void viewChartSource(@IdParam ID chartId, HttpServletResponse response) throws IOException {
ConfigBean configEntry = ChartManager.instance.getChart(chartId);
JSONObject config = (JSONObject) configEntry.getJSON("config");
String sourceEntity = config.getString("entity");
String url = MessageFormat.format("../app/{0}/list#via={1}", sourceEntity, chartId);
response.sendRedirect(url);
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ModelExtrasController method transform.
// 记录转换
@RequestMapping("transform")
public RespBody transform(HttpServletRequest request) {
ID transid = getIdParameterNotNull(request, "transid");
ID sourceRecord = getIdParameterNotNull(request, "source");
ID mainid = getIdParameter(request, "mainid");
ConfigBean config = TransformManager.instance.getTransformConfig(transid, null);
Entity targetEntity = MetadataHelper.getEntity(config.getString("target"));
RecordTransfomer transfomer = new RecordTransfomer(targetEntity, (JSONObject) config.getJSON("config"));
if (!transfomer.checkFilter(sourceRecord)) {
return RespBody.error(Language.L("当前记录不符合转换条件"), 400);
}
try {
ID newId = transfomer.transform(sourceRecord, mainid);
return RespBody.ok(newId);
} catch (Exception ex) {
log.warn(">>>>> {}", ex.getLocalizedMessage());
String detail = ex.getLocalizedMessage();
if (ex instanceof RepeatedRecordsException) {
detail = Language.L("存在重复记录");
}
return RespBody.errorl("记录转换失败 (%s)", detail);
}
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class AdvFilterController method gets.
@GetMapping("advfilter/get")
public RespBody gets(@PathVariable String entity, HttpServletRequest request) {
ID filterId = getIdParameter(request, "id");
ConfigBean filter = AdvFilterManager.instance.getAdvFilter(filterId);
if (filter == null) {
return RespBody.errorl("未知过滤条件");
} else {
return RespBody.ok(filter.toJSON());
}
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ShowFieldsController method gets.
@GetMapping("list-fields")
public void gets(@PathVariable String entity, HttpServletRequest request, HttpServletResponse response) {
final ID user = getRequestUser(request);
final Entity entityMeta = MetadataHelper.getEntity(entity);
List<Map<String, Object>> fieldList = new ArrayList<>();
for (Field field : MetadataSorter.sortFields(entityMeta)) {
if (canListField(field)) {
fieldList.add(DataListManager.instance.formatField(field));
}
}
// 明细关联字段
final Field dtmField = entityMeta.getMainEntity() == null ? null : MetadataHelper.getDetailToMainField(entityMeta);
// 引用实体的字段
for (Field field : MetadataSorter.sortFields(entityMeta, DisplayType.REFERENCE)) {
// 过滤所属用户/所属部门等系统字段(除了明细引用(主实体)字段)
if (EasyMetaFactory.valueOf(field).isBuiltin() && (dtmField == null || !dtmField.equals(field))) {
continue;
}
Entity refEntity = field.getReferenceEntity();
// 无权限的不返回
if (!Application.getPrivilegesManager().allowRead(user, refEntity.getEntityCode())) {
continue;
}
for (Field fieldOfRef : MetadataSorter.sortFields(refEntity)) {
if (canListField(fieldOfRef)) {
fieldList.add(DataListManager.instance.formatField(fieldOfRef, field));
}
}
}
ConfigBean raw;
String cfgid = request.getParameter("id");
if ("NEW".equalsIgnoreCase(cfgid)) {
raw = new ConfigBean();
raw.set("config", JSONUtils.EMPTY_ARRAY);
} else if (ID.isId(cfgid)) {
raw = DataListManager.instance.getLayoutById(ID.valueOf(cfgid));
} else {
raw = DataListManager.instance.getLayoutOfDatalist(user, entity);
}
JSONObject config = (JSONObject) DataListManager.instance.formatFieldsLayout(entity, user, false, raw);
Map<String, Object> ret = new HashMap<>();
ret.put("fieldList", fieldList);
ret.put("configList", config.getJSONArray("fields"));
if (raw != null) {
ret.put("configId", raw.getID("id"));
ret.put("shareTo", raw.getString("shareTo"));
}
writeSuccess(response, ret);
}
Aggregations