001 /* 002 * Copyright 2011 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 */ 016 package org.kuali.kfs.sys.businessobject; 017 018 import java.util.LinkedHashMap; 019 020 import org.apache.commons.lang.StringUtils; 021 import org.kuali.kfs.sys.context.SpringContext; 022 import org.kuali.kfs.sys.service.KfsBusinessObjectMetaDataService; 023 import org.kuali.rice.kns.bo.Inactivateable; 024 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 025 026 public class FunctionalFieldDescription extends PersistableBusinessObjectBase implements Inactivateable { 027 private String namespaceCode; 028 private String componentClass; 029 private String propertyName; 030 private String description; 031 private boolean active; 032 033 private BusinessObjectProperty businessObjectProperty; 034 035 public FunctionalFieldDescription() { 036 } 037 038 public FunctionalFieldDescription(String componentClass, String propertyName) { 039 setComponentClass(componentClass); 040 setPropertyName(propertyName); 041 } 042 043 @Override 044 public void refreshNonUpdateableReferences() { 045 if (StringUtils.isNotBlank(getComponentClass()) && StringUtils.isNotBlank(getPropertyName()) && ((businessObjectProperty == null) || !getPropertyName().equals(businessObjectProperty.getPropertyName()) || (businessObjectProperty.getBusinessObjectComponent() == null) || !getComponentClass().equals(businessObjectProperty.getBusinessObjectComponent().getComponentClass()))) { 046 setBusinessObjectProperty(SpringContext.getBean(KfsBusinessObjectMetaDataService.class).getBusinessObjectProperty(getComponentClass(), getPropertyName())); 047 setNamespaceCode(businessObjectProperty.getNamespaceCode()); 048 } 049 } 050 051 public String getNamespaceCode() { 052 return namespaceCode; 053 } 054 055 public void setNamespaceCode(String namespaceCode) { 056 this.namespaceCode = namespaceCode; 057 } 058 059 public String getComponentClass() { 060 return componentClass; 061 } 062 063 public void setComponentClass(String componentClass) { 064 this.componentClass = componentClass; 065 } 066 067 public String getPropertyName() { 068 return propertyName; 069 } 070 071 public void setPropertyName(String propertyName) { 072 this.propertyName = propertyName; 073 } 074 075 public String getDescription() { 076 return description; 077 } 078 079 public void setDescription(String description) { 080 this.description = description; 081 } 082 083 public boolean isActive() { 084 return active; 085 } 086 087 public void setActive(boolean active) { 088 this.active = active; 089 } 090 091 public BusinessObjectProperty getBusinessObjectProperty() { 092 refreshNonUpdateableReferences(); 093 return businessObjectProperty; 094 } 095 096 public void setBusinessObjectProperty(BusinessObjectProperty businessObjectProperty) { 097 this.businessObjectProperty = businessObjectProperty; 098 } 099 100 @Override 101 protected LinkedHashMap toStringMapper() { 102 if (businessObjectProperty != null) { 103 return businessObjectProperty.toStringMapper(); 104 } 105 return new LinkedHashMap<String, String>(); 106 } 107 }