001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.kra.routingform.web.struts.form;
017:
018: import java.util.ArrayList;
019: import java.util.HashMap;
020: import java.util.List;
021: import java.util.Map;
022:
023: import org.kuali.core.datadictionary.DataDictionary;
024: import org.kuali.core.datadictionary.DocumentEntry;
025: import org.kuali.core.service.DataDictionaryService;
026: import org.kuali.core.web.format.PhoneNumberFormatter;
027: import org.kuali.kfs.context.SpringContext;
028: import org.kuali.kfs.service.ParameterService;
029: import org.kuali.module.kra.KraConstants;
030: import org.kuali.module.kra.budget.web.struts.form.BudgetOverviewFormHelper;
031: import org.kuali.module.kra.document.ResearchDocument;
032: import org.kuali.module.kra.routingform.bo.RoutingFormInstitutionCostShare;
033: import org.kuali.module.kra.routingform.bo.RoutingFormOrganization;
034: import org.kuali.module.kra.routingform.bo.RoutingFormOrganizationCreditPercent;
035: import org.kuali.module.kra.routingform.bo.RoutingFormOtherCostShare;
036: import org.kuali.module.kra.routingform.bo.RoutingFormPersonnel;
037: import org.kuali.module.kra.routingform.bo.RoutingFormSubcontractor;
038: import org.kuali.module.kra.routingform.document.RoutingFormDocument;
039: import org.kuali.module.kra.web.struts.form.ResearchDocumentFormBase;
040:
041: public class RoutingForm extends ResearchDocumentFormBase {
042:
043: private boolean auditActivated;
044: private int numAuditErrors;
045:
046: // Main Page
047: private RoutingFormPersonnel newRoutingFormProjectDirector;
048: private RoutingFormPersonnel newRoutingFormOtherPerson;
049:
050: private RoutingFormOrganizationCreditPercent newRoutingFormOrganizationCreditPercent;
051:
052: // Project Details
053: private RoutingFormInstitutionCostShare newRoutingFormInstitutionCostShare;
054: private RoutingFormOtherCostShare newRoutingFormOtherCostShare;
055: private RoutingFormSubcontractor newRoutingFormSubcontractor;
056: private RoutingFormOrganization newRoutingFormOrganization;
057:
058: // Module Links
059: private String[] selectedBudgetPeriods;
060: private boolean allPeriodsSelected;
061: private List<BudgetOverviewFormHelper> periodBudgetOverviewFormHelpers;
062: private BudgetOverviewFormHelper summaryBudgetOverviewFormHelper;
063:
064: // Template properties
065: private boolean templateAddress;
066: private boolean templateAdHocPermissions;
067: private boolean templateAdHocApprovers;
068:
069: // Approvals
070: private String approvalsMessage;
071:
072: private Map systemParametersMap;
073:
074: /**
075: * Used to indicate which result set we're using when refreshing/returning from a multi-value lookup
076: */
077: private String lookupResultsSequenceNumber;
078: /**
079: * The type of result returned by the multi-value lookup TODO: to be persisted in the lookup results service instead? See
080: * KULRNE/Using+multiple+value+lookups
081: */
082: private String lookupResultsBOClassName;
083:
084: public RoutingForm() {
085: super ();
086:
087: DataDictionary dataDictionary = SpringContext.getBean(
088: DataDictionaryService.class).getDataDictionary();
089: DocumentEntry budgetDocumentEntry = dataDictionary
090: .getDocumentEntry(org.kuali.module.kra.routingform.document.RoutingFormDocument.class
091: .getName());
092: this .setHeaderNavigationTabs(budgetDocumentEntry
093: .getHeaderTabNavigation());
094:
095: setDocument(new RoutingFormDocument());
096:
097: periodBudgetOverviewFormHelpers = new ArrayList();
098:
099: setFormatterType(
100: "document.routingFormPersonnel.personPhoneNumber",
101: PhoneNumberFormatter.class);
102: setFormatterType(
103: "document.routingFormPersonnel.personFaxNumber",
104: PhoneNumberFormatter.class);
105: }
106:
107: @Override
108: public ResearchDocument getResearchDocument() {
109: return this .getRoutingFormDocument();
110: }
111:
112: public RoutingFormDocument getRoutingFormDocument() {
113: return (RoutingFormDocument) this .getDocument();
114: }
115:
116: public boolean isAuditActivated() {
117: return auditActivated;
118: }
119:
120: public void setAuditActivated(boolean auditActivated) {
121: this .auditActivated = auditActivated;
122: }
123:
124: public int getNumAuditErrors() {
125: return numAuditErrors;
126: }
127:
128: public void setNumAuditErrors(int numAuditErrors) {
129: this .numAuditErrors = numAuditErrors;
130: }
131:
132: public void setNewRoutingFormInstitutionCostShare(
133: RoutingFormInstitutionCostShare newRoutingFormInstitutionCostShare) {
134: this .newRoutingFormInstitutionCostShare = newRoutingFormInstitutionCostShare;
135: }
136:
137: public RoutingFormInstitutionCostShare getNewRoutingFormInstitutionCostShare() {
138: return newRoutingFormInstitutionCostShare;
139: }
140:
141: public RoutingFormOtherCostShare getNewRoutingFormOtherCostShare() {
142: return newRoutingFormOtherCostShare;
143: }
144:
145: public void setNewRoutingFormOtherCostShare(
146: RoutingFormOtherCostShare newRoutingFormOtherCostShare) {
147: this .newRoutingFormOtherCostShare = newRoutingFormOtherCostShare;
148: }
149:
150: public RoutingFormSubcontractor getNewRoutingFormSubcontractor() {
151: return newRoutingFormSubcontractor;
152: }
153:
154: public void setNewRoutingFormSubcontractor(
155: RoutingFormSubcontractor newRoutingFormSubcontractor) {
156: this .newRoutingFormSubcontractor = newRoutingFormSubcontractor;
157: }
158:
159: public RoutingFormPersonnel getNewRoutingFormProjectDirector() {
160: return newRoutingFormProjectDirector;
161: }
162:
163: public void setNewRoutingFormProjectDirector(
164: RoutingFormPersonnel newRoutingFormProjectDirector) {
165: this .newRoutingFormProjectDirector = newRoutingFormProjectDirector;
166: }
167:
168: public RoutingFormPersonnel getNewRoutingFormOtherPerson() {
169: return newRoutingFormOtherPerson;
170: }
171:
172: public void setNewRoutingFormOtherPerson(
173: RoutingFormPersonnel newRoutingFormOtherPerson) {
174: this .newRoutingFormOtherPerson = newRoutingFormOtherPerson;
175: }
176:
177: public RoutingFormOrganizationCreditPercent getNewRoutingFormOrganizationCreditPercent() {
178: return newRoutingFormOrganizationCreditPercent;
179: }
180:
181: public void setNewRoutingFormOrganizationCreditPercent(
182: RoutingFormOrganizationCreditPercent newRoutingFormOrganizationCreditPercent) {
183: this .newRoutingFormOrganizationCreditPercent = newRoutingFormOrganizationCreditPercent;
184: }
185:
186: public RoutingFormOrganization getNewRoutingFormOrganization() {
187: return newRoutingFormOrganization;
188: }
189:
190: public void setNewRoutingFormOrganization(
191: RoutingFormOrganization newRotuingFormOrganization) {
192: this .newRoutingFormOrganization = newRotuingFormOrganization;
193: }
194:
195: public boolean isTemplateAddress() {
196: return templateAddress;
197: }
198:
199: public void setTemplateAddress(boolean templateAddress) {
200: this .templateAddress = templateAddress;
201: }
202:
203: public boolean isTemplateAdHocApprovers() {
204: return templateAdHocApprovers;
205: }
206:
207: public void setTemplateAdHocApprovers(boolean templateAdHocApprovers) {
208: this .templateAdHocApprovers = templateAdHocApprovers;
209: }
210:
211: public boolean isTemplateAdHocPermissions() {
212: return templateAdHocPermissions;
213: }
214:
215: public void setTemplateAdHocPermissions(
216: boolean templateAdHocPermissions) {
217: this .templateAdHocPermissions = templateAdHocPermissions;
218: }
219:
220: public List<BudgetOverviewFormHelper> getPeriodBudgetOverviewFormHelpers() {
221: return periodBudgetOverviewFormHelpers;
222: }
223:
224: public void setPeriodBudgetOverviewFormHelpers(
225: List<BudgetOverviewFormHelper> periodBudgetOverviewFormHelpers) {
226: this .periodBudgetOverviewFormHelpers = periodBudgetOverviewFormHelpers;
227: }
228:
229: public BudgetOverviewFormHelper getPeriodBudgetOverviewFormHelper(
230: int index) {
231: while (this .getPeriodBudgetOverviewFormHelpers().size() <= index) {
232: this .getPeriodBudgetOverviewFormHelpers().add(
233: new BudgetOverviewFormHelper());
234: }
235: return this .getPeriodBudgetOverviewFormHelpers().get(index);
236: }
237:
238: public BudgetOverviewFormHelper getSummaryBudgetOverviewFormHelper() {
239: return summaryBudgetOverviewFormHelper;
240: }
241:
242: public void setSummaryBudgetOverviewFormHelper(
243: BudgetOverviewFormHelper summaryBudgetOverviewFormHelper) {
244: this .summaryBudgetOverviewFormHelper = summaryBudgetOverviewFormHelper;
245: }
246:
247: public boolean getAllPeriodsSelected() {
248: return allPeriodsSelected;
249: }
250:
251: public void setAllPeriodsSelected(boolean allPeriodsSelected) {
252: this .allPeriodsSelected = allPeriodsSelected;
253: }
254:
255: public String getApprovalsMessage() {
256: return approvalsMessage;
257: }
258:
259: public void setApprovalsMessage(String approvalsMessage) {
260: this .approvalsMessage = approvalsMessage;
261: }
262:
263: /**
264: * Gets the two column size of routingFormProjectTypes, zero based. The result will be rounded up so that the left column has an
265: * additional element for odd sized lists.
266: *
267: * @return half size of routingFormProjectTypes, rounded up, zero based
268: */
269: public int getRoutingFormProjectTypesSizeByTwoColumns() {
270: return new Double(Math.ceil(getRoutingFormDocument()
271: .getRoutingFormProjectTypes().size() / 2.0)).intValue() - 1;
272: }
273:
274: public String getLookupResultsBOClassName() {
275: return lookupResultsBOClassName;
276: }
277:
278: public void setLookupResultsBOClassName(
279: String lookupResultsBOClassName) {
280: this .lookupResultsBOClassName = lookupResultsBOClassName;
281: }
282:
283: public String getLookupResultsSequenceNumber() {
284: return lookupResultsSequenceNumber;
285: }
286:
287: public void setLookupResultsSequenceNumber(
288: String lookupResultsSequenceNumber) {
289: this .lookupResultsSequenceNumber = lookupResultsSequenceNumber;
290: }
291:
292: /**
293: * Lazy gets the systemParametersMap attribute. Use it on a jsp or tag as such:
294: * ${KualiForm.systemParametersMap[KraConstants.foobar]}
295: *
296: * @return Returns the systemParametersMap.
297: */
298: public Map getSystemParametersMap() {
299: if (systemParametersMap == null) {
300: systemParametersMap = new HashMap();
301:
302: ParameterService parameterService = SpringContext
303: .getBean(ParameterService.class);
304: systemParametersMap.put(
305: KraConstants.SUBMISSION_TYPE_CHANGE,
306: parameterService.getParameterValue(
307: RoutingFormDocument.class,
308: KraConstants.SUBMISSION_TYPE_CHANGE));
309: systemParametersMap.put(KraConstants.PROJECT_TYPE_OTHER,
310: parameterService.getParameterValue(
311: RoutingFormDocument.class,
312: KraConstants.PROJECT_TYPE_OTHER));
313: systemParametersMap.put(KraConstants.PURPOSE_RESEARCH,
314: parameterService.getParameterValue(
315: RoutingFormDocument.class,
316: KraConstants.PURPOSE_RESEARCH));
317: systemParametersMap.put(KraConstants.PURPOSE_OTHER,
318: parameterService.getParameterValue(
319: RoutingFormDocument.class,
320: KraConstants.PURPOSE_OTHER));
321:
322: systemParametersMap.put(
323: KraConstants.CO_PROJECT_DIRECTOR_PARAM,
324: parameterService.getParameterValue(
325: RoutingFormDocument.class,
326: KraConstants.CO_PROJECT_DIRECTOR_PARAM));
327: systemParametersMap.put(
328: KraConstants.PROJECT_DIRECTOR_PARAM,
329: parameterService.getParameterValue(
330: RoutingFormDocument.class,
331: KraConstants.PROJECT_DIRECTOR_PARAM));
332: systemParametersMap.put(KraConstants.OTHER_PERSON_PARAM,
333: parameterService.getParameterValue(
334: RoutingFormDocument.class,
335: KraConstants.OTHER_PERSON_PARAM));
336: systemParametersMap.put(KraConstants.CONTACT_PERSON_PARAM,
337: parameterService.getParameterValue(
338: RoutingFormDocument.class,
339: KraConstants.CONTACT_PERSON_PARAM));
340: }
341:
342: return systemParametersMap;
343: }
344: }
|