001
014
015 package com.liferay.portlet.dynamicdatamapping.storage;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portlet.expando.model.ExpandoColumn;
020 import com.liferay.portlet.expando.model.ExpandoValue;
021
022 import java.util.HashMap;
023 import java.util.List;
024 import java.util.Map;
025
026 import org.springframework.expression.BeanResolver;
027 import org.springframework.expression.EvaluationContext;
028
029
032 public class ExpandoValueBeanResolver implements BeanResolver {
033
034 public ExpandoValueBeanResolver(List<ExpandoValue> expandoValues) {
035 _expandoValues = new HashMap<String, ExpandoValue>();
036
037 try {
038 for (ExpandoValue expandoValue : expandoValues) {
039 ExpandoColumn expandoColumn = expandoValue.getColumn();
040
041 _expandoValues.put(expandoColumn.getName(), expandoValue);
042 }
043 }
044 catch (Exception e) {
045 _log.error(e.getMessage(), e);
046 }
047 }
048
049 @Override
050 public Object resolve(EvaluationContext context, String beanName) {
051 return _expandoValues.get(beanName);
052 }
053
054 private static Log _log = LogFactoryUtil.getLog(
055 ExpandoValueBeanResolver.class);
056
057 private Map<String, ExpandoValue> _expandoValues;
058
059 }