use of io.github.ihongs.action.ActionRunner in project HongsCORE by ihongs.
the class TitlesHelper method addForks.
/**
* 通过调用关联动作来补全名称
* @param ls
* @param fc
* @param fn
* @throws HongsException
*/
protected void addForks(List<Object[]> ls, Map fc, String fn) throws HongsException {
String at = (String) fc.get("data-at");
String vk = (String) fc.get("data-vk");
String tk = (String) fc.get("data-tk");
if (at == null || at.isEmpty()) {
String c = (String) fc.get("conf");
String f = (String) fc.get("form");
at = c + "/" + f + "/search";
}
if (vk == null || vk.isEmpty()) {
vk = Cnst.ID_KEY;
}
if (tk == null || tk.isEmpty()) {
tk = "name";
}
Object[] vk2 = Dict.splitKeys(vk);
Object[] tk2 = Dict.splitKeys(tk);
// 映射关系
Map<Object, Object[]> lm = new HashMap();
for (Object[] lx : ls) {
lm.put(lx[0], lx);
}
Set li = lm.keySet();
// 查询结构
Map cd = new HashMap();
Map rd = new HashMap();
Set rb = new HashSet();
rd.put(Cnst.RB_KEY, rb);
rd.put(Cnst.RN_KEY, 1024);
rb.add(vk);
rb.add(tk);
// 获取结果
ActionHelper ah = ActionHelper.newInstance();
ah.setContextData(cd);
ah.setRequestData(rd);
ActionRunner ar = ActionRunner.newInstance(ah, at);
/**
* Lucene 单个条件的数量无法超过 1024
* 故需拆成片段
* 分批进行查询
*/
List l = new ArrayList(li);
int k = l.size();
int j = 0, i = 0;
while (j < k) {
j = i + 1024;
if (j > k) {
j = k;
}
rd.put(Cnst.ID_KEY, l.subList(i, j));
/**/
i = j;
ar.doInvoke();
// 整合数据
Map sd = ah.getResponseData();
List<Map> lz = (List) sd.get("list");
if (lz != null)
for (Map ro : lz) {
String lv = Dict.getValue(ro, "", vk2);
String lt = Dict.getValue(ro, "", tk2);
Object[] lx = lm.get(lv);
if (null != lx) {
lx[1] = lt;
}
}
}
}
use of io.github.ihongs.action.ActionRunner in project HongsCORE by ihongs.
the class DBAction method getRspMsg.
/**
* 获取返回消息
* @param helper
* @param ett
* @param opr
* @param num
* @return
* @throws HongsException
*/
protected String getRspMsg(ActionHelper helper, Model ett, String opr, int num) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String mod = runner.getModule();
String ent = runner.getEntity();
String cnt = Integer.toString(num);
CoreLocale locale = CoreLocale.getInstance().clone();
locale.fill(mod);
String key = "fore." + opr + "." + ent + ".success";
if (!locale.containsKey(key)) {
key = "fore." + opr + /**/
".success";
}
return locale.translate(key, null, cnt);
}
Aggregations