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 circulationLocationCode;
23      private String circulationFullLocationCode;
24      private OleCirculationDesk oleCirculationDesk = new OleCirculationDesk();
25      private OleLocation location = new OleLocation();
26  
27      public String getCirculationDeskLocationId() {
28          return circulationDeskLocationId;
29      }
30  
31      public void setCirculationDeskLocationId(String circulationDeskLocationId) {
32          this.circulationDeskLocationId = circulationDeskLocationId;
33      }
34  
35      public String getCirculationDeskId() {
36          return circulationDeskId;
37      }
38  
39      public void setCirculationDeskId(String circulationDeskId) {
40          this.circulationDeskId = circulationDeskId;
41      }
42  
43      public String getCirculationDeskLocation() {
44          return circulationDeskLocation;
45      }
46  
47      public void setCirculationDeskLocation(String circulationDeskLocation) {
48          this.circulationDeskLocation = circulationDeskLocation;
49      }
50  
51      public OleCirculationDesk getOleCirculationDesk() {
52          return oleCirculationDesk;
53      }
54  
55      public void setOleCirculationDesk(OleCirculationDesk oleCirculationDesk) {
56          this.oleCirculationDesk = oleCirculationDesk;
57      }
58  
59      public OleLocation getLocation() {
60          return location;
61      }
62  
63      public void setLocation(OleLocation location) {
64          this.location = location;
65      }
66  
67      public String getCirculationLocationCode() {
68          if ((circulationLocationCode == null && location != null)) {
69              return location.getLocationCode();
70          }
71          return circulationLocationCode;
72      }
73  
74      public void setCirculationLocationCode(String circulationLocationCode) {
75          this.circulationLocationCode = circulationLocationCode;
76      }
77  
78      public String getCirculationFullLocationCode() {
79          String fullLocationCode = this.getCirculationLocationCode();
80          if (circulationDeskLocation != null) {
81              Map<String, String> locationMap = new HashMap<String, String>();
82              locationMap.put("locationId", circulationDeskLocation);
83              List<OleLocation> oleLocationList = (List<OleLocation>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLocation.class, locationMap);
84              if (oleLocationList.size() > 0) {
85  
86                  OleLocation deskLocation = oleLocationList.get(0);
87                  if (deskLocation.getParentLocationId() != null) {
88                      deskLocation = deskLocation.getOleLocation();
89                  } else {
90                      return fullLocationCode;
91                  }
92                  while (deskLocation != null) {
93                      fullLocationCode = deskLocation.getLocationCode() + "/" + fullLocationCode;
94                      if (deskLocation.getParentLocationId() != null) {
95                          deskLocation = deskLocation.getOleLocation();
96                      } else
97                          deskLocation = null;
98                  }
99                  return fullLocationCode;
100             }
101         } else {
102             fullLocationCode = this.circulationFullLocationCode;
103         }
104         return fullLocationCode;
105     }
106 
107     public void setCirculationFullLocationCode(String circulationFullLocationCode) {
108         this.circulationFullLocationCode = circulationFullLocationCode;
109     }
110 }