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.vnd.businessobject;
017    
018    import java.util.LinkedHashMap;
019    import java.util.List;
020    
021    import org.apache.commons.lang.StringUtils;
022    import org.kuali.kfs.integration.purap.PurchasingAccountsPayableModuleService;
023    import org.kuali.kfs.integration.purap.PurchasingAccountsPayableSensitiveData;
024    import org.kuali.kfs.sys.context.SpringContext;
025    import org.kuali.kfs.vnd.VendorPropertyConstants;
026    import org.kuali.rice.kns.bo.Inactivateable;
027    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
028    import org.kuali.rice.kns.service.KualiModuleService;
029    import org.kuali.rice.kns.util.TypedArrayList;
030    
031    /**
032     * CommodityCode Business Object
033     */
034    public class CommodityCode extends PersistableBusinessObjectBase implements Inactivateable  {
035        
036        private String purchasingCommodityCode;
037        private String commodityDescription;
038        private boolean salesTaxIndicator;
039        private boolean restrictedItemsIndicator;
040        private String sensitiveDataCode;
041        private boolean active;
042        
043        private PurchasingAccountsPayableSensitiveData sensitiveData;
044        
045        private List<CommodityContractManager> commodityContractManagers;
046        
047        public CommodityCode() {
048            commodityContractManagers = new TypedArrayList(CommodityContractManager.class);
049        }
050        
051        public boolean isActive() {
052            return active;
053        }
054    
055        public void setActive(boolean active) {
056            this.active = active;
057        }
058    
059        public String getPurchasingCommodityCode() {
060            return purchasingCommodityCode;
061        }
062    
063        public void setPurchasingCommodityCode(String purchasingCommodityCode) {
064            this.purchasingCommodityCode = purchasingCommodityCode;
065        }
066    
067        public String getCommodityDescription() {
068            return commodityDescription;
069        }
070    
071        public void setCommodityDescription(String commodityDescription) {
072            this.commodityDescription = commodityDescription;
073        }
074    
075        public boolean isRestrictedItemsIndicator() {
076            return restrictedItemsIndicator;
077        }
078    
079        public void setRestrictedItemsIndicator(boolean restrictedItemsIndicator) {
080            this.restrictedItemsIndicator = restrictedItemsIndicator;
081        }
082        
083        public String getSensitiveDataCode() {
084            return sensitiveDataCode;
085        }
086    
087        public void setSensitiveDataCode(String sensitiveDataCode) {
088            this.sensitiveDataCode = sensitiveDataCode;
089        }
090    
091        public PurchasingAccountsPayableSensitiveData getSensitiveData() {
092            /*if (StringUtils.isBlank(sensitiveDataCode)) {
093                if (sensitiveData != null) {
094                    sensitiveData = null;
095                }
096            } else {
097                if (sensitiveData == null || !sensitiveData.getSensitiveDataCode().equals(this.sensitiveDataCode)) {
098                    sensitiveData = SpringContext.getBean(PurchasingAccountsPayableModuleService.class).getSensitiveDataByCode(this.sensitiveDataCode);
099                }
100            }
101            return sensitiveData;*/
102            return sensitiveData = (PurchasingAccountsPayableSensitiveData)SpringContext.getBean(KualiModuleService.class)
103                                    .getResponsibleModuleService(PurchasingAccountsPayableSensitiveData.class)
104                                    .retrieveExternalizableBusinessObjectIfNecessary(this, sensitiveData, "sensitiveData");
105        }
106    
107        public boolean isSalesTaxIndicator() {
108            return salesTaxIndicator;
109        }
110    
111        public void setSalesTaxIndicator(boolean salesTaxIndicator) {
112            this.salesTaxIndicator = salesTaxIndicator;
113        }
114        
115        public List<CommodityContractManager> getCommodityContractManagers() {
116            return commodityContractManagers;
117        }
118    
119        public void setCommodityContractManagers(List<CommodityContractManager> commodityContractManagers) {
120            this.commodityContractManagers = commodityContractManagers;
121        }    
122    
123        /**
124         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
125         */
126        @Override
127        protected LinkedHashMap toStringMapper() {
128            LinkedHashMap m = new LinkedHashMap();
129            m.put(VendorPropertyConstants.PURCHASING_COMMODITY_CODE, this.purchasingCommodityCode);
130            m.put(VendorPropertyConstants.COMMODITY_DESCRIPTION, this.commodityDescription);
131            return null;
132        }
133    
134    }