use of app.hongs.serv.matrix.Data in project HongsCORE by ihongs.
the class DataAction method acting.
@Override
public void acting(ActionHelper helper, ActionRunner runner) throws HongsException {
super.acting(helper, runner);
String ent = runner.getEntity();
String mod = runner.getModule();
Method met = runner.getMethod();
// 绑定特制的表单
if (met.isAnnotationPresent(Select.class) || met.isAnnotationPresent(Spread.class) || met.isAnnotationPresent(Verify.class)) {
Data dat = (Data) getEntity(helper);
Map fcs = dat.getFields();
helper.setAttribute("form:" + mod + "." + ent, fcs);
}
// 放入当前用户ID
Object uid = helper.getSessibute(Cnst.UID_SES);
helper.getRequestData().put("user_id", uid);
helper.getRequestData().put("form_id", ent);
}
use of app.hongs.serv.matrix.Data in project HongsCORE by ihongs.
the class DataAction method export.
@Action("stream")
@Preset(conf = "", form = "")
@CustomReplies
public void export(ActionHelper helper) throws HongsException, IOException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
Data sr = (Data) getEntity(helper);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "export", rd);
int rn = Synt.declare(rd.get("rn"), 0);
int pn = Synt.declare(rd.get("pn"), 0);
Loop lp = sr.search(rd, pn, rn);
/**
* 逐行输出
*/
HttpServletResponse rs = helper.getResponse();
String csv = ent + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
rs.setHeader("Content-Disposition", "attachment;filename=" + csv + ".csv");
rs.setHeader("Content-Type", "application/octet-stream;charset=UTF-8");
rs.setHeader("Transfer-Encoding", "chunked");
Writer ot = rs.getWriter();
Map fs = sr.getFields();
Map es = new HashMap();
if (lp.hasNext()) {
Map<String, Object> ds = lp.next();
StringBuilder sf = new StringBuilder();
StringBuilder sb = new StringBuilder();
Map ts = FormSet.getInstance("default").getEnum("__types__");
for (Map.Entry<String, Object> et : ds.entrySet()) {
Object fv = et.getValue();
String fn = et.getKey();
Map mt = (Map) fs.get(fn);
Map ex = null;
String fx, ft;
fx = (String) mt.get("__text__");
ft = (String) mt.get("__type__");
ft = (String) ts.get(ft);
if ("enum".equals(ft)) {
String xonf = (String) mt.get("conf");
String xame = (String) mt.get("enum");
if (null == xonf || "".equals(xonf))
xonf = mod;
if (null == xame || "".equals(xame))
xame = fn;
ex = FormSet.getInstance(xonf).getEnum(xame);
es.put(fn, ex);
}
sf.append(",\"").append(escape(fx, null)).append("\"");
sb.append(",\"").append(escape(fv, ex)).append("\"");
}
ot.write(sf.append("\r\n").substring(1));
ot.write(sb.append("\r\n").substring(1));
ot.flush();
}
while (lp.hasNext()) {
Map<String, Object> ds = lp.next();
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> et : ds.entrySet()) {
Object fv = et.getValue();
String fn = et.getKey();
Map ex = (Map) es.get(fn);
sb.append(",\"").append(escape(fv, ex)).append("\"");
}
ot.write(sb.append("\r\n").substring(1));
}
}
use of app.hongs.serv.matrix.Data in project HongsCORE by ihongs.
the class DataAction method redo.
@Action("revert/update")
@CommitSuccess
public void redo(ActionHelper helper) throws HongsException {
String id = helper.getParameter(Cnst.ID_KEY);
if (null == id || "".equals(id)) {
throw new HongsException(0x1100, "id required");
}
Data sr = (Data) getEntity(helper);
Map rd = helper.getRequestData();
sr.redo(id, rd);
helper.reply("");
}
use of app.hongs.serv.matrix.Data in project HongsCORE by ihongs.
the class DataAction method list.
@Action("revert/search")
public void list(ActionHelper helper) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
Data sr = (Data) getEntity(helper);
Model mo = sr.getModel();
Map rd = helper.getRequestData();
rd.remove("user_id");
rd.put("form_id", sr.getFormId());
Map sd = mo.search(rd);
// 详情数据转换
if (sd.containsKey("info")) {
Map df = (Map) sd.remove("info");
Map dt = (Map) app.hongs.util.Data.toObject((String) df.remove("data"));
sd.put("logs", df);
sd.put("info", dt);
// 补充枚举和关联
Set ab = Synt.toTerms(rd.get(Cnst.AB_KEY));
if (ab != null) {
byte md = 0;
if (ab.contains("_enum")) {
md += 2;
}
if (ab.contains("_time")) {
md += 4;
}
if (ab.contains("_link")) {
md += 8;
}
if (md != 0) {
new SelectHelper().addItemsByForm(mod, ent).select(sd, md);
}
if (ab.contains("_fork")) {
new SpreadHelper().addItemsByForm(mod, ent).spread(sd);
}
}
}
helper.reply(sd);
}
use of app.hongs.serv.matrix.Data in project HongsCORE by ihongs.
the class DataAction method acting.
@Override
public void acting(ActionHelper helper, ActionRunner runner) throws HongsException {
super.acting(helper, runner);
String ent = runner.getEntity();
String mod = runner.getModule();
Method met = runner.getMethod();
// 绑定特制的表单
if (met.isAnnotationPresent(Select.class) || met.isAnnotationPresent(Spread.class) || met.isAnnotationPresent(Verify.class)) {
Data dat = (Data) getEntity(helper);
Map fcs = dat.getFields();
helper.setAttribute("form:" + mod + "." + ent, fcs);
}
// 放入当前用户ID
Object uid = helper.getSessibute(Cnst.UID_SES);
helper.getRequestData().put("user_id", uid);
helper.getRequestData().put("form_id", ent);
}
Aggregations