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.model.DAOService;
24 import org.seasar.tuigwaa.model.ModelService;
25 import org.seasar.tuigwaa.model.core.TgwEntity;
26 import org.seasar.tuigwaa.plugin.TgwPluginUtils;
27 import org.seasar.tuigwaa.util.TgwContext;
28
29 import com.isenshi.util.functor.UnaryProcedure;
30
31 public class RowDeleteProcedure implements UnaryProcedure {
32
33 private String entityName;
34
35 public RowDeleteProcedure() {
36 }
37
38 public RowDeleteProcedure(String entityName) {
39 this.entityName = entityName;
40 }
41
42 public void setEntityName(String entityName) {
43 this.entityName = entityName;
44 }
45
46 public String getEntityName() {
47 return entityName;
48 }
49
50 public void run(Object obj) {
51 DAOService daoService = (DAOService) SingletonS2ContainerFactory
52 .getContainer().getComponent(DAOService.class);
53 ModelService entityService = (ModelService) SingletonS2ContainerFactory
54 .getContainer().getComponent(ModelService.class);
55
56 String siteName = TgwContext.getSiteName();
57
58 HttpServletRequest request = SingletonS2ContainerFactory.getContainer()
59 .getRequest();
60 Map map = TgwPluginUtils.getEntityNameMapFromRequest(request);
61
62 String idStr = (String) map.get(entityName);
63 if (idStr == null) {
64 return;
65 }
66 Long id = Long.valueOf(idStr);
67
68 if (id.longValue() > 0) {
69 TgwEntity entity = entityService.getEntity(siteName, entityName);
70 daoService.getDAO(entity).delete(id);
71 }
72 }
73 }