View Javadoc
1   package org.kuali.ole.deliver.bo;
2   
3   import org.kuali.ole.describe.bo.OleLocation;
4   import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
5   import org.kuali.rice.krad.service.KRADServiceLocator;
6   
7   import java.util.HashMap;
8   import java.util.List;
9   import java.util.Map;
10  
11  /**
12   * Created with IntelliJ IDEA.
13   * User: ?
14   * Date: 12/17/12
15   * Time: 4:53 PM
16   * To change this template use File | Settings | File Templates.
17   */
18  public class OleCirculationDeskLocation extends PersistableBusinessObjectBase {
19      private String circulationDeskLocationId;
20      private String circulationDeskId;
21      private String circulationDeskLocation;
22      private String circulationPickUpDeskLocation;
23      private String circulationPickUpLocationCode;
24      private String circulationLocationCode;
25      private String circulationFullLocationCode;
26      private String circulationPickUpFullLocationCode;
27      private OleCirculationDesk oleCirculationDesk = new OleCirculationDesk();
28      private OleLocation location = new OleLocation();
29      private OleLocation pickupLocation = new OleLocation();
30  
31      public String getCirculationDeskLocationId() {
32          return circulationDeskLocationId;
33      }
34  
35      public void setCirculationDeskLocationId(String circulationDeskLocationId) {
36          this.circulationDeskLocationId = circulationDeskLocationId;
37      }
38  
39      public String getCirculationDeskId() {
40          return circulationDeskId;
41      }
42  
43      public void setCirculationDeskId(String circulationDeskId) {
44          this.circulationDeskId = circulationDeskId;
45      }
46  
47      public String getCirculationDeskLocation() {
48          return circulationDeskLocation;
49      }
50  
51      public void setCirculationDeskLocation(String circulationDeskLocation) {
52          this.circulationDeskLocation = circulationDeskLocation;
53      }
54  
55      public OleCirculationDesk getOleCirculationDesk() {
56          return oleCirculationDesk;
57      }
58  
59      public void setOleCirculationDesk(OleCirculationDesk oleCirculationDesk) {
60          this.oleCirculationDesk = oleCirculationDesk;
61      }
62  
63      public OleLocation getLocation() {
64          return location;
65      }
66  
67      public void setLocation(OleLocation location) {
68          this.location = location;
69      }
70  
71      public String getCirculationLocationCode() {
72          if ((circulationLocationCode == null && location != null)) {
73              return location.getLocationCode();
74          }
75          return circulationLocationCode;
76      }
77  
78      public void setCirculationLocationCode(String circulationLocationCode) {
79          this.circulationLocationCode = circulationLocationCode;
80      }
81  
82      public String getCirculationFullLocationCode() {
83          String fullLocationCode = this.getCirculationLocationCode();
84          if (circulationDeskLocation != null) {
85              Map<String, String> locationMap = new HashMap<String, String>();
86              locationMap.put("locationId", circulationDeskLocation);
87              List<OleLocation> oleLocationList = (List<OleLocation>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLocation.class, locationMap);
88              if (oleLocationList.size() > 0) {
89  
90                  OleLocation deskLocation = oleLocationList.get(0);
91                  if (deskLocation.getParentLocationId() != null) {
92                      deskLocation = deskLocation.getOleLocation();
93                  } else {
94                      return fullLocationCode;
95                  }
96                  while (deskLocation != null) {
97                      fullLocationCode = deskLocation.getLocationCode() + "/" + fullLocationCode;
98                      if (deskLocation.getParentLocationId() != null) {
99                          deskLocation = deskLocation.getOleLocation();
100                     } else
101                         deskLocation = null;
102                 }
103                 return fullLocationCode;
104             }
105         } else {
106             fullLocationCode = this.circulationFullLocationCode;
107         }
108         return fullLocationCode;
109     }
110 
111     public String getCirculationPickUpFullLocationCode() {
112         String fullLocationCode = this.getCirculationPickUpLocationCode();
113         if (circulationPickUpDeskLocation != null) {
114             Map<String, String> locationMap = new HashMap<String, String>();
115             locationMap.put("locationId", circulationPickUpDeskLocation);
116             List<OleLocation> oleLocationList = (List<OleLocation>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLocation.class, locationMap);
117             if (oleLocationList.size() > 0) {
118 
119                 OleLocation deskLocation = oleLocationList.get(0);
120                 if (deskLocation.getParentLocationId() != null) {
121                     deskLocation = deskLocation.getOleLocation();
122                 } else {
123                     return fullLocationCode;
124                 }
125                 while (deskLocation != null) {
126                     fullLocationCode = deskLocation.getLocationCode() + "/" + fullLocationCode;
127                     if (deskLocation.getParentLocationId() != null) {
128                         deskLocation = deskLocation.getOleLocation();
129                     } else
130                         deskLocation = null;
131                 }
132                 return fullLocationCode;
133             }
134         } else {
135             fullLocationCode = this.circulationPickUpDeskLocation;
136         }
137         return fullLocationCode;
138     }
139 
140     public void setCirculationPickUpFullLocationCode(String circulationPickUpFullLocationCode) {
141         this.circulationPickUpFullLocationCode = circulationPickUpFullLocationCode;
142     }
143 
144     public void setCirculationFullLocationCode(String circulationFullLocationCode) {
145         this.circulationFullLocationCode = circulationFullLocationCode;
146     }
147 
148     public String getCirculationPickUpDeskLocation() {
149         return circulationPickUpDeskLocation;
150     }
151 
152     public void setCirculationPickUpDeskLocation(String circulationPickUpDeskLocation) {
153         this.circulationPickUpDeskLocation = circulationPickUpDeskLocation;
154     }
155 
156     public OleLocation getPickupLocation() {
157         return pickupLocation;
158     }
159 
160     public void setPickupLocation(OleLocation pickupLocation) {
161         this.pickupLocation = pickupLocation;
162     }
163 
164     public String getCirculationPickUpLocationCode() {
165         if ((circulationPickUpLocationCode == null && pickupLocation != null)) {
166             return pickupLocation.getLocationCode();
167         }
168         return circulationPickUpLocationCode;
169     }
170 
171     public void setCirculationPickUpLocationCode(String circulationPickUpLocationCode) {
172         this.circulationPickUpLocationCode = circulationPickUpLocationCode;
173     }
174 }