1 /**
2 * Copyright 2005-2007 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.control.form;
16
17 import org.figure8.join.control.JoinForm;
18 import org.figure8.join.control.action.EISMappingActions;
19
20 import org.apache.struts.action.ActionMapping;
21
22 import javax.servlet.http.HttpServletRequest;
23 import java.util.Date;
24 /**
25 * Form object used for manipulating EIS mappings into Join application.
26 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
27 * @version $Revision: 1.1 $
28 *
29 * @struts.form name="eisMappingForm"
30 */
31 public class EISMappingForm extends JoinForm{
32
33
34
35 /** The unique id of EIS this mapping is for */
36 private long eisId = -1;
37 /** The unique name of gateway this mapping is for */
38 private String gatewayName;
39 /** The starting date of this EIS mapping */
40 private Date startDate;
41 /** The end date of this EIS mapping */
42 private Date endDate;
43
44 /** String representation of eisId (should be a long) */
45 private String eisIdStr = null;
46 /** String representation of gatewayId (should be a long) */
47 private String gatewayIdStr = null;
48
49
50
51
52 /** Creates a new instance of EISMappingForm */
53 public EISMappingForm(){
54 }
55
56
57
58
59 /** @return The unique id of EIS this mapping is for */
60 public long getEISId(){
61 return eisId;
62 }
63 /** @param eisId The unique id of EIS this mapping is for */
64 public void setEISId(long eisId){
65 this.eisId = eisId;
66 this.eisIdStr = String.valueOf(eisId);
67 }
68 /** @return The unique nmae of gateway this mapping is for */
69 public String getGatewayName(){
70 return gatewayName;
71 }
72 /** @param gatewayName The unique name of gateway this mapping is for */
73 public void setGatewayName(String gatewayName){
74 this.gatewayName = gatewayName;
75 }
76
77 /** @return The starting date of this EIS mapping */
78 public Date getStartDate(){
79 return startDate;
80 }
81 /** @param startDate The starting date of this EIS mapping */
82 public void setStartDate(Date startDate){
83 this.startDate = startDate;
84 }
85 /** @return The end date of this EIS mapping */
86 public Date getEndDate(){
87 return endDate;
88 }
89 /** @param endDate The end date of this EIS mapping */
90 public void setEndDate(Date endDate){
91 this.endDate = endDate;
92 }
93
94 /** @return String representation of eisId (should be a long) */
95 public String getEISIdStr(){
96 return eisIdStr;
97 }
98 /** @param eisIdStr String representation of eisId (must be a long) */
99 public void setEISIdStr(String eisIdStr){
100 this.eisIdStr = eisIdStr;
101 }
102
103
104
105
106 /**
107 * Validation of the form attributes.
108 * @param operation String representing the operation to invoke on Action
109 * @param mapping Mapping between forwards name and path for this action
110 * @param request The servlet container request wrapper
111 */
112 public void doValidate(String operation, ActionMapping mapping, HttpServletRequest request){
113
114 if (EISMappingActions.LOAD_OP.equals(operation) || EISMappingActions.CLOSE_OP.equals(operation)){
115
116 validateEntityObjectId();
117 }
118 else if (EISMappingActions.CREATE_OP.equals(operation)){
119
120 if (eisIdStr == null || eisIdStr.length() == 0)
121 addActionError("errors.required", getGuiMessageResources().getMessage("label.eismapping.eis"));
122 else{
123
124 try {eisId = Long.valueOf(eisIdStr).longValue();}
125 catch (Exception e){
126 addActionError("errors.range", getGuiMessageResources().getMessage("label.eismapping.eis"),
127 "1", String.valueOf(Long.MAX_VALUE));
128 }
129 }
130
131 if (gatewayName == null || gatewayName.length() == 0)
132 addActionError("errors.required", getGuiMessageResources().getMessage("label.eismapping.gateway"));
133 }
134 }
135
136
137
138
139 /**
140 * Reset form attributes.
141 * @param mapping Mapping between forwards name and path for this action
142 * @param request The servlet container request wrapper
143 */
144 public void reset(ActionMapping mapping, HttpServletRequest request){
145 super.reset(mapping, request);
146 eisId = -1;
147 gatewayName = null;
148 startDate = null;
149 endDate = null;
150 eisIdStr = null;
151 }
152 }