@SuppressWarnings("unchecked")
@Override
public Object exec(List args) throws TemplateModelException {
if (args == null || args.size() < 1 || args.size() > 2 ) {
throw new TemplateModelException("Invalid number of arguments (expected: 1-2)");
}
ObjectWrapper objectWrapper = CommonFtlUtil.getCurrentEnvironment().getObjectWrapper();
TemplateHashModelEx argsMap = (TemplateHashModelEx) args.get(0);
// caller-supplied excludes
TemplateModel excludesModel = (args.size() >=2) ? (TemplateModel) args.get(1) : null;
Set<String> excludes;
if (excludesModel != null) {
excludes = LangFtlUtil.getAsStringSet(excludesModel);
} else {
excludes = new HashSet<>();
}
SimpleHash res = null;
final Boolean useExclude = Boolean.FALSE;
// put attribs from explicit attribs map first, if any
TemplateModel attribsModel = argsMap.get("attribs");
if (attribsModel != null && OfbizFtlObjectType.isObjectType(OfbizFtlObjectType.MAP, attribsModel)) {
if (OfbizFtlObjectType.isObjectType(OfbizFtlObjectType.COMPLEXMAP, attribsModel)) {
attribsModel = LangFtlUtil.toSimpleMap(attribsModel, false, objectWrapper);
}
res = LangFtlUtil.copyMapToSimple((TemplateHashModel) attribsModel, excludes, useExclude, objectWrapper);
}
// to get inline attribs, add list of all arg names to excludes as well as the lists themselves
TemplateModel allArgNamesModel = argsMap.get("allArgNames");
if (allArgNamesModel != null) {
excludes.addAll(LangFtlUtil.getAsStringSet(allArgNamesModel));
}
excludes.add("allArgNames");
excludes.add("localArgNames");
// add the inline attribs over the attribs map (if any)
if (res == null) {
res = LangFtlUtil.copyMapToSimple(argsMap, excludes, useExclude, objectWrapper);
} else {
LangFtlUtil.putAll(res, argsMap, excludes, useExclude, objectWrapper);
}
return res;
}
MakeAttribMapFromArgMapMethod.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:scipio-erp
作者:
评论列表
文章目录