| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| KimEntityDataBase | 
  | 
  | 7.0;7 | 
| 1 |  /* | |
| 2 |   * Copyright 2007-2008 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.rice.kim.bo.entity.impl; | |
| 17 | ||
| 18 |  import java.util.List; | |
| 19 |  import java.util.Set; | |
| 20 | ||
| 21 |  import javax.persistence.MappedSuperclass; | |
| 22 | ||
| 23 |  import org.kuali.rice.kns.bo.DefaultableInactivateable; | |
| 24 |  import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; | |
| 25 | ||
| 26 |  /** | |
| 27 |   * This is a description of what this class does - jonathan don't forget to fill this in.  | |
| 28 |   *  | |
| 29 |   * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 30 |   * | |
| 31 |   */ | |
| 32 | @MappedSuperclass  | |
| 33 | 0 |  public abstract class KimEntityDataBase extends PersistableBusinessObjectBase { | 
| 34 | ||
| 35 | ||
| 36 | protected DefaultableInactivateable getDefaultItem( List<? extends DefaultableInactivateable> list ) {  | |
| 37 |                  // find the default entry | |
| 38 | 0 |                  for ( DefaultableInactivateable item : list ) { | 
| 39 | 0 |                          if ( item.isDefaultValue() && item.isActive() ) { | 
| 40 | 0 |                                  return item; | 
| 41 | }  | |
| 42 | }  | |
| 43 |                  // if no default, return the first | |
| 44 | 0 |                  if ( list.size() > 0 ) { | 
| 45 | 0 |                          return list.get( 0 ); | 
| 46 | }  | |
| 47 |                  // if neither, return null | |
| 48 | 0 |                  return null;                 | 
| 49 | }  | |
| 50 | ||
| 51 | protected DefaultableInactivateable getDefaultItem( Set<? extends DefaultableInactivateable> set ) {  | |
| 52 |                  // find the default entry | |
| 53 | 0 |                  for ( DefaultableInactivateable item : set ) { | 
| 54 | 0 |                          if ( item.isDefaultValue() && item.isActive() ) { | 
| 55 | 0 |                                  return item; | 
| 56 | }  | |
| 57 | }  | |
| 58 |                  // if no default, return the first | |
| 59 | 0 |                  if ( set.size() > 0 ) { | 
| 60 | 0 |                          return set.iterator().next(); | 
| 61 | }  | |
| 62 |                  // if neither, return null | |
| 63 | 0 |                  return null;                 | 
| 64 | }  | |
| 65 | ||
| 66 | }  |