Search in sources :

Example 1 with LuceneRecord

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);
}
Also used : ActionRunner(app.hongs.action.ActionRunner) LuceneRecord(app.hongs.dh.lucene.LuceneRecord) Map(java.util.Map) Action(app.hongs.action.anno.Action) LuceneAction(app.hongs.dh.lucene.LuceneAction)

Example 2 with LuceneRecord

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);
}
Also used : ActionRunner(app.hongs.action.ActionRunner) LuceneRecord(app.hongs.dh.lucene.LuceneRecord) Map(java.util.Map) Action(app.hongs.action.anno.Action) LuceneAction(app.hongs.dh.lucene.LuceneAction)

Example 3 with LuceneRecord

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);
}
Also used : ActionHelper(app.hongs.action.ActionHelper) LuceneRecord(app.hongs.dh.lucene.LuceneRecord) Map(java.util.Map) Cmdlet(app.hongs.cmdlet.anno.Cmdlet)

Example 4 with LuceneRecord

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();
        }
    }
}
Also used : VerifyHelper(app.hongs.action.VerifyHelper) HongsException(app.hongs.HongsException) ActionHelper(app.hongs.action.ActionHelper) LuceneRecord(app.hongs.dh.lucene.LuceneRecord) Map(java.util.Map) Cmdlet(app.hongs.cmdlet.anno.Cmdlet)

Aggregations

LuceneRecord (app.hongs.dh.lucene.LuceneRecord)4 Map (java.util.Map)4 ActionHelper (app.hongs.action.ActionHelper)2 ActionRunner (app.hongs.action.ActionRunner)2 Action (app.hongs.action.anno.Action)2 Cmdlet (app.hongs.cmdlet.anno.Cmdlet)2 LuceneAction (app.hongs.dh.lucene.LuceneAction)2 HongsException (app.hongs.HongsException)1 VerifyHelper (app.hongs.action.VerifyHelper)1