View Javadoc
1   package org.kuali.ole.deliver.bo;
2   
3   import org.apache.commons.lang3.StringUtils;
4   import org.kuali.ole.deliver.api.OlePhoneContract;
5   import org.kuali.ole.deliver.api.OlePhoneDefinition;
6   import org.kuali.rice.kim.impl.identity.phone.EntityPhoneBo;
7   import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
8   import org.kuali.rice.krad.service.KRADServiceLocator;
9   
10  import java.util.HashMap;
11  import java.util.Map;
12  
13  /**
14   * Created by angelind on 10/6/15.
15   */
16  public class OlePhoneBo extends PersistableBusinessObjectBase implements OlePhoneContract{
17  
18      private String olePhoneId;
19      private String olePatronId;
20      private String id;
21      private String phoneSource;
22      private String phoneSourceName;
23      private OleAddressSourceBo olePhoneSourceBo = new OleAddressSourceBo();
24      private EntityPhoneBo entityPhoneBo;
25      private OlePatronDocument olePatronDocument;
26  
27      public String getOlePhoneId() {
28          return olePhoneId;
29      }
30  
31      public void setOlePhoneId(String olePhoneId) {
32          this.olePhoneId = olePhoneId;
33      }
34  
35      public String getOlePatronId() {
36          return olePatronId;
37      }
38  
39      public void setOlePatronId(String olePatronId) {
40          this.olePatronId = olePatronId;
41      }
42  
43      public String getPhoneSource() {
44          return phoneSource;
45      }
46  
47      public void setPhoneSource(String phoneSource) {
48          this.phoneSource = phoneSource;
49      }
50  
51      public String getPhoneSourceName() {
52          return phoneSourceName;
53      }
54  
55      public void setPhoneSourceName(String phoneSourceName) {
56          this.phoneSourceName = phoneSourceName;
57      }
58  
59      public OleAddressSourceBo getOlePhoneSourceBo() {
60          return olePhoneSourceBo;
61      }
62  
63      public void setOlePhoneSourceBo(OleAddressSourceBo olePhoneSourceBo) {
64          this.olePhoneSourceBo = olePhoneSourceBo;
65      }
66  
67      public EntityPhoneBo getEntityPhoneBo() {
68          return entityPhoneBo;
69      }
70  
71      public void setEntityPhoneBo(EntityPhoneBo entityPhoneBo) {
72          this.entityPhoneBo = entityPhoneBo;
73      }
74  
75      public OlePatronDocument getOlePatronDocument() {
76          if (null == olePatronDocument) {
77              String patronId = getOlePatronId();
78              if (StringUtils.isNotEmpty(patronId)) {
79                  Map<String, String> parameterMap = new HashMap<>();
80                  parameterMap.put("olePatronId", patronId);
81                  olePatronDocument = KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(OlePatronDocument.class, parameterMap);
82              }
83          }
84          return olePatronDocument;
85      }
86  
87      public void setOlePatronDocument(OlePatronDocument olePatronDocument) {
88          this.olePatronDocument = olePatronDocument;
89      }
90  
91      public static OlePhoneDefinition to(OlePhoneBo bo) {
92          if (bo == null) {
93              return null;
94          }
95          return OlePhoneDefinition.Builder.create(bo).build();
96      }
97  
98      public static OlePhoneBo from(OlePhoneDefinition imOlePhoneDefinition) {
99          if (imOlePhoneDefinition == null) {
100             return null;
101         }
102         OlePhoneBo bo = new OlePhoneBo();
103         bo.olePhoneId = imOlePhoneDefinition.getOlePhoneId();
104         bo.olePatronId = imOlePhoneDefinition.getOlePatronId();
105         bo.id = imOlePhoneDefinition.getId();
106         bo.phoneSource = imOlePhoneDefinition.getPhoneSource();
107         bo.versionNumber = imOlePhoneDefinition.getVersionNumber();
108         if (imOlePhoneDefinition.getOlePhoneSourceBo() != null) {
109             bo.olePhoneSourceBo = OleAddressSourceBo.from(imOlePhoneDefinition.getOlePhoneSourceBo());
110         }
111         return bo;
112     }
113 
114     public String getId() {
115         return id;
116     }
117 
118     public void setId(String id) {
119         this.id = id;
120     }
121 }