001/*
002 * Copyright 2009 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 */
016package org.kuali.ole.sys.businessobject.defaultvalue;
017
018import org.kuali.ole.select.document.service.OleSelectDocumentService;
019import org.kuali.ole.sys.OLEConstants;
020import org.kuali.ole.sys.context.SpringContext;
021import org.kuali.rice.kim.api.identity.Person;
022import org.kuali.rice.kim.api.identity.PersonService;
023import org.kuali.rice.krad.valuefinder.ValueFinder;
024
025/**
026 * This class...
027 */
028public class DefaultSystemUserValueFinder implements ValueFinder {
029
030    /**
031     * @see org.kuali.rice.krad.valuefinder.ValueFinder#getValue()
032     */
033
034    private OleSelectDocumentService oleSelectDocumentService;
035
036    public String getValue() {
037        Person defaultUser = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(getOleSelectDocumentService().getSelectParameterValue(OLEConstants.SYSTEM_USER));
038        if (defaultUser != null) {
039            return defaultUser.getPrincipalName();
040        }
041        else {
042            return OLEConstants.EMPTY_STRING;
043        }
044    }
045
046    public OleSelectDocumentService getOleSelectDocumentService() {
047        if(oleSelectDocumentService == null){
048            oleSelectDocumentService = SpringContext.getBean(OleSelectDocumentService.class);
049        }
050        return oleSelectDocumentService;
051    }
052
053    public void setOleSelectDocumentService(OleSelectDocumentService oleSelectDocumentService) {
054        this.oleSelectDocumentService = oleSelectDocumentService;
055    }
056
057}