View Javadoc

1   package org.kuali.ole.patron.bo;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.kuali.ole.patron.api.OlePatronAffiliationContract;
5   import org.kuali.ole.patron.api.OlePatronAffiliationDefinition;
6   import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
7   import org.kuali.rice.kim.api.identity.phone.EntityPhone;
8   import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo;
9   import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
10  import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo;
11  import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
12  import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
13  import org.kuali.rice.krad.bo.BusinessObjectBase;
14  
15  import java.util.ArrayList;
16  import java.util.List;
17  
18  /**
19   * Created with IntelliJ IDEA.
20   * User: JuliyaMonica.S
21   * Date: 10/11/12
22   * Time: 11:56 AM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class OlePatronAffiliation extends BusinessObjectBase implements OlePatronAffiliationContract {
26  
27      private String entityAffiliationId;
28  
29      private String affiliationTypeCode;
30  
31      private String campusCode;
32  
33      private boolean defaultValue;
34  
35      private boolean active;
36  
37      private EntityAffiliationTypeBo affiliationType = new EntityAffiliationTypeBo();
38  
39      private List<EntityEmploymentBo> employments = new ArrayList<EntityEmploymentBo>();
40  
41      private Long versionNumber;
42  
43      private String objectId;
44  
45      public OlePatronAffiliation() {
46  
47      }
48      public OlePatronAffiliation(EntityAffiliationBo entityAffiliationBo) {
49          this.setEntityAffiliationId(entityAffiliationBo.getId());
50          this.setAffiliationTypeCode(entityAffiliationBo.getAffiliationTypeCode());
51          this.setAffiliationType(entityAffiliationBo.getAffiliationType());
52          this.setDefaultValue(entityAffiliationBo.getDefaultValue());
53          this.setActive(entityAffiliationBo.getActive());
54          this.setVersionNumber(entityAffiliationBo.getVersionNumber());
55          this.setObjectId(entityAffiliationBo.getObjectId());
56      }
57  
58      public String getEntityAffiliationId() {
59          return entityAffiliationId;
60      }
61  
62      public void setEntityAffiliationId(String entityAffiliationId) {
63          this.entityAffiliationId = entityAffiliationId;
64      }
65  
66      public String getAffiliationTypeCode() {
67          return affiliationTypeCode;
68      }
69  
70      public void setAffiliationTypeCode(String affiliationTypeCode) {
71          this.affiliationTypeCode = affiliationTypeCode;
72      }
73  
74      public String getCampusCode() {
75          return campusCode;
76      }
77  
78      public void setCampusCode(String campusCode) {
79          this.campusCode = campusCode;
80      }
81  
82      public boolean isDefaultValue() {
83          return defaultValue;
84      }
85  
86      public void setDefaultValue(boolean defaultValue) {
87          this.defaultValue = defaultValue;
88      }
89  
90      public boolean isActive() {
91          return active;
92      }
93  
94      public void setActive(boolean active) {
95          this.active = active;
96      }
97  
98      public EntityAffiliationTypeBo getAffiliationType() {
99          return affiliationType;
100     }
101 
102     public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
103         this.affiliationType = affiliationType;
104     }
105 
106     public List<EntityEmploymentBo> getEmployments() {
107         return employments;
108     }
109 
110     public void setEmployments(List<EntityEmploymentBo> employments) {
111         this.employments = employments;
112     }
113     public EntityAffiliationBo getEntityAffliationBo() {
114         EntityAffiliationBo entityAffiliationBo = new EntityAffiliationBo();
115         entityAffiliationBo.setId(this.getEntityAffiliationId());
116         entityAffiliationBo.setAffiliationTypeCode(this.getAffiliationTypeCode());
117         entityAffiliationBo.setAffiliationType(this.getAffiliationType());
118         entityAffiliationBo.setActive(this.isActive());
119         entityAffiliationBo.setDefaultValue(this.defaultValue);
120         entityAffiliationBo.setCampusCode(this.getCampusCode());
121         entityAffiliationBo.setObjectId(this.getObjectId());
122         entityAffiliationBo.setVersionNumber(this.getVersionNumber());
123         return entityAffiliationBo;
124     }
125 
126     /**
127      * This method converts the PersistableBusinessObjectBase OleBorrowerType into immutable object OlePatronAffiliationDefinition
128      * @param bo(OlePatronAffiliation)
129      * @return OlePatronAffiliationDefinition
130      */
131     static OlePatronAffiliationDefinition to(OlePatronAffiliation bo) {
132         if (bo == null) { return null; }
133         return OlePatronAffiliationDefinition.Builder.create(bo).build();
134     }
135 
136     /**
137      * This method converts the immutable object OlePatronAffiliationDefinition into PersistableBusinessObjectBase OlePatronAffiliation
138      * @param im(OlePatronAffiliationDefinition)
139      * @return bo(OlePatronAffiliation)
140      */
141     static OlePatronAffiliation from(OlePatronAffiliationDefinition im) {
142         if (im == null) { return null; }
143 
144         OlePatronAffiliation bo = new OlePatronAffiliation();
145         bo.entityAffiliationId= im.getEntityAffiliationId();
146         bo.affiliationTypeCode = im.getAffiliationTypeCode();
147         if (im.getAffiliationType() != null) {
148             bo.affiliationType = EntityAffiliationTypeBo.from(im.getAffiliationType());
149         }
150         bo.defaultValue = im.isDefaultValue();
151         bo.active = im.isActive();
152         bo.versionNumber = im.getVersionNumber();
153 
154         if (CollectionUtils.isNotEmpty(im.getEmployments())) {
155             for (EntityEmployment entityEmployment : im.getEmployments()) {
156                 bo.employments.add(EntityEmploymentBo.from(entityEmployment));
157             }
158         }
159         return bo;
160     }
161 
162     @Override
163     public void refresh() {
164         //To change body of implemented methods use File | Settings | File Templates.
165     }
166 
167     @Override
168     public String getId() {
169         return this.entityAffiliationId;
170     }
171 
172 
173     @Override
174     public Long getVersionNumber() {
175         return this.versionNumber;
176     }
177 
178     public void setVersionNumber(Long versionNumber) {
179         this.versionNumber = versionNumber;
180     }
181 
182     public String getObjectId() {
183         return objectId;
184     }
185 
186     public void setObjectId(String objectId) {
187         this.objectId = objectId;
188     }
189 
190 }