001/*
002 * Copyright 2011 The Kuali Foundation.
003 * 
004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.coa.service.impl;
017
018import org.apache.commons.lang.StringUtils;
019
020/**
021 * Represents an exemption in AccountReferencePersistencestructureServiceImpl - a business object and related-to-object
022 * keys which will lawlessly not abide by the rules
023 */
024public class AccountReferencePersistenceExemption {
025    protected Class<?> parentBusinessObjectClass;
026    protected String chartOfAccountsCodePropertyName;
027    protected String accountNumberPropertyName;
028    
029    /**
030     * @return the business object class which owns a relationship that will be exempted
031     */
032    public Class<?> getParentBusinessObjectClass() {
033        return parentBusinessObjectClass;
034    }
035    /**
036     * Sets the business object class which owns a relationship that will be exempted
037     * @param parentBusinessObjectClass the business object class which owns a relationship that will be exempted
038     */
039    public void setParentBusinessObjectClass(Class<?> parentBusinessObjectClass) {
040        this.parentBusinessObjectClass = parentBusinessObjectClass;
041    }
042    /**
043     * @return the name of the property on the parentBusinessObjectClass which represents the chart of accounts code portion of the Account relationship 
044     */
045    public String getChartOfAccountsCodePropertyName() {
046        return chartOfAccountsCodePropertyName;
047    }
048    /**
049     * Sets the name of the property on the parentBusinessObjectClass which represents the chart of accounts code portion of the Account relationship
050     * @param chartOfAccountsCodePropertyName the name of the property on the parentBusinessObjectClass which represents the chart of accounts code portion of the Account relationship
051     */
052    public void setChartOfAccountsCodePropertyName(String chartOfAccountsCodePropertyName) {
053        this.chartOfAccountsCodePropertyName = chartOfAccountsCodePropertyName;
054    }
055    /**
056     * @return the name of the property on the parentBusinessObjectClass which represents the account number portion of the Account relationship
057     */
058    public String getAccountNumberPropertyName() {
059        return accountNumberPropertyName;
060    }
061    /**
062     * Sets the name of the property on the parentBusinessObjectClass which represents the account number portion of the Account relationship
063     * @param accountNumberPropertyName the name of the property on the parentBusinessObjectClass which represents the account number portion of the Account relationship
064     */
065    public void setAccountNumberPropertyName(String accountNumberPropertyName) {
066        this.accountNumberPropertyName = accountNumberPropertyName;
067    }
068
069    /**
070     * Determines if the given chart of accounts code property name and account number property name would match the relationship-to-account chart of accounts code property name and account number property name encapsulated herein
071     * @param chartOfAccountsCodePropertyName the name of the chart of accounts code property name in the relationship
072     * @param accountNumberPropertyName the name of the account number property name in the relationship
073     * @return true if the property names all match
074     */
075    public boolean matches(String chartOfAccountsCodePropertyName, String accountNumberPropertyName) {
076        return ( ( !StringUtils.isBlank(chartOfAccountsCodePropertyName) && !StringUtils.isBlank(getChartOfAccountsCodePropertyName()) && chartOfAccountsCodePropertyName.equals(getChartOfAccountsCodePropertyName()) ) && ( !StringUtils.isBlank(accountNumberPropertyName) && !StringUtils.isBlank(getAccountNumberPropertyName()) && accountNumberPropertyName.equals(getAccountNumberPropertyName()) ) );
077    }
078}