/*
 * Copyright 2006 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.module.labor.web.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.kuali.core.bo.user.UniversalUser;
import org.kuali.core.exceptions.UserNotFoundException;
import org.kuali.core.web.struts.form.KualiTransactionalDocumentFormBase;
import org.kuali.module.labor.document.SalaryExpenseTransferDocument;

import static org.kuali.core.util.SpringServiceLocator.getUniversalUserService;

/**
 * This class is the form class for the Salary Expense Transfer document. This method extends the parent
 * KualiTransactionalDocumentFormBase class which contains all of the common form methods and form attributes needed by the
 * Salary Expense Transfer document. It adds a new method which is a convenience method for getting at the Salary Expense Transfer document easier.
 * 
 * 
 */
public class SalaryExpenseTransferForm extends LaborDocumentFormBase {
    private UniversalUser user;
    private String userId;

    /**
     * Constructs a SalaryExpenseTransferForm instance and sets up the appropriately casted document.
     */
    public SalaryExpenseTransferForm() {
        super();
        setDocument(new SalaryExpenseTransferDocument());
    }

    /**
     * @return Returns the salaryExpenseTransferDocument.
     */
    public SalaryExpenseTransferDocument getSalaryExpenseTransferDocument() {
        return (SalaryExpenseTransferDocument) getDocument();
    }
    
    /**
     * Sets the <code>{@link UniversalUser}</code> through the <code>personUserIdentifier</code> attribute value
     *
     * @param uid <code>personUserIdentifier</code>
     */
    public void setUserId(String uid) throws UserNotFoundException {
        if (uid != null) {
            //  This may happen during populate when there is no initial user
            user = getUniversalUserService().getUniversalUser(uid);
        }
    }
    
    /**
     * Gets the <code>personUserIdentifier</code> attribute value from the <code>{@link UniversalUser}</code> instance
     *
     * @return String <code>personUserIdentifier</code>
     */
    public String getUserId() {
        String retval = null;
        if (user != null) {
            retval = user.getPersonUniversalIdentifier();
        }
        return retval;
    }

    /**
     * Gets the <code>personName</code> attribute value from the <code>{@link UniversalUser}</code> instance
     *
     * @return String <code>personName</code>
     */
    public String getPersonName() {
        String retval = null;
        if (user != null) {
            retval = user.getPersonName();
        }
        return retval;
    }

    /**
     * @param request direct access to the <code>{@link javax.servlet.http.HttpServletRequest}</code> instance 
     */
    @Override
    public void populate(HttpServletRequest request) {
        super.populate(request);
        
        
    }
}

@@ -2855,32 +2855,503 @@
  retval;%0A    %7D%0A%0A
+    /**%0A     * Sets the %3Ccode%3E%7B@link UniversalUser%7D%3C/code%3E through the %3Ccode%3EpersonUserIdentifier%3C/code%3E attribute value%0A     *%0A     * @param uid %3Ccode%3EpersonUserIdentifier%3C/code%3E%0A     */%0A    public void setPersonName(String personName) throws UserNotFoundException %7B%0A        if (personName != null) %7B%0A            //  This may happen during populate when there is no initial user%0A            user = getUniversalUserService().getUniversalUser(personName);%0A        %7D%0A    %7D%0A
     /**%0A     * G

Create Necessary JSP and TagLibrary Definitions for Salary Expense Transfer Document Proof-of-Concept