1   package ch.ige.edossier.web.struts;
2   
3   import javax.servlet.http.HttpServletRequest;
4   import org.apache.struts.action.*;
5   import org.apache.struts.upload.FormFile;
6   
7   /**
8    * B32.03 - eDossier-Interceptions - Diplomarbeit an der Software-Schule Schweiz<br>
9    * KANN-ZIEL [K4] - Mailversand an Markenprüfer (Pflichtenheft b32.03_PF_eDossier.pdf, Seite 17)<br>
10   * KANN-ZIEL [K6] - Attachement (Pflichtenheft b32.03_PF_eDossier.pdf, Seite 17)<br>
11   * NICE-TO_HAVE-ZIEL [N2] - Korrekturvorschläge (Pflichtenheft b32.03_PF_eDossier.pdf, Seite 17)<br>
12   * Die Klasse AnswerForm ist die Datenhaltung der answer.jsp.
13   * <p>
14   * Copyright (c) 2004, Eidgenössisches Institut für Geistiges Eigentum
15   * @author    Anita Rueegsegger, Marc Bouquet
16   * @version   $Id: AnswerForm.java,v 1.8 2004/11/15 18:22:52 bouquet Exp $
17   */
18  public class AnswerForm extends ActionForm
19  {
20    private int answerId = 0;
21    private int interceptionId = 0;
22    private String name = null;
23    private String email = null;
24    private String telNr = null;
25    private String text = null; //Clob in DB
26    private String standardtext = ""; //Clob in DB
27    private FormFile uploadData = null;
28  
29    //*******************************************************************************************************************
30     //  G E T T E R -  U N D  S E T T E R - M E T H O D E N  D E R  A C T I O N F O R M
31     //*******************************************************************************************************************
32  
33      public int getAnswerId()
34      {
35        return answerId;
36      }
37  
38    public void setAnswerId( int answerId )
39    {
40      this.answerId = answerId;
41    }
42  
43    public int getInterceptionId()
44    {
45      return interceptionId;
46    }
47  
48    public void setInterceptionId( int interceptionId )
49    {
50      this.interceptionId = interceptionId;
51    }
52  
53    public String getStandardtext()
54    {
55      return standardtext;
56    }
57  
58    public void setStandardtext( String standardtext )
59    {
60      this.standardtext = standardtext;
61    }
62  
63    public String getName()
64    {
65      return name;
66    }
67  
68    public void setName( String name )
69    {
70      this.name = name;
71    }
72  
73    public String getEmail()
74    {
75      return email;
76    }
77  
78    public void setEmail( String email )
79    {
80      this.email = email;
81    }
82  
83    public String getTelNr()
84    {
85      return telNr;
86    }
87  
88    public void setTelNr( String telNr )
89    {
90      this.telNr = telNr;
91    }
92  
93    public String getText()
94    {
95      return text;
96    }
97  
98    public void setText( String text )
99    {
100     this.text = text;
101   }
102 
103   public FormFile getUploadData()
104   {
105     return uploadData;
106   }
107 
108   public void setUploadData( FormFile uploadData )
109   {
110     this.uploadData = uploadData;
111   }
112 
113   /**
114    * Überprüft ob die erforderlichen Felder nicht leer sind und gültige Daten enthalten
115    * Feld Email muss ein @ enthalten
116    * Standardtext oder Text muss vorhanden sein
117    * @param actionMapping ActionMapping
118    * @param httpServletRequest HttpServletRequest
119    * @return ActionErrors
120    */
121   public ActionErrors validate( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
122   {
123     ActionErrors errors = new ActionErrors();
124 
125     if( name == null || name.trim().equals( "" ) )
126     {
127       errors.add( "name", new ActionError( "validate.answer.nameRequired" ) );
128     }
129     else if( name.length() > 40 )
130     {
131       errors.add( "name", new ActionError( "validate.answer.nameLength" ) );
132     }
133 
134     if( email == null || email.trim().equals( "" ) )
135     {
136       errors.add( "email", new ActionError( "validate.answer.emailRequired" ) );
137     }
138     else if( email.length() > 50 )
139     {
140       errors.add( "email", new ActionError( "validate.answer.emailLength" ) );
141     }
142     else if( email.indexOf( "@" ) == -1 )
143     {
144       errors.add( "email", new ActionError( "validate.answer.emailNotValid" ) );
145     }
146 
147     if( telNr == null || telNr.trim().equals( "" ) )
148     {
149       errors.add( "telNr", new ActionError( "validate.answer.telNrRequired" ) );
150     }
151     else if( telNr.length() > 23 )
152     {
153       errors.add( "telNr", new ActionError( "validate.answer.telNrLength" ) );
154     }
155 
156 
157     if( ( this.text == null || this.text.trim().equals( "" ) ) &&
158         ( this.standardtext == null || this.standardtext.trim().equals( "" ) ) )
159     {
160       errors.add( "text", new ActionError( "validate.answer.textRequired" ) );
161     }
162 
163     return errors;
164   }
165 
166   /**
167    * Diese Methode setzt die Eingabedaten auf der JSP zurück in den Defaultwert
168    * @param actionMapping ActionMapping
169    * @param httpServletRequest HttpServletRequest
170    */
171   public void reset( ActionMapping actionMapping, HttpServletRequest httpServletRequest )
172   {
173     this.standardtext = "";
174     this.name = null;
175     this.email = null;
176     this.telNr = null;
177     this.text = null;
178   }
179 }
180