Search in sources :

Example 11 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class ChartManager method getChart.

/**
 * @param chartid
 * @return
 */
public ConfigBean getChart(ID chartid) {
    final String ckey = "Chart-" + chartid;
    ConfigBean cb = (ConfigBean) Application.getCommonsCache().getx(ckey);
    if (cb != null) {
        return cb.clone();
    }
    Object[] o = Application.createQueryNoFilter("select title,chartType,config,createdBy from ChartConfig where chartId = ?").setParameter(1, chartid).unique();
    if (o == null) {
        for (BuiltinChart ch : ChartsFactory.getBuiltinCharts()) {
            if (chartid.equals(ch.getChartId())) {
                o = new Object[] { ch.getChartTitle(), ch.getChartType(), ch.getChartConfig(), UserService.SYSTEM_USER };
            }
        }
        if (o == null) {
            return null;
        }
    }
    cb = new ConfigBean().set("title", o[0]).set("type", o[1]).set("config", o[2] instanceof JSON ? o[2] : JSON.parse((String) o[2])).set("createdBy", o[3]);
    Application.getCommonsCache().putx(ckey, cb);
    return cb.clone();
}
Also used : BuiltinChart(com.rebuild.core.service.dashboard.charts.builtin.BuiltinChart) JSONObject(com.alibaba.fastjson.JSONObject) JSON(com.alibaba.fastjson.JSON) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 12 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class ProjectTaskController method pageTask.

@GetMapping("task/{taskId}")
public ModelAndView pageTask(@PathVariable String taskId, HttpServletRequest request, HttpServletResponse response) throws IOException {
    final ID taskId2 = ID.isId(taskId) ? ID.valueOf(taskId) : null;
    if (taskId2 == null) {
        response.sendError(404);
        return null;
    }
    final ID user = getRequestUser(request);
    if (!ProjectHelper.checkReadable(taskId2, user)) {
        response.sendError(403, Language.L("你无权查看此任务"));
        return null;
    }
    ConfigBean project = ProjectManager.instance.getProjectByX(taskId2, user);
    ModelAndView mv = createModelAndView("/project/task-view");
    mv.getModel().put("id", taskId2.toLiteral());
    mv.getModel().put("projectIcon", project.getString("iconName"));
    mv.getModel().put("projectStatus", project.getInteger("status"));
    mv.getModel().put("isMember", project.get("members", Set.class).contains(user));
    return mv;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 13 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class TransformConfigController method pageEditor.

@GetMapping("transform/{id}")
public ModelAndView pageEditor(@PathVariable String id, HttpServletResponse response) throws IOException {
    ModelAndView mv = createModelAndView("/admin/robot/transform-editor");
    ID configId = ID.isId(id) ? ID.valueOf(id) : null;
    if (configId == null) {
        response.sendError(404);
        return null;
    }
    ConfigBean config;
    try {
        config = TransformManager.instance.getTransformConfig(configId, null);
    } catch (ConfigurationException notExists) {
        response.sendError(404);
        return null;
    }
    mv.getModelMap().put("configId", configId);
    mv.getModelMap().put("config", config.getJSON("config"));
    Entity sourceEntity = MetadataHelper.getEntity(config.getString("source"));
    Entity targetEntity = MetadataHelper.getEntity(config.getString("target"));
    // 主实体
    mv.getModelMap().put("sourceEntity", buildEntity(sourceEntity, true));
    mv.getModelMap().put("targetEntity", buildEntity(targetEntity, false));
    // 明细(两个实体均有明细才返回)
    if (sourceEntity.getDetailEntity() != null && targetEntity.getDetailEntity() != null) {
        mv.getModelMap().put("sourceDetailEntity", buildEntity(sourceEntity.getDetailEntity(), true));
        mv.getModelMap().put("targetDetailEntity", buildEntity(targetEntity.getDetailEntity(), false));
    }
    mv.getModelMap().put("name", config.getString("name"));
    return mv;
}
Also used : Entity(cn.devezhao.persist4j.Entity) ConfigurationException(com.rebuild.core.configuration.ConfigurationException) ModelAndView(org.springframework.web.servlet.ModelAndView) ID(cn.devezhao.persist4j.engine.ID) ConfigBean(com.rebuild.core.configuration.ConfigBean) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 14 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class ApiGatewayTest method createApp.

/**
 * 创建用于调用接口的 API Key
 *
 * @return
 */
protected static String[] createApp() {
    final String appId = "999999999";
    ConfigBean exists = RebuildApiManager.instance.getApp(appId);
    if (exists != null) {
        return new String[] { appId, exists.getString("appSecret") };
    }
    String appSecret = CodecUtils.randomCode(40);
    Record record = RecordBuilder.builder(EntityHelper.RebuildApi).add("appId", appId).add("appSecret", appSecret).add("bindUser", UserService.SYSTEM_USER).build(UserService.SYSTEM_USER);
    Application.getCommonsService().create(record, false);
    RebuildApiManager.instance.clean(appId);
    return new String[] { appId, appSecret };
}
Also used : Record(cn.devezhao.persist4j.Record) ConfigBean(com.rebuild.core.configuration.ConfigBean)

Example 15 with ConfigBean

use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.

the class FormsManagerTest method testGet.

@Test
public void testGet() {
    ConfigBean entry = FormsManager.instance.getFormLayout("User", UserService.ADMIN_USER);
    System.out.println(entry.toJSON());
}
Also used : ConfigBean(com.rebuild.core.configuration.ConfigBean) Test(org.junit.jupiter.api.Test)

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