use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProtocolFilterParser method parseVia.
/**
* @param viaId
* @param refField
* @return
*/
public String parseVia(String viaId, String refField) {
final ID anyId = ID.isId(viaId) ? ID.valueOf(viaId) : null;
if (anyId == null)
return null;
JSONObject filterExp = null;
// via Charts
if (anyId.getEntityCode() == EntityHelper.ChartConfig) {
ConfigBean chart = ChartManager.instance.getChart(anyId);
if (chart != null)
filterExp = ((JSONObject) chart.getJSON("config")).getJSONObject("filter");
} else // via AdvFilter
if (anyId.getEntityCode() == EntityHelper.FilterConfig) {
ConfigBean filter = AdvFilterManager.instance.getAdvFilter(anyId);
if (filter != null)
filterExp = (JSONObject) filter.getJSON("filter");
} else // via OTHERS
if (refField != null) {
String[] entityAndField = refField.split("\\.");
Assert.isTrue(entityAndField.length == 2, "Bad `via` filter defined");
JSONObject item = JSONUtils.toJSONObject(new String[] { "field", "op", "value" }, new Object[] { entityAndField[1], ParseHelper.EQ, anyId });
filterExp = JSONUtils.toJSONObject("entity", entityAndField[0]);
filterExp.put("items", Collections.singletonList(item));
}
return filterExp == null ? null : new AdvFilterParser(filterExp).toSqlWhere();
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectController method getPlans.
@GetMapping("{projectId}/details")
public RespBody getPlans(@PathVariable String projectId, HttpServletRequest request) throws IOException {
final ID user = getRequestUser(request);
JSONObject details;
try {
ConfigBean p = ProjectManager.instance.getProject(ID.valueOf(projectId), user);
details = JSONUtils.toJSONObject(new String[] { "projectName", "isMember", "projectStatus" }, new Object[] { p.getString("projectName"), p.get("members", Set.class).contains(user), p.getInteger("status") });
} catch (ConfigurationException ex) {
return RespBody.error(ex.getLocalizedMessage(), 403);
}
ConfigBean[] plans = ProjectManager.instance.getPlansOfProject(ID.valueOf(projectId));
JSONArray array = new JSONArray();
for (ConfigBean cb : plans) {
array.add(cb.toJSON());
}
details.put("projectPlans", array);
return RespBody.ok(details);
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ProjectController method pageProject.
@GetMapping("{projectId}/tasks")
public ModelAndView pageProject(@PathVariable String projectId, HttpServletRequest request, HttpServletResponse response) throws IOException {
final ID projectId2 = ID.isId(projectId) ? ID.valueOf(projectId) : null;
if (projectId2 == null) {
response.sendError(404);
return null;
}
final ID user = getRequestUser(request);
ConfigBean p;
try {
p = ProjectManager.instance.getProject(projectId2, getRequestUser(request));
} catch (ConfigurationException ex) {
response.sendError(403, ex.getLocalizedMessage());
return null;
}
ModelAndView mv = createModelAndView("/project/project-tasks");
mv.getModel().put("projectId", p.getID("id"));
mv.getModel().put("iconName", p.getString("iconName"));
mv.getModel().put("projectCode", p.getString("projectCode"));
mv.getModel().put("projectName", p.getString("projectName"));
mv.getModel().put("isMember", p.get("members", Set.class).contains(user));
mv.getModel().put("scope", p.getInteger("scope"));
mv.getModel().put("status", p.getInteger("status"));
// 分组显示
JSONArray plansList = new JSONArray();
String group = getParameter(request, "group");
if (GROUP_PRIORITY.equalsIgnoreCase(group)) {
plansList.add(newCustomPlan(GROUP_PRIORITY + "-3", Language.L("非常紧急")));
plansList.add(newCustomPlan(GROUP_PRIORITY + "-2", Language.L("紧急")));
plansList.add(newCustomPlan(GROUP_PRIORITY + "-1", Language.L("普通")));
plansList.add(newCustomPlan(GROUP_PRIORITY + "-0", Language.L("较低")));
} else if (GROUP_DEADLINE.equalsIgnoreCase(group)) {
plansList.add(newCustomPlan(GROUP_DEADLINE + "-1", Language.L("已逾期")));
plansList.add(newCustomPlan(GROUP_DEADLINE + "-2", Language.L("今天")));
plansList.add(newCustomPlan(GROUP_DEADLINE + "-3", Language.L("7 天内")));
plansList.add(newCustomPlan(GROUP_DEADLINE + "-4", Language.L("以后或未安排")));
} else if (GROUP_MODIFIED.equalsIgnoreCase(group)) {
plansList.add(newCustomPlan(GROUP_MODIFIED + "-1", Language.L("今天")));
plansList.add(newCustomPlan(GROUP_MODIFIED + "-2", Language.L("7 天内")));
plansList.add(newCustomPlan(GROUP_MODIFIED + "-3", Language.L("14 天内")));
plansList.add(newCustomPlan(GROUP_MODIFIED + "-4", Language.L("更早")));
} else {
final ConfigBean[] plans = ProjectManager.instance.getPlansOfProject(projectId2);
for (ConfigBean e : plans) {
plansList.add(e.toJSON());
}
}
mv.getModel().put("projectPlans", plansList.toJSONString());
return mv;
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class PickListController method picklistGet.
@RequestMapping({ "picklist-gets", "multiselect-gets" })
public void picklistGet(HttpServletRequest request, HttpServletResponse response) {
String entity = getParameterNotNull(request, "entity");
String field = getParameterNotNull(request, "field");
boolean isAll = "true".equals(getParameter(request, "isAll"));
Field fieldMeta = MetadataHelper.getField(entity, field);
ConfigBean[] entries = PickListManager.instance.getPickListRaw(fieldMeta, isAll);
writeSuccess(response, JSONUtils.toJSONArray(entries));
}
use of com.rebuild.core.configuration.ConfigBean in project rebuild by getrebuild.
the class ViewAddonsController method gets.
@GetMapping("{entity}/view-addons")
public JSON gets(@PathVariable String entity, HttpServletRequest request) {
final ID user = getRequestUser(request);
String applyType = getParameter(request, "type", ViewAddonsManager.TYPE_TAB);
ConfigBean config = ViewAddonsManager.instance.getLayout(user, entity, applyType);
// compatible: v2.2
JSON configJson = config == null ? null : config.getJSON("config");
if (configJson instanceof JSONArray) {
configJson = JSONUtils.toJSONObject("items", configJson);
}
Entity entityMeta = MetadataHelper.getEntity(entity);
Set<Entity> mfRefs = ViewAddonsManager.hasMultiFieldsReferenceTo(entityMeta);
List<String[]> refs = new ArrayList<>();
for (Field field : entityMeta.getReferenceToFields(true)) {
Entity e = field.getOwnEntity();
if (e.getMainEntity() != null) {
continue;
}
String label = EasyMetaFactory.getLabel(e);
if (mfRefs.contains(e)) {
label = EasyMetaFactory.getLabel(field) + " (" + label + ")";
}
refs.add(new String[] { e.getName() + ViewAddonsManager.EF_SPLIT + field.getName(), label });
}
// 跟进(动态)
refs.add(new String[] { "Feeds.relatedRecord", Language.L("动态") });
// 任务(项目)
refs.add(new String[] { "ProjectTask.relatedRecord", Language.L("任务") });
// 附件
if (ViewAddonsManager.TYPE_TAB.equals(applyType)) {
refs.add(new String[] { "Attachment.relatedRecord", Language.L("附件") });
}
return JSONUtils.toJSONObject(new String[] { "config", "refs" }, new Object[] { configJson, refs });
}
Aggregations