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();
}
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;
}
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;
}
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 };
}
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());
}
Aggregations