Search in sources :

Example 26 with ConfigBean

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;
}
Also used : JSONArray(com.alibaba.fastjson.JSONArray) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 27 with ConfigBean

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);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) ConfigBean(com.rebuild.core.configuration.ConfigBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with ConfigBean

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);
    }
}
Also used : EasyEntity(com.rebuild.core.metadata.easymeta.EasyEntity) Entity(cn.devezhao.persist4j.Entity) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean) RecordTransfomer(com.rebuild.core.service.general.transform.RecordTransfomer) RepeatedRecordsException(com.rebuild.core.service.general.RepeatedRecordsException) RepeatedRecordsException(com.rebuild.core.service.general.RepeatedRecordsException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with ConfigBean

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());
    }
}
Also used : ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 30 with ConfigBean

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);
}
Also used : Entity(cn.devezhao.persist4j.Entity) Field(cn.devezhao.persist4j.Field) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JSONObject(com.alibaba.fastjson.JSONObject) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

ConfigBean (com.rebuild.core.configuration.ConfigBean)52 ID (cn.devezhao.persist4j.engine.ID)26 JSONObject (com.alibaba.fastjson.JSONObject)23 JSONArray (com.alibaba.fastjson.JSONArray)16 JSON (com.alibaba.fastjson.JSON)9 GetMapping (org.springframework.web.bind.annotation.GetMapping)9 Entity (cn.devezhao.persist4j.Entity)8 ArrayList (java.util.ArrayList)7 Field (cn.devezhao.persist4j.Field)6 Record (cn.devezhao.persist4j.Record)5 ConfigurationException (com.rebuild.core.configuration.ConfigurationException)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 DataSpecificationException (com.rebuild.core.service.DataSpecificationException)2 AdvFilterParser (com.rebuild.core.service.query.AdvFilterParser)2 List (java.util.List)2 Set (java.util.Set)2 Test (org.junit.jupiter.api.Test)2 Permission (cn.devezhao.bizz.privileges.Permission)1 BizzPermission (cn.devezhao.bizz.privileges.impl.BizzPermission)1