use of app.hongs.dh.lucene.LuceneRecord in project HongsCORE by ihongs.
the class SearchAction method counts.
@Action("counts/search")
public void counts(ActionHelper helper) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
LuceneRecord sr = (LuceneRecord) getEntity(helper);
SearchHelper sh = new SearchHelper(sr);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "counts", rd);
Map sd = sh.counts(rd);
sd = getRspMap(helper, sr, "counts", sd);
// sr.close ( ); // 应用容器可自行关闭
// 增加标题
titled(rd, sd, mod, ent);
helper.reply(sd);
}
use of app.hongs.dh.lucene.LuceneRecord in project HongsCORE by ihongs.
the class SearchAction method statis.
@Action("statis/search")
public void statis(ActionHelper helper) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
LuceneRecord sr = (LuceneRecord) getEntity(helper);
SearchHelper sh = new SearchHelper(sr);
Map rd = helper.getRequestData();
rd = getReqMap(helper, sr, "statis", rd);
Map sd = sh.statis(rd);
sd = getRspMap(helper, sr, "statis", sd);
// sr.close ( ); // 应用容器可自行关闭
// 增加标题
titled(rd, sd, mod, ent);
helper.reply(sd);
}
use of app.hongs.dh.lucene.LuceneRecord in project HongsCORE by ihongs.
the class SearchCmdlet method search.
@Cmdlet("search")
public void search(String[] args) throws HongsException {
Map opts = CmdletHelper.getOpts(args, new String[] { "conf=s", "name=s", "id*s", "wd*s", "rb*s", "ob*s", "pn:i", "gn:i", "rn:i" });
String conf = Synt.asString(opts.remove("conf"));
String name = Synt.asString(opts.remove("name"));
ActionHelper ah = Core.getInstance(ActionHelper.class);
LuceneRecord so = LuceneRecord.getInstance(conf, name);
Map req = ah.getRequestData();
req.putAll(opts);
Map rsp = so.search(req);
CmdletHelper.preview(rsp);
}
use of app.hongs.dh.lucene.LuceneRecord in project HongsCORE by ihongs.
the class SearchCmdlet method update.
@Cmdlet("update")
public void update(String[] args) throws HongsException {
Map opts = CmdletHelper.getOpts(args, new String[] { "conf=s", "name=s", "id*s" });
String conf = Synt.asString(opts.remove("conf"));
String name = Synt.asString(opts.remove("name"));
List<String> ds = Synt.asList(opts.remove("id"));
ActionHelper ah = Core.getInstance(ActionHelper.class);
LuceneRecord so = LuceneRecord.getInstance(conf, name);
Map rd = ah.getRequestData();
if (!rd.isEmpty()) {
// 有数据则校验数据
VerifyHelper vh = new VerifyHelper();
vh.addRulesByForm(conf, name);
rd = vh.verify(rd);
try {
so.begin();
for (String id : ds) {
so.set(id, rd);
}
so.commit();
} catch (HongsException ex) {
so.revert();
throw ex;
} finally {
so.close();
}
} else {
// 不给内容即为删除
try {
so.begin();
for (String id : ds) {
so.del(id);
}
so.commit();
} catch (HongsException ex) {
so.revert();
throw ex;
} finally {
so.close();
}
}
}
Aggregations