1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.logic.functor;
17
18 import java.util.Map;
19
20 import javax.servlet.http.HttpServletRequest;
21
22 import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
23 import org.seasar.tuigwaa.database.function.DaoMethod;
24 import org.seasar.tuigwaa.model.DAOService;
25 import org.seasar.tuigwaa.model.ModelService;
26 import org.seasar.tuigwaa.model.core.TgwEntity;
27 import org.seasar.tuigwaa.plugin.TgwPluginUtils;
28 import org.seasar.tuigwaa.util.TgwContext;
29
30 import com.isenshi.util.functor.UnaryProcedure;
31
32 public class RowUpdateProcedure implements UnaryProcedure {
33
34 private String updateDaoName;
35
36 private String entityName;
37
38 public RowUpdateProcedure() {
39 }
40
41 public RowUpdateProcedure(String entityName, String daoName) {
42 this.entityName = entityName;
43 this.updateDaoName = daoName;
44 }
45
46 public void setUpdateDaoName(String updateDaoName) {
47 this.updateDaoName = updateDaoName;
48 }
49
50 public String getUpdateDaoName() {
51 return updateDaoName;
52 }
53
54 public void setEntityName(String entityName) {
55 this.entityName = entityName;
56 }
57
58 public String getEntityName() {
59 return entityName;
60 }
61
62 public void run(Object obj) {
63 DAOService daoService = (DAOService) SingletonS2ContainerFactory
64 .getContainer().getComponent(DAOService.class);
65 ModelService entityService = (ModelService) SingletonS2ContainerFactory
66 .getContainer().getComponent(ModelService.class);
67
68 String siteName = TgwContext.getSiteName();
69 TgwEntity entity = entityService.getEntity(siteName, entityName);
70 DaoMethod daoMethod = daoService.getDAO(entity)
71 .getMethod(updateDaoName);
72
73
74
75 HttpServletRequest request = SingletonS2ContainerFactory.getContainer()
76 .getRequest();
77 Map map = TgwPluginUtils.getEntityNameMapFromRequest(request);
78 String idStr = (String)map.get(entityName);
79 if(idStr==null){
80 return;
81 }
82 Long id = Long.valueOf(idStr);
83
84
85
86 if (id != null && id.longValue() > 0) {
87 daoMethod.evaluate(id);
88 }
89 }
90 }