001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.module.ec.document.web.struts;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.apache.commons.lang.StringUtils;
022 import org.kuali.kfs.module.ec.EffortConstants;
023 import org.kuali.kfs.module.ec.EffortPropertyConstants;
024 import org.kuali.kfs.module.ec.document.EffortCertificationDocument;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.kfs.sys.context.SpringContext;
027 import org.kuali.rice.kns.service.DictionaryValidationService;
028 import org.kuali.rice.kns.util.GlobalVariables;
029
030 /**
031 * To define an action form for effrot certification recreate process
032 */
033 public class CertificationRecreateForm extends EffortCertificationForm {
034 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CertificationRecreateForm.class);
035
036 protected String emplid;
037 protected String personName;
038 protected Integer universityFiscalYear;
039 protected String effortCertificationReportNumber;
040
041 /**
042 * Constructs a CertificationRecreateForm.java.
043 */
044 public CertificationRecreateForm() {
045 super();
046 }
047
048 /**
049 * Gets the importing field values.
050 *
051 * @return Returns the importing field values.
052 */
053 protected List<String> getImportingFields() {
054 List<String> importingFields = new ArrayList<String>();
055
056 importingFields.add(KFSPropertyConstants.EMPLID);
057 importingFields.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
058 importingFields.add(EffortPropertyConstants.EFFORT_CERTIFICATION_REPORT_NUMBER);
059
060 return importingFields;
061 }
062
063 /**
064 * validate the importing field values
065 *
066 * @return true if the importing field values are valid; otherwsie, add errors into error map and return false
067 */
068 public boolean validateImportingFieldValues(EffortCertificationDocument document) {
069 DictionaryValidationService dictionaryValidationService = SpringContext.getBean(DictionaryValidationService.class);
070
071 for (String fieldName : this.getImportingFields()) {
072 dictionaryValidationService.validateDocumentAttribute(document, fieldName, EffortConstants.DOCUMENT_PREFIX);
073 }
074
075 return GlobalVariables.getMessageMap().isEmpty();
076 }
077
078 /**
079 * force the input data as upper case
080 */
081 public void forceInputAsUpperCase() {
082
083 String reportNumber = this.getEffortCertificationReportNumber();
084 this.setEffortCertificationReportNumber(StringUtils.upperCase(reportNumber));
085 }
086
087 /**
088 * Gets the emplid attribute.
089 *
090 * @return Returns the emplid.
091 */
092 public String getEmplid() {
093 return emplid;
094 }
095
096 /**
097 * Sets the emplid attribute value.
098 *
099 * @param emplid The emplid to set.
100 */
101 public void setEmplid(String emplid) {
102 this.emplid = emplid;
103 }
104
105 /**
106 * Gets the universityFiscalYear attribute.
107 *
108 * @return Returns the universityFiscalYear.
109 */
110 public Integer getUniversityFiscalYear() {
111 return universityFiscalYear;
112 }
113
114 /**
115 * Sets the universityFiscalYear attribute value.
116 *
117 * @param universityFiscalYear The universityFiscalYear to set.
118 */
119 public void setUniversityFiscalYear(Integer universityFiscalYear) {
120 this.universityFiscalYear = universityFiscalYear;
121 }
122
123 /**
124 * Gets the effortCertificationReportNumber attribute.
125 *
126 * @return Returns the effortCertificationReportNumber.
127 */
128 public String getEffortCertificationReportNumber() {
129 return effortCertificationReportNumber;
130 }
131
132 /**
133 * Sets the effortCertificationReportNumber attribute value.
134 *
135 * @param effortCertificationReportNumber The effortCertificationReportNumber to set.
136 */
137 public void setEffortCertificationReportNumber(String effortCertificationReportNumber) {
138 this.effortCertificationReportNumber = effortCertificationReportNumber;
139 }
140
141 /**
142 * Gets the personName attribute.
143 *
144 * @return Returns the personName.
145 */
146 public String getName() {
147 return personName;
148 }
149
150 /**
151 * Sets the personName attribute value.
152 *
153 * @param personName The personName to set.
154 */
155 public void setName(String personName) {
156 this.personName = personName;
157 }
158 }
159