use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class UnitAction method doSave.
@Action("save")
@Verify(conf = "matrix", form = "unit")
@CommitSuccess
public void doSave(ActionHelper helper) throws HongsException {
Map data = helper.getRequestData();
String id = model.set(data);
Map info = new HashMap();
info.put("id", id);
info.put("name", data.get("name"));
CoreLocale lang = CoreLocale.getInstance().clone();
lang.load("matrix");
String ms = lang.translate("core.save.unit.success");
helper.reply(ms, info);
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class UnitAction method doDelete.
@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
Map data = helper.getRequestData();
int rows = model.delete(data);
CoreLocale lang = CoreLocale.getInstance().clone();
lang.load("matrix");
String ms = lang.translate("core.delete.unit.success", Integer.toString(rows));
helper.reply(ms, rows);
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class CmdletRunner method main.
public static void main(String[] args) throws IOException, HongsException {
args = init(args);
Core core = Core.getInstance();
String act = Core.ACTION_NAME.get();
if (null == act || act.length() == 0) {
System.err.println("ERROR: Cmdlet name can not be empty.");
System.exit(2);
return;
}
// 获取方法
Method method = getCmdlets().get(act);
if (null == method) {
System.err.println("ERROR: Cmdlet " + act + " is not exists.");
System.exit(2);
return;
}
// 执行方法
try {
if (0 < Core.DEBUG && 8 != (8 & Core.DEBUG)) {
CmdletHelper.println("Starting...");
}
method.invoke(null, new Object[] { args });
if (0 < Core.DEBUG && 8 != (8 & Core.DEBUG)) {
CmdletHelper.println("Finished!!!");
}
} catch (IllegalAccessException ex) {
CoreLogger.error("Illegal access for method '" + method.getClass().getName() + "." + method.getName() + "(String[]).");
System.exit(3);
} catch (IllegalArgumentException ex) {
CoreLogger.error("Illegal params for method '" + method.getClass().getName() + "." + method.getName() + "(String[]).");
System.exit(3);
} catch (InvocationTargetException ex) {
Throwable ta = ex.getCause();
if (0 < Core.DEBUG) {
CoreLogger.error(ta);
return;
}
/**
* 构建错误消息
*/
String error = ta.getLocalizedMessage();
if (!(ta instanceof HongsException) && !(ta instanceof HongsExpedient) && !(ta instanceof HongsError)) {
CoreLocale lang = Core.getInstance(CoreLocale.class);
if (error == null || error.length() == 0) {
error = lang.translate("core.error.unkwn", ta.getClass().getName());
} else {
error = lang.translate("core.error.label", ta.getClass().getName()) + ": " + error;
}
}
CoreLogger.error(error);
System.exit(4);
} finally {
try {
core.close();
} catch (Throwable er) {
CoreLogger.error(er);
System.exit(5);
}
/**
* 输出总的运行时间
* 并清除参数及核心
*/
if (0 < Core.DEBUG && 8 != (8 & Core.DEBUG)) {
CmdletHelper.println("Total exec time: " + (Tool.humanTime(System.currentTimeMillis() - Core.STARTS_TIME)));
}
}
}
use of app.hongs.CoreLocale 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());
CoreLocale locale = CoreLocale.getInstance().clone();
String mod = runner.getModule();
String ent = runner.getEntity();
String cnt = Integer.toString(num);
String key = "fore." + opr + "." + ent + ".success";
locale.fill(mod);
if (!locale.containsKey(key)) {
key = "fore." + opr + ".success";
Mview view = new Mview(ett);
String tit = view.getTitle();
return locale.translate(key, tit, cnt);
} else {
return locale.translate(key, /**/
cnt);
}
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class Table method getDtfmt.
/**
* 获取日期(时间)格式
* <p>
* 也可在 values 中通过 __type_format__,__name__format__ 来告知格式;
* 其中的 type 为 date,time,datetime; name 为 values 中的键
* </p>
* @param type
* @param name
* @param values
* @return
*/
protected String getDtfmt(String name, String type, Map values) {
String key;
key = name + "_format__";
if (values.containsKey(key)) {
if (values.get(key) instanceof String) {
return (String) values.get(key);
}
}
key = type + "_format__";
if (values.containsKey(key)) {
if (values.get(key) instanceof String) {
return (String) values.get(key);
}
}
String fmt;
if ("time".equals(type)) {
fmt = "HH:mm:ss";
} else if ("date".equals(type)) {
fmt = "yyyy/MM/dd";
} else {
fmt = "yyyy/MM/dd HH:mm:ss";
}
CoreLocale conf = Core.getInstance(CoreLocale.class);
return conf.getProperty("core.default." + type + ".format", fmt);
}
Aggregations