View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.businessobject.defaultvalue;
17  
18  import java.util.Collection;
19  
20  import org.apache.log4j.Logger;
21  import org.kuali.ole.fp.businessobject.MessageOfTheDay;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.krad.service.BusinessObjectService;
24  import org.kuali.rice.krad.valuefinder.ValueFinder;
25  
26  public class MessageOfTheDayFinder implements ValueFinder {
27  //    public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/MessageOfTheDayFinder";
28  //
29  //    @Cacheable(value=CACHE_NAME)
30      @Override
31      public String getValue() {
32          try {
33              Collection<MessageOfTheDay> collection = SpringContext.getBean(BusinessObjectService.class).findAll(MessageOfTheDay.class);
34          if (collection != null && !collection.isEmpty()) {
35                  return collection.iterator().next().getFinancialSystemMessageOfTheDayText();
36              }
37          } catch ( Exception ex ) {
38              Logger.getLogger(getClass()).error("Unable to retrieve the message of the day",ex);
39          }
40          return "unable to retrieve message of the day";
41      }
42  
43  }