1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.controller;
17
18
19 import java.util.Map;
20
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.seasar.tuigwaa.database.function.CriteriaExeFunction;
28 import org.seasar.tuigwaa.model.DAOService;
29 import org.seasar.tuigwaa.model.DataService;
30 import org.seasar.tuigwaa.model.core.TgwEntity;
31 import org.seasar.tuigwaa.system.Constants;
32 import org.seasar.tuigwaa.util.TgwUtils;
33 import org.seasar.tuigwaa.util.ajax.AbstractRowSetAction;
34 import org.seasar.tuigwaa.util.ajax.RowSetForm;
35
36
37 public class AggregationAction extends AbstractRowSetAction {
38
39 private DAOService daoService_;
40
41 public AggregationAction(DAOService daoService) {
42 this.daoService_ = daoService;
43 }
44
45 public String getFormName() {
46 return "aggregationForm";
47 }
48
49 public String getEditPath() {
50 return "tiles.sitemanage.createAggregation";
51 }
52
53 public String getBasePath() {
54 return "/listRecord.do";
55 }
56
57 public RowSetForm getNewRowSet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
58 TgwEntity entity = TgwUtils.getEntity(request, getServlet());
59 Map map = daoService_.getDataFilterFunctionMap(entity);
60
61 String valueStr = request.getParameter(Constants.PARAM_VALUE);
62 boolean valueFlag = "true".equals(valueStr);
63 AggregationForm aggForm = new AggregationForm(entity, map);
64 aggForm.setValueFlag(valueFlag);
65 return aggForm;
66 }
67
68 public RowSetForm getRowSet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
69
70 return null;
71 }
72
73 public ActionForward doSave(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
74 AggregationForm aggForm = (AggregationForm)form;
75
76 CriteriaExeFunction function = aggForm.getAggregatoinExeFunction();
77 TgwEntity entity = aggForm.getEntity();
78
79 daoService_.registerDaoMethod(entity, function);
80 daoService_.saveFunction(entity);
81
82 String daoType = (aggForm.isValueFlag())?DataService.DAOTYPE_VALUE:DataService.DAOTYPE_AGGREGATION;
83
84 return TgwUtils.dialoggCloseAndListRecordForward(mapping, request, entity.getName(),
85 aggForm.getName(), daoType);
86 }
87 }