use of org.broadleafcommerce.common.RequestDTO in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafRobotsController method buildMvelParameters.
/**
* @param request
* @return
*/
private Map<String, Object> buildMvelParameters(HttpServletRequest request) {
TimeDTO timeDto = new TimeDTO(SystemTime.asCalendar());
RequestDTO requestDto = (RequestDTO) request.getAttribute(REQUEST_DTO);
Map<String, Object> mvelParameters = new HashMap<String, Object>();
mvelParameters.put("time", timeDto);
mvelParameters.put("request", requestDto);
Map<String, Object> blcRuleMap = (Map<String, Object>) request.getAttribute(BLC_RULE_MAP_PARAM);
if (blcRuleMap != null) {
for (String mapKey : blcRuleMap.keySet()) {
mvelParameters.put(mapKey, blcRuleMap.get(mapKey));
}
}
return mvelParameters;
}
use of org.broadleafcommerce.common.RequestDTO in project BroadleafCommerce by BroadleafCommerce.
the class ContentProcessor method buildMvelParameters.
/**
* MVEL is used to process the content targeting rules.
*
* @param request
* @return
*/
protected Map<String, Object> buildMvelParameters(HttpServletRequest request, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
TimeZone timeZone = BroadleafRequestContext.getBroadleafRequestContext().getTimeZone();
final TimeDTO timeDto;
if (timeZone != null) {
timeDto = new TimeDTO(SystemTime.asCalendar(timeZone));
} else {
timeDto = new TimeDTO();
}
RequestDTO requestDto = (RequestDTO) request.getAttribute(REQUEST_DTO);
Map<String, Object> mvelParameters = new HashMap<>();
mvelParameters.put("time", timeDto);
mvelParameters.put("request", requestDto);
String productString = tagAttributes.get("product");
if (productString != null) {
Object product = context.parseExpression(productString);
if (product != null) {
mvelParameters.put("product", product);
}
}
String categoryString = tagAttributes.get("category");
if (categoryString != null) {
Object category = context.parseExpression(categoryString);
if (category != null) {
mvelParameters.put("category", category);
}
}
@SuppressWarnings("unchecked") Map<String, Object> blcRuleMap = (Map<String, Object>) request.getAttribute(BLC_RULE_MAP_PARAM);
if (blcRuleMap != null) {
for (String mapKey : blcRuleMap.keySet()) {
mvelParameters.put(mapKey, blcRuleMap.get(mapKey));
}
}
return mvelParameters;
}
Aggregations