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
017 package org.kuali.kfs.module.cg.businessobject;
018
019 import java.util.LinkedHashMap;
020
021 import org.kuali.kfs.coa.businessobject.Chart;
022 import org.kuali.kfs.coa.businessobject.Organization;
023 import org.kuali.rice.kns.bo.Inactivateable;
024 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
025
026 /**
027 * Represents a relationship between a {@link Proposal} and an {@Org}.
028 */
029 public class ProposalOrganization extends PersistableBusinessObjectBase implements Primaryable, Inactivateable {
030
031 private String chartOfAccountsCode;
032 private String organizationCode;
033 private Long proposalNumber;
034 private boolean proposalPrimaryOrganizationIndicator;
035 private boolean active = true;
036
037 private Organization organization;
038 private Chart chartOfAccounts;
039
040 /**
041 * Default constructor.
042 */
043 public ProposalOrganization() {
044 }
045
046 /**
047 * Gets the chartOfAccountsCode attribute.
048 *
049 * @return Returns the chartOfAccountsCode
050 */
051 public String getChartOfAccountsCode() {
052 return chartOfAccountsCode;
053 }
054
055 /**
056 * Sets the chartOfAccountsCode attribute.
057 *
058 * @param chartOfAccountsCode The chartOfAccountsCode to set.
059 */
060 public void setChartOfAccountsCode(String chartOfAccountsCode) {
061 this.chartOfAccountsCode = chartOfAccountsCode;
062 }
063
064
065 /**
066 * Gets the organizationCode attribute.
067 *
068 * @return Returns the organizationCode
069 */
070 public String getOrganizationCode() {
071 return organizationCode;
072 }
073
074 /**
075 * Sets the organizationCode attribute.
076 *
077 * @param organizationCode The organizationCode to set.
078 */
079 public void setOrganizationCode(String organizationCode) {
080 this.organizationCode = organizationCode;
081 }
082
083
084 /**
085 * Gets the proposalNumber attribute.
086 *
087 * @return Returns the proposalNumber
088 */
089 public Long getProposalNumber() {
090 return proposalNumber;
091 }
092
093 /**
094 * Sets the proposalNumber attribute.
095 *
096 * @param proposalNumber The proposalNumber to set.
097 */
098 public void setProposalNumber(Long proposalNumber) {
099 this.proposalNumber = proposalNumber;
100 }
101
102 /**
103 * @return Returns the proposalPrimaryOrganizationIndicator.
104 */
105 public boolean isProposalPrimaryOrganizationIndicator() {
106 return proposalPrimaryOrganizationIndicator;
107 }
108
109 /**
110 * @see Primaryable#isPrimary()
111 */
112 public boolean isPrimary() {
113 return isProposalPrimaryOrganizationIndicator();
114 }
115
116 /**
117 * @param proposalPrimaryOrganizationIndicator The proposalPrimaryOrganizationIndicator to set.
118 */
119 public void setProposalPrimaryOrganizationIndicator(boolean proposalPrimaryOrganizationIndicator) {
120 this.proposalPrimaryOrganizationIndicator = proposalPrimaryOrganizationIndicator;
121 }
122
123 /**
124 * Gets the active attribute.
125 *
126 * @return Returns the active attribute.
127 */
128 public boolean isActive() {
129 return active;
130 }
131
132 /**
133 * Sets the active attribute value.
134 *
135 * @param active true if the instance is active, false otherwise
136 */
137 public void setActive(boolean active) {
138 this.active = active;
139 }
140
141 /**
142 * Gets the organization attribute.
143 *
144 * @return Returns the organization
145 */
146 public Organization getOrganization() {
147 return organization;
148 }
149
150 /**
151 * Sets the organization attribute.
152 *
153 * @param organization The organization to set.
154 * @deprecated
155 */
156 public void setOrganization(Organization organization) {
157 this.organization = organization;
158 }
159
160 /**
161 * Gets the chartOfAccounts attribute.
162 *
163 * @return Returns the chartOfAccounts
164 */
165 public Chart getChartOfAccounts() {
166 return chartOfAccounts;
167 }
168
169 /**
170 * Sets the chartOfAccounts attribute.
171 *
172 * @param chartOfAccounts The chartOfAccounts to set.
173 * @deprecated
174 */
175 public void setChartOfAccounts(Chart chartOfAccounts) {
176 this.chartOfAccounts = chartOfAccounts;
177 }
178
179 /**
180 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
181 */
182 protected LinkedHashMap toStringMapper() {
183 LinkedHashMap m = new LinkedHashMap();
184 m.put("chartOfAccountsCode", this.chartOfAccountsCode);
185 m.put("organizationCode", this.organizationCode);
186 if (this.proposalNumber != null) {
187 m.put("proposalNumber", this.proposalNumber.toString());
188 }
189 return m;
190 }
191
192 /**
193 * This can be displayed by Proposal.xml lookup results.
194 *
195 * @see Object#toString()
196 */
197 @Override
198 public String toString() {
199 // todo: get "primary" and "secondary" from ApplicationResources.properties via KFSKeyConstants?
200 return getChartOfAccountsCode() + "-" + getOrganizationCode() + " " + (isProposalPrimaryOrganizationIndicator() ? "primary" : "secondary");
201 }
202
203 }