Here are the examples of the java api org.apache.velocity.VelocityContext taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
642 Examples
19
Source : WeixinTagController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 跳转到编辑页面
* @return
*/
@RequestMapping(value = "toEdit", method = RequestMethod.GET)
public void toEdit(@RequestParam(required = true, value = "id") String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
VelocityContext velocityContext = new VelocityContext();
WeixinTag weixinTag = weixinTagService.queryById(id);
velocityContext.put("weixinTag", weixinTag);
String viewName = "weixin/back/weixinTag-edit.vm";
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : WeixinTagController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 详情
* @return
*/
@RequestMapping(value = "toDetail", method = RequestMethod.GET)
public void weixinTagDetail(@RequestParam(required = true, value = "id") String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
VelocityContext velocityContext = new VelocityContext();
String viewName = "weixin/back/weixinTag-detail.vm";
WeixinTag weixinTag = weixinTagService.queryById(id);
velocityContext.put("weixinTag", weixinTag);
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : WeixinNewstemplateController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 详情
* @return
*/
@RequestMapping(value = "toDetail", method = RequestMethod.GET)
public void weixinNewstemplateDetail(@RequestParam(required = true, value = "id") String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
VelocityContext velocityContext = new VelocityContext();
String viewName = "weixin/back/weixinNewstemplate-detail.vm";
WeixinNewstemplate weixinNewstemplate = weixinNewstemplateService.queryById(id);
velocityContext.put("weixinNewstemplate", weixinNewstemplate);
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : WeixinNewstemplateController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 跳转到编辑页面
* @return
*/
@RequestMapping(value = "toEdit", method = RequestMethod.GET)
public void toEdit(@RequestParam(required = true, value = "id") String id, HttpServletResponse response, HttpServletRequest request) throws Exception {
VelocityContext velocityContext = new VelocityContext();
WeixinNewstemplate weixinNewstemplate = weixinNewstemplateService.queryById(id);
velocityContext.put("weixinNewstemplate", weixinNewstemplate);
String viewName = "weixin/back/weixinNewstemplate-edit.vm";
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : MyJwWebJwid3Controller.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 去扫码授权页面
* @param request
* @return
*/
@RequestMapping(value = "toSweepCodeAuthorization", method = { RequestMethod.GET, RequestMethod.POST })
public void toSweepCodeAuthorization(HttpServletRequest request, HttpServletResponse response) throws Exception {
VelocityContext velocityContext = new VelocityContext();
String viewName = "open/back/myJwWebJwid3-sweepCodeAuthorization.vm";
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : MyJwWebJwidController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 去扫码授权页面(扫描授权公众号)
* @param request
* @return
*/
@RequestMapping(value = "toSweepCodeAuthorization", method = { RequestMethod.GET, RequestMethod.POST })
public void toSweepCodeAuthorization(HttpServletRequest request, HttpServletResponse response) throws Exception {
VelocityContext velocityContext = new VelocityContext();
String viewName = "open/back/myJwWebJwid-sweepCodeAuthorization.vm";
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : MyJwWebJwidController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
// update-begin-zhangweijian-----Date:20180808---for:变更公众号原始ID
/**
* @功能:进入变更公众号原始ID页面
* @author zhangweijian
* @param response
* @param request
* @throws Exception
*/
@RequestMapping(value = "toSwitchDefaultOfficialAcco", method = RequestMethod.GET)
public void toSwitchDefaultOfficialAcco(@RequestParam String jwid, HttpServletResponse response, HttpServletRequest request) throws Exception {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("jwid", jwid);
String viewName = "commonweixin/back/switchDefaultOfficialAcco.vm";
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : SystemController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 后台接入没有权限
*
* @throws Exception
*/
@RequestMapping(value = "/noAuth", method = { RequestMethod.GET, RequestMethod.POST })
public void noAuth(HttpServletRequest request, HttpServletResponse response) throws Exception {
String viewName = "base/back/common/error.vm";
VelocityContext velocityContext = new VelocityContext();
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : JwSystemProjectController.java
with Apache License 2.0
from zhangdaiscott
with Apache License 2.0
from zhangdaiscott
/**
* 详情
* @return
*/
@RequestMapping(value = "toDetail", method = RequestMethod.GET)
public void jwSystemProjectDetail(@RequestParam(required = true, value = "id") String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
VelocityContext velocityContext = new VelocityContext();
String viewName = "system/back/jwSystemProject-detail.vm";
JwSystemProject jwSystemProject = jwSystemProjectService.queryById(id);
velocityContext.put("jwSystemProject", jwSystemProject);
ViewVelocity.view(request, response, viewName, velocityContext);
}
19
Source : TmpBuilder.java
with GNU General Public License v3.0
from wlhbdp
with GNU General Public License v3.0
from wlhbdp
protected String buildVm(String fromPath, VelocityContext ctx) throws IOException {
Template t = ve.getTemplate(fromPath);
StringWriter sw = new StringWriter();
t.merge(ctx, sw);
return sw.toString();
}
19
Source : TmpBuilder.java
with GNU General Public License v3.0
from wlhbdp
with GNU General Public License v3.0
from wlhbdp
protected VelocityContext getContext() {
VelocityContext ctx = new VelocityContext();
ctx.put("name", ip.name);
return ctx;
}
19
Source : LatexTemplate.java
with MIT License
from vsfexperts
with MIT License
from vsfexperts
private final VelocityContext prepareContext(final LatexContext context) {
final VelocityContext velocityContext = new VelocityContext(context.asMap());
customize(velocityContext);
return velocityContext;
}
19
Source : CodeGenerator.java
with BSD 3-Clause "New" or "Revised" License
from ueboot
with BSD 3-Clause "New" or "Revised" License
from ueboot
// 生成VUE页面
public void createPages(Clreplaced<?> clz, String vuePageModuleName, String vueFilePath, String requestPath) {
log("pagePath:" + vueFilePath);
VelocityContext context = getBaseContext(clz);
String enreplacedyClreplacedName = (String) context.get("enreplacedyName");
try {
List<ObjectField> fields = getObjectValue(clz);
context.put("fields", fields);
} catch (Exception e) {
e.printStackTrace();
}
context.put("requestPath", requestPath);
String js = getTemplateString("VUE.vm", context);
log("vue 页面文件内容:" + js);
String jsFilePath = projectPah + vuePageModuleName + separator + vueFilePath + separator + enreplacedyClreplacedName + ".vue";
log("vueFilePath文件保存路径:" + jsFilePath);
saveFile(jsFilePath, js);
}
19
Source : CodeGenerator.java
with BSD 3-Clause "New" or "Revised" License
from ueboot
with BSD 3-Clause "New" or "Revised" License
from ueboot
private void createVO(Clreplaced<?> clz, String controllerModuleName, String controllerPackageName) {
String voPackageName = controllerPackageName + ".vo";
String filepath = voPackageName.replace(".", "/");
VelocityContext context = getBaseContext(clz);
context.put("controllerPackageName", controllerPackageName);
try {
List<ObjectField> fields = getObjectValue(clz);
context.put("fields", fields);
} catch (Exception e) {
e.printStackTrace();
}
Map<String, String> transCodes = new HashMap<String, String>();
transCodes.put("FindReq", "");
transCodes.put("Resp", "");
transCodes.put("Req", "");
for (Map.Entry<String, String> entry : transCodes.entrySet()) {
String key = entry.getKey();
String java = getTemplateString(key + ".vm", context);
log(key + "文件内容:" + java);
String reqFilePath = projectPah + controllerModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filepath + separator + context.get("enreplacedyName") + key + ".java";
log(key + "文件保存路径:" + reqFilePath);
saveFile(reqFilePath, java);
}
}
19
Source : CodeGenerator.java
with BSD 3-Clause "New" or "Revised" License
from ueboot
with BSD 3-Clause "New" or "Revised" License
from ueboot
/**
* 生成service及serviceImpl类
*
* @param clz 实体类
* @param servicePackageName service类包名路径
* @param serviceModuleName service类模块名称
* @param repositoryPackageName repository类包名路径
*/
public void createService(Clreplaced<?> clz, String servicePackageName, String serviceModuleName, String repositoryPackageName) {
log("service类生成包名:" + servicePackageName);
VelocityContext context = getBaseContext(clz);
String enreplacedyClreplacedName = (String) context.get("enreplacedyName");
context.put("servicePackageName", servicePackageName);
String java = getTemplateString("Service.vm", context);
log("service文件内容:" + java);
context.put("repositoryPackageName", repositoryPackageName);
String java2 = getTemplateString("ServiceImpl.vm", context);
log("serviceImpl文件内容:" + java2);
String filePath = servicePackageName.replace(".", separator);
String interfaceFilePath = projectPah + serviceModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filePath + separator + enreplacedyClreplacedName + "Service.java";
String implFilePath = projectPah + serviceModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filePath + separator + "impl" + separator + enreplacedyClreplacedName + "ServiceImpl.java";
log("service文件保存路径:" + interfaceFilePath);
log("serviceImpl文件保存路径:" + implFilePath);
saveFile(interfaceFilePath, java);
saveFile(implFilePath, java2);
}
19
Source : CodeGenerator.java
with BSD 3-Clause "New" or "Revised" License
from ueboot
with BSD 3-Clause "New" or "Revised" License
from ueboot
/**
* 生成repository及repositoryImpl类
*
* @param clz 实体类
* @param repositoryPackageName repository包名路径
* @param repositoryModuleName repository模块名称
*/
public void createRepository(Clreplaced<?> clz, String repositoryPackageName, String repositoryModuleName) {
log("repository类生成包名:" + repositoryPackageName);
VelocityContext context = getBaseContext(clz);
String enreplacedyClreplacedName = (String) context.get("enreplacedyName");
context.put("repositoryPackageName", repositoryPackageName);
String baseJava = getTemplateString("BaseRepository.vm", context);
String java = getTemplateString("Repository.vm", context);
String java2 = getTemplateString("RepositoryImpl.vm", context);
log("repository文件内容:" + java);
String filePath = repositoryPackageName.replace(".", separator);
String interfaceFilePath = projectPah + repositoryModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filePath + separator + enreplacedyClreplacedName + "Repository.java";
String baseFilePath = projectPah + repositoryModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filePath + separator + enreplacedyClreplacedName + "BaseRepository.java";
String implFilePath = projectPah + repositoryModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filePath + separator + "impl" + separator + enreplacedyClreplacedName + "RepositoryImpl.java";
log("baseRepository文件保存路径:" + baseFilePath);
log("repository文件保存路径:" + interfaceFilePath);
log("repositoryImpl文件保存路径:" + implFilePath);
saveFile(baseFilePath, baseJava);
saveFile(interfaceFilePath, java);
saveFile(implFilePath, java2);
}
19
Source : CodeGenerator.java
with BSD 3-Clause "New" or "Revised" License
from ueboot
with BSD 3-Clause "New" or "Revised" License
from ueboot
/**
* 生成controller类
*
* @param clz 实体类
* @param controllerPackageName controller类包名路径
* @param servicePackageName service类包名路径
* @param controllerModuleName controller模块名称
* @param requestPath 请求上下文,加了这个则会多加一个路径,默认为类名,如:/role
*/
public void createController(Clreplaced<?> clz, String controllerPackageName, String servicePackageName, String controllerModuleName, String requestPath) {
createVO(clz, controllerModuleName, controllerPackageName);
log("controller类生成包名:" + controllerPackageName);
VelocityContext context = getBaseContext(clz);
String enreplacedyClreplacedName = (String) context.get("enreplacedyName");
context.put("controllerPackageName", controllerPackageName);
context.put("servicePackageName", servicePackageName);
if (requestPath == null || "".equals(requestPath)) {
requestPath = "/";
}
if (!requestPath.startsWith("/")) {
requestPath = "/" + requestPath;
}
if (!requestPath.endsWith("/")) {
requestPath += "/";
}
context.put("requestPath", requestPath);
String java = getTemplateString("Controller.vm", context);
log("controller文件内容:" + java);
String filepath = controllerPackageName.replace(".", separator);
String controllerfilepath = projectPah + controllerModuleName + separator + "src" + separator + "main" + separator + "java" + separator + filepath + separator + enreplacedyClreplacedName + "Controller.java";
log("controller文件保存路径:" + controllerfilepath);
saveFile(controllerfilepath, java);
}
19
Source : OdfHelper.java
with Apache License 2.0
from tdf
with Apache License 2.0
from tdf
private static VelocityContext getOdfContext(String contextStr, String param) {
VelocityContext context = new VelocityContext();
context.put("signaturemodel", mOdf12SignatureSchemaModel);
context.put("manifestmodel", mOdf12ManifestSchemaModel);
context.put("model", mOdf12SchemaModel);
context.put("oldmodel", mOdf11SchemaModel);
context.put("odfmodel", mOdfModel);
context.put("javamodel", mJavaModelOdf);
context.put("context", contextStr);
context.put("param", param);
return context;
}
19
Source : ODPSTaskCreator.java
with GNU Affero General Public License v3.0
from qlangtech
with GNU Affero General Public License v3.0
from qlangtech
/**
* 解析模板
*/
private void parseTemplate() {
File dir = new File(tplDir);
if (!dir.isDirectory()) {
throw new IllegalArgumentException("dir:" + dir.getAbsolutePath() + " is not directory");
}
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("odps", context);
File tpl = null;
for (String f : dir.list()) {
tpl = new File(dir, f);
mergeSystemParameter(velocityContext, new File(this.outputDir, context.getDate() + "_" + StringUtils.substringBeforeLast(f, ".tpl")), tpl);
}
}
19
Source : EmailServiceActor.java
with MIT License
from project-sunbird
with MIT License
from project-sunbird
private void sendMail(Map<String, Object> request, List<String> emails, String template, RequestContext requestContext) {
try {
SendEmail sendEmail = new SendEmail();
Velocity.init();
VelocityContext context = ProjectUtil.getContext(request);
StringWriter writer = new StringWriter();
Velocity.evaluate(context, writer, "SimpleVelocity", template);
long interval = 60000L;
if (StringUtils.isNotBlank(resetInterval)) {
interval = Long.parseLong(resetInterval);
}
if (null == connection.getTransport() || ((System.currentTimeMillis()) - timer >= interval) || (!connection.getTransport().isConnected())) {
resetConnection();
}
sendEmail.send(emails.toArray(new String[emails.size()]), (String) request.get(JsonKey.SUBJECT), context, writer, connection.getSession(), connection.getTransport());
} catch (Exception e) {
logger.error(requestContext, "EmailServiceActor:sendMail: Exception occurred with message = " + e.getMessage(), e);
}
}
19
Source : ShowAllTypesPage.java
with Apache License 2.0
from Netflix
with Apache License 2.0
from Netflix
@Override
protected void renderPage(HttpServletRequest req, VelocityContext ctx, Writer writer) {
ui.getVelocityEngine().getTemplate("show-all-types.vm").merge(ctx, writer);
}
19
Source : QueryPage.java
with Apache License 2.0
from Netflix
with Apache License 2.0
from Netflix
@Override
protected void renderPage(HttpServletRequest req, VelocityContext ctx, Writer writer) {
ui.getVelocityEngine().getTemplate("query.vm").merge(ctx, writer);
}
19
Source : BrowseSchemaPage.java
with Apache License 2.0
from Netflix
with Apache License 2.0
from Netflix
@Override
protected void renderPage(HttpServletRequest req, VelocityContext ctx, Writer writer) {
ui.getVelocityEngine().getTemplate("browse-schema.vm").merge(ctx, writer);
}
19
Source : SimUtils.java
with Apache License 2.0
from lujian213
with Apache License 2.0
from lujian213
public static String mergeResult(VelocityContext context, String tagName, String templateStr) throws IOException {
try (StringWriter writer = new StringWriter()) {
ve.evaluate(context, writer, tagName, templateStr);
return writer.toString();
}
}
19
Source : BeanRepository.java
with Apache License 2.0
from lujian213
with Apache License 2.0
from lujian213
public Object invoke(String clreplacedName, String methodName, VelocityContext vc) {
FunctionBean bean = addBean(clreplacedName, vc);
Method targetMethod = findMethod(bean.getBean(), methodName);
if (targetMethod != null) {
return invoke(bean.getBean(), targetMethod, vc);
} else {
throw new RuntimeException("no such method [" + methodName + "] for bean [" + clreplacedName + "]");
}
}
19
Source : BeanRepository.java
with Apache License 2.0
from lujian213
with Apache License 2.0
from lujian213
public FunctionBean addBean(String clreplacedName, VelocityContext vc) {
try {
ClreplacedLoader cl = Thread.currentThread().getContextClreplacedLoader();
SimLogger.getLogger().info("Use " + cl + " to load clreplaced [" + clreplacedName + "]");
return addBean(Clreplaced.forName(clreplacedName, true, cl), vc);
} catch (ClreplacedNotFoundException e) {
throw new RuntimeException("error to create instance of clreplaced [" + clreplacedName + "]", e);
}
}
19
Source : BeanRepository.java
with Apache License 2.0
from lujian213
with Apache License 2.0
from lujian213
protected Object invoke(Object obj, Method m, VelocityContext vc) {
Object[] paramValues = prepareMethodParameters(m.getParameters(), vc);
try {
return m.invoke(obj, paramValues);
} catch (IllegalAccessException | IllegalArgumentException e) {
throw new RuntimeException("invoke error", e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
}
throw new RuntimeException(e.getCause().getMessage(), e.getCause());
}
}
19
Source : BeanRepository.java
with Apache License 2.0
from lujian213
with Apache License 2.0
from lujian213
protected Object[] prepareMethodParameters(Parameter[] parameters, VelocityContext vc) {
Object[] paramValues = new Object[parameters.length];
for (int i = 1; i <= parameters.length; i++) {
String paramName = getParameterName(parameters[i - 1]);
paramValues[i - 1] = smartValuePickup(parameters[i - 1].getType(), paramName, vc.get(paramName));
}
return paramValues;
}
19
Source : GenUtils.java
with MIT License
from kongshanxuelin
with MIT License
from kongshanxuelin
/**
* 项目生成中的变量
*
* @return 模板列表
*/
public static VelocityContext getVelocityContext(String projectName, String basePackage, String version) {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("basePackage", Convert.toStr(basePackage, "com.ruoyi"));
velocityContext.put("version", version);
velocityContext.put("projectName", projectName);
return velocityContext;
}
19
Source : JpaMappingCodeGenerator.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
/**
* This method create a single java clreplaced file
*
* @param templateFile
* @param businessTable
* @param views
*/
private void createViewsFile(List<IJpaView> jpaViews) {
VelocityContext context;
logger.trace("IN");
try {
context = new VelocityContext();
// $NON-NLS-1$
context.put("jpaViews", jpaViews);
File outputFile = new File(srcDir, "views.json");
createFile(viewTemplate, outputFile, context);
} catch (Throwable t) {
logger.error("Impossible to create mapping", t);
} finally {
logger.trace("OUT");
}
}
19
Source : ChartEngineUtil.java
with GNU Affero General Public License v3.0
from KnowageLabs
with GNU Affero General Public License v3.0
from KnowageLabs
public static String applyTemplate(Template velocityTemplate, VelocityContext velocityContext) {
StringWriter jsonChartTemplate = new StringWriter();
velocityTemplate.merge(velocityContext, jsonChartTemplate);
return jsonChartTemplate.toString();
}
19
Source : GenerateCodeGenerator.java
with MIT License
from graphql-java-generator
with MIT License
from graphql-java-generator
/**
* Returns a {@link VelocityContext} with all default values filled.
*
* @return
*/
VelocityContext getVelocityContext() {
VelocityContext context = new VelocityContext();
context.put("sharp", "#");
context.put("dollar", "$");
context.put("configuration", configuration);
// Velocity can't access to enum values. So we add it into the context
context.put("isPluginModeClient", configuration.getMode() == PluginMode.client);
context.put("packageUtilName", generateCodeDoreplacedentParser.getUtilPackageName());
context.put("customScalars", generateCodeDoreplacedentParser.getCustomScalars());
context.put("directives", generateCodeDoreplacedentParser.getDirectives());
return context;
}
19
Source : J2clAstProcessor.java
with Apache License 2.0
from google
with Apache License 2.0
from google
private VelocityContext createVelocityContextForVisitor(String packageName, List<VisitableClreplaced> visitableClreplacedes) {
VelocityContext vc = new VelocityContext();
vc.put("clreplacedes", visitableClreplacedes);
vc.put("packageName", packageName);
return vc;
}
19
Source : DashboardBuilder.java
with MIT License
from dwslab
with MIT License
from dwslab
/**
* Writes the HTML content to htmlFile and the data (csv) to another file.
* The data file is compressed by gzip and base64 encoded.
* This is for publishing the dashboard to a server.
* @param htmlFile the file where all html code should be written to
* @param csvFile the file where all data should be written to (compressed by gzip and base64 encoded)
*/
public void writeToCompressedFile(File htmlFile, File csvFile) {
newRow();
try (Writer writer = new BufferedWriter(new FileWriter(csvFile))) {
String csv = this.csvSupplier.get();
writer.write(Base64.getEncoder().encodeToString(getGzippedByteArray(csv)));
} catch (IOException ex) {
LOGGER.error("Could not write to file.", ex);
}
VelocityContext context = prepareVelocityContext();
context.put("compressedRemoteLocation", csvFile.getName());
try (Writer writer = new FileWriter(htmlFile)) {
template.merge(context, writer);
} catch (IOException ex) {
LOGGER.error("Could not write to file.", ex);
}
}
19
Source : DashboardBuilder.java
with MIT License
from dwslab
with MIT License
from dwslab
/**
* Writes the HTML content to one file. This includes also the data (csv) which is included in the HTML file.
* This HTML file can be opened directly by a browser.
* @param htmlFile the file where all html data should be written to
*/
public void writeToFile(File htmlFile) {
if (htmlFile == null) {
LOGGER.error("The specified file is NULL. ABORT.");
return;
}
// in case the last row is not closed:
newRow();
VelocityContext context = prepareVelocityContext();
context.put("csvData", this.csvSupplier.get());
/*context.put("csvData", "Track,TestCase,left_label,left_comment,left_explicit_type,left_uri,relation,confidence,right_uri,right_label,right_comment,right explicit type,result\n" +
"conference,conference-sigkdd,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],http://conference-Review,=,1.0,http://sigkdd-Review,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],true positive\n" +
"conference,conference-sigkdd,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],http://conference-Committee,=,1.0,http://sigkdd-Committee,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],true positive\n" +
"conference,conference-sigkdd,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],http://conference-Person,=,1.0,http://sigkdd-Person,[],[],[http://www.w3.org/2002/07/owl-Clreplaced],true positive");
*/
try (Writer writer = new FileWriter(htmlFile)) {
template.merge(context, writer);
} catch (IOException ex) {
LOGGER.error("Could not write to file.", ex);
}
}
19
Source : DashboardBuilder.java
with MIT License
from dwslab
with MIT License
from dwslab
/**
* Writes the HTML content to htmlFile and the data (csv) to another file.
* This is for publishing the dashboard to a server.
* @param htmlFile the file where all html code should be written to
* @param csvFile the file where all data should be written to
*/
public void writeToFile(File htmlFile, File csvFile) {
newRow();
try (Writer writer = new BufferedWriter(new FileWriter(csvFile))) {
writer.write(this.csvSupplier.get());
} catch (IOException ex) {
LOGGER.error("Could not write to file.", ex);
}
VelocityContext context = prepareVelocityContext();
context.put("remoteLocation", csvFile.getName());
try (Writer writer = new FileWriter(htmlFile)) {
template.merge(context, writer);
} catch (IOException ex) {
LOGGER.error("Could not write to file.", ex);
}
}
19
Source : DashboardBuilder.java
with MIT License
from dwslab
with MIT License
from dwslab
private VelocityContext prepareVelocityContext() {
VelocityContext context = new VelocityContext();
context.put("replacedle", replacedle);
context.put("additionalText", additionalText);
context.put("dcjsElements", rows);
context.put("loadingSpinner", this.dataLoadingIndicator);
context.put("dimensionDefinition", this.getAllDimensionDefinitions());
context.put("groupDefinition", this.getAllGroupDefinitions());
context.put("jsHelperFileNames", this.getAllJsHelperFileNames());
return context;
}
19
Source : GridUtils.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
/**
* Render using Velocity.
*/
private static void render(Grid grid, Map<?, ?> params, Writer writer, String template) {
final VelocityContext context = new VelocityContext();
context.put(KEY_GRID, grid);
context.put(KEY_ENCODER, ENCODER);
context.put(KEY_PARAMS, params);
new VelocityManager().getEngine().getTemplate(template).merge(context, writer);
}
19
Source : ThemeElementProviderGenerator.java
with Apache License 2.0
from CloudMade
with Apache License 2.0
from CloudMade
private String getThemeSuffixesInitializer(Map<ChameleonThemeEnreplacedy, List<String>> themeSuffixesMap) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<ChameleonThemeEnreplacedy, List<String>> entry : themeSuffixesMap.entrySet()) {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("theme", entry.getKey().getThemeSuffix());
velocityContext.put("themeSuffixes", Algorithms.joinCollectionToStringWrappedInQuotes(entry.getValue()));
sb.append(clreplacedGenerator.mergeVelocityContext(velocityContext, VelocityTemplate.THEME_SUFFIXES_INITIALIZER)).append("\n");
}
return sb.toString();
}
19
Source : ThemeElementProviderGenerator.java
with Apache License 2.0
from CloudMade
with Apache License 2.0
from CloudMade
private String getThemeElementResources(Map<String, List<String>> resourcesMap) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, List<String>> entry : resourcesMap.entrySet()) {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("themeElementProviderKey", entry.getKey());
velocityContext.put("themeElementResources", Algorithms.joinCollectionToStringWrappedInQuotes(entry.getValue()));
sb.append(clreplacedGenerator.mergeVelocityContext(velocityContext, VelocityTemplate.THEME_ELEMENT_RESOURCE)).append("\n");
}
return sb.toString();
}
19
Source : ThemeElementProviderGenerator.java
with Apache License 2.0
from CloudMade
with Apache License 2.0
from CloudMade
private String getThemeElementProvideMethods(Set<String> themeResources, Map<String, Map<String, String>> javaDocInfoMap, String packageName, ResourceType resourceType) {
StringBuilder themeElementProviderMethodsStringBuilder = new StringBuilder();
for (String themeResource : themeResources) {
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("themeElementProvideMethod", getThemeElementProviderMethodName(themeResource));
velocityContext.put("themeElementProvideKey", themeResource);
velocityContext.put("javaDocInfo", getJavaDocInfo(javaDocInfoMap.get(themeResource), packageName, resourceType));
themeElementProviderMethodsStringBuilder.append(clreplacedGenerator.mergeVelocityContext(velocityContext, VelocityTemplate.THEME_ELEMENT_PROVIDE_METHOD)).append("\n");
}
return themeElementProviderMethodsStringBuilder.toString();
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateMapper(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getMapperPackage().replace(".", "/") + "/" + table.getBeanName() + "Mapper.java");
Template t = velocityEngine.getTemplate("mapperTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateServiceImpl(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getServiceImplPackage().replace(".", "/") + "/" + table.getBeanName() + "ServiceImpl.java");
Template t = velocityEngine.getTemplate("serviceImplTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateXml(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getXmlPackage().replace(".", "/") + "/" + table.getBeanName() + "Mapper.xml");
Template t = velocityEngine.getTemplate("xmlTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateService(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getServicePackage().replace(".", "/") + "/" + table.getBeanName() + "Service.java");
Template t = velocityEngine.getTemplate("serviceTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateWebController(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getControllerPackage().replace(".", "/") + "/" + table.getBeanName() + "Controller.java");
Template t = velocityEngine.getTemplate("controllerTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : Generator.java
with MIT License
from chyanwu
with MIT License
from chyanwu
public void generateModel(String targetDir, Table table) {
VelocityEngine velocityEngine = createVelocityEngine();
VelocityContext context = createContext(table);
Writer writer = createWriter(targetDir, configure.getEnreplacedyPackage().replace(".", "/") + "/" + table.getBeanName() + ".java");
Template t = velocityEngine.getTemplate("beanTemplate.vm");
t.merge(context, writer);
flushWriter(writer);
}
19
Source : VelocityWebPlugin.java
with Apache License 2.0
from bruceran
with Apache License 2.0
from bruceran
VelocityContext generateVelocityContext(WebContextData ctx, WebReq req, WebRes res) {
VelocityContext context = new VelocityContext();
context.put("req", req.getParameters());
context.put("res", res.getResults());
if (ctx.getSession() != null)
context.put("session", ctx.getSession());
context.put("version", version);
context.put("tool", tool);
return context;
}
19
Source : VelocityTemplate.java
with MIT License
from baiczsy
with MIT License
from baiczsy
/**
* Volecity 模板
* Created by wangl on 2016/7/5.
*/
public clreplaced VelocityTemplate extends ViewResult {
static {
try {
initVelocity();
} catch (IOException e) {
e.printStackTrace();
}
}
private String vmpath;
private VelocityContext context;
public VelocityTemplate(String vmpath, VelocityContext context) {
this.vmpath = vmpath;
this.context = context;
}
public void setVmpath(String vmpath) {
this.vmpath = vmpath;
}
public void setContext(VelocityContext context) {
this.context = context;
}
@Override
protected void execute() throws IOException {
Template template = Velocity.getTemplate(vmpath);
StringWriter writer = new StringWriter();
template.merge(context, writer);
getResponse().setContentType("text/html;charset=utf-8");
getResponse().getWriter().println(writer.toString());
}
/**
* 初始化Velocity
* @throws IOException
*/
private static void initVelocity() throws IOException {
InputStream in = VelocityTemplate.clreplaced.getClreplacedLoader().getResourcereplacedtream("velocity.properties");
Properties prop = new Properties();
prop.load(in);
for (String name : prop.stringPropertyNames()) {
if (name.equals(Velocity.FILE_RESOURCE_LOADER_PATH)) {
String projectDir = ActionContext.getContext().getRealPath("");
Velocity.addProperty(name, projectDir + prop.getProperty(name));
} else {
Velocity.addProperty(name, prop.getProperty(name));
}
}
Velocity.init();
}
}
19
Source : VelocityTemplate.java
with MIT License
from baiczsy
with MIT License
from baiczsy
public void setContext(VelocityContext context) {
this.context = context;
}
See More Examples