1 /*
2 * Copyright 2006 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
17 package org.kuali.ole.module.cg.businessobject;
18
19 import java.util.LinkedHashMap;
20
21 import org.kuali.ole.coa.businessobject.Chart;
22 import org.kuali.ole.coa.businessobject.Organization;
23 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
24 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
25
26 /**
27 * Represents a relationship between a {@link Proposal} and an {@Org}.
28 */
29 public class ProposalOrganization extends PersistableBusinessObjectBase implements Primaryable, MutableInactivatable {
30
31 private String chartOfAccountsCode;
32 private String organizationCode;
33 private Long proposalNumber;
34 private boolean proposalPrimaryOrganizationIndicator;
35 private boolean active = true;
36
37 private Organization organization;
38 private Chart chartOfAccounts;
39
40 /**
41 * Default constructor.
42 */
43 public ProposalOrganization() {
44 }
45
46 /**
47 * Gets the chartOfAccountsCode attribute.
48 *
49 * @return Returns the chartOfAccountsCode
50 */
51 public String getChartOfAccountsCode() {
52 return chartOfAccountsCode;
53 }
54
55 /**
56 * Sets the chartOfAccountsCode attribute.
57 *
58 * @param chartOfAccountsCode The chartOfAccountsCode to set.
59 */
60 public void setChartOfAccountsCode(String chartOfAccountsCode) {
61 this.chartOfAccountsCode = chartOfAccountsCode;
62 }
63
64
65 /**
66 * Gets the organizationCode attribute.
67 *
68 * @return Returns the organizationCode
69 */
70 public String getOrganizationCode() {
71 return organizationCode;
72 }
73
74 /**
75 * Sets the organizationCode attribute.
76 *
77 * @param organizationCode The organizationCode to set.
78 */
79 public void setOrganizationCode(String organizationCode) {
80 this.organizationCode = organizationCode;
81 }
82
83
84 /**
85 * Gets the proposalNumber attribute.
86 *
87 * @return Returns the proposalNumber
88 */
89 public Long getProposalNumber() {
90 return proposalNumber;
91 }
92
93 /**
94 * Sets the proposalNumber attribute.
95 *
96 * @param proposalNumber The proposalNumber to set.
97 */
98 public void setProposalNumber(Long proposalNumber) {
99 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.krad.bo.BusinessObjectBase#toStringMapper()
181 */
182 protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
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 OLEKeyConstants?
200 return getChartOfAccountsCode() + "-" + getOrganizationCode() + " " + (isProposalPrimaryOrganizationIndicator() ? "primary" : "secondary");
201 }
202
203 }