1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.plugin.database;
17
18 import org.seasar.framework.log.Logger;
19 import org.seasar.tuigwaa.cms.core.CmsRequest;
20 import org.seasar.tuigwaa.cms.core.CmsResponse;
21 import org.seasar.tuigwaa.database.function.criteria.CriteriaFunction;
22 import org.seasar.tuigwaa.model.DataService;
23 import org.seasar.tuigwaa.model.core.TgwEntity;
24 import org.seasar.tuigwaa.plugin.AbstractTgwPlugin;
25 import org.seasar.tuigwaa.plugin.PluginException;
26 import org.seasar.tuigwaa.plugin.PluginRequest;
27 import org.seasar.tuigwaa.system.TgwRuntimeException;
28
29 /***
30 * @author nishioka
31 */
32 public class ValuePlugin extends AbstractTgwPlugin {
33
34 private static final Logger logger = Logger.getLogger(ValuePlugin.class);
35
36 private DataService dataService = (DataService) getService(DataService.class);
37
38 public String doHTMLView(CmsRequest req, CmsResponse res,
39 PluginRequest prequest) throws PluginException {
40
41 String[] array = prequest.getArgs();
42 if (array == null || array.length < 2) {
43 return null;
44 }
45
46 String ret = null;
47 try {
48 String domain = req.getSiteName();
49 TgwEntity entity = getEntity(domain, array[0]);
50
51 if (entity == null) {
52 return null;
53 }
54
55 CriteriaFunction extraCriteria = createBindingCriteria(req, entity);
56 Object result = dataService.getValue(entity, array[1],
57 extraCriteria);
58
59 ret = (result != null) ? String.valueOf(result) : "";
60 } catch (TgwRuntimeException e) {
61 logger.log(e);
62 } catch (Exception e) {
63 e.printStackTrace();
64 throw new PluginException(e);
65 }
66 return ret;
67 }
68 }