001/*
002 * Copyright 2007 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 java.util.Collection;
019
020import org.apache.log4j.Logger;
021import org.kuali.ole.fp.businessobject.MessageOfTheDay;
022import org.kuali.ole.sys.context.SpringContext;
023import org.kuali.rice.krad.service.BusinessObjectService;
024import org.kuali.rice.krad.valuefinder.ValueFinder;
025
026public class MessageOfTheDayFinder implements ValueFinder {
027//    public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/MessageOfTheDayFinder";
028//
029//    @Cacheable(value=CACHE_NAME)
030    @Override
031    public String getValue() {
032        try {
033            Collection<MessageOfTheDay> collection = SpringContext.getBean(BusinessObjectService.class).findAll(MessageOfTheDay.class);
034        if (collection != null && !collection.isEmpty()) {
035                return collection.iterator().next().getFinancialSystemMessageOfTheDayText();
036            }
037        } catch ( Exception ex ) {
038            Logger.getLogger(getClass()).error("Unable to retrieve the message of the day",ex);
039        }
040        return "unable to retrieve message of the day";
041    }
042
043}