001package org.kuali.ole.describe.bo;
002
003import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
004
005import java.util.LinkedHashMap;
006
007/**
008 * The OleLocation is a BO class that defines the location fields with getters and setters which
009 * is used for interacting the location data with the persistence layer in OLE.
010 */
011public class OleLocation extends PersistableBusinessObjectBase {
012
013    private String locationId;
014    private String locationCode;
015    private String locationName;
016    private String parentLocationId;
017    private String levelId;
018    private String levelCode;
019    private OleLocation oleLocation;
020    private OleLocationLevel oleLocationLevel;
021    private String fullLocationPath;
022
023    /**
024     * Gets the levelCode string value from this OleLocation class
025     *
026     * @return levelCode
027     */
028    public String getLevelCode() {
029        return oleLocationLevel.getLevelCode();
030    }
031
032    /**
033     * Sets the levelCode string value inside this OleLocation class
034     *
035     * @param levelCode
036     */
037    public void setLevelCode(String levelCode) {
038        this.levelCode = levelCode;
039    }
040
041    /**
042     * Gets the parentLocationId string value from this OleLocation class
043     *
044     * @return parentLocationId
045     */
046    public String getParentLocationId() {
047        return parentLocationId;
048    }
049
050    /**
051     * Sets the parentLocationId string value inside this OleLocation class
052     *
053     * @param parentLocationId
054     */
055    public void setParentLocationId(String parentLocationId) {
056        if (parentLocationId != null && parentLocationId.equals(""))
057            this.parentLocationId = null;
058        else
059            this.parentLocationId = parentLocationId;
060    }
061
062    /**
063     * Gets the locationName string value from this OleLocation class
064     *
065     * @return locationName
066     */
067    public String getLocationName() {
068        return locationName;
069    }
070
071    /**
072     * Sets the locationName string value inside this OleLocation class
073     *
074     * @param locationName
075     */
076    public void setLocationName(String locationName) {
077        this.locationName = locationName;
078    }
079
080    /**
081     * Gets the locationCode string value from this OleLocation class
082     *
083     * @return locationCode
084     */
085    public String getLocationCode() {
086        return locationCode;
087    }
088
089    /**
090     * Sets the locationCode string value inside this OleLocation class
091     *
092     * @param locationCode
093     */
094    public void setLocationCode(String locationCode) {
095        this.locationCode = locationCode;
096    }
097
098    /**
099     * Gets the locationId string value from this OleLocation class
100     *
101     * @return locationId
102     */
103    public String getLocationId() {
104        return locationId;
105    }
106
107    /**
108     * Sets the locationId string value inside this OleLocation class
109     *
110     * @param locationId
111     */
112    public void setLocationId(String locationId) {
113        this.locationId = locationId;
114    }
115
116    /**
117     * Gets the oleLocation object value from this OleLocation class
118     *
119     * @return oleLocation
120     */
121    public OleLocation getOleLocation() {
122        return oleLocation;
123    }
124
125    /**
126     * Sets the oleLocation value inside this OleLocation class
127     *
128     * @param oleLocation
129     */
130    public void setOleLocation(OleLocation oleLocation) {
131        this.oleLocation = oleLocation;
132    }
133
134    /**
135     * Gets the levelId string value from this OleLocation class
136     *
137     * @return levelId
138     */
139    public String getLevelId() {
140        return levelId;
141    }
142
143    /**
144     * Sets the levelId string value inside this OleLocation class
145     *
146     * @param levelId
147     */
148    public void setLevelId(String levelId) {
149        this.levelId = levelId;
150    }
151
152    /**
153     * Gets the oleLocationLevel object value from this OleLocation class
154     *
155     * @return oleLocationLevel
156     */
157    public OleLocationLevel getOleLocationLevel() {
158        return oleLocationLevel;
159    }
160
161    /**
162     * Sets the oleLocationLevel value inside this OleLocation class
163     *
164     * @param oleLocationLevel
165     */
166    public void setOleLocationLevel(OleLocationLevel oleLocationLevel) {
167        this.oleLocationLevel = oleLocationLevel;
168    }
169
170    /**
171     * This method returns a map that contains the Primary Key value of this OleLocation class
172     *
173     * @return toStringMap
174     */
175    protected LinkedHashMap toStringMapper() {
176        LinkedHashMap toStringMap = new LinkedHashMap();
177        toStringMap.put("locationId", locationId);
178        return toStringMap;
179    }
180
181
182    public String getFullLocationPath() {
183        String fullLocationCode = this.getLocationCode();
184        OleLocation deskLocation = this.getOleLocation();
185        while (deskLocation != null) {
186            fullLocationCode = deskLocation.getLocationCode() + "/" + fullLocationCode;
187            if (deskLocation.getParentLocationId() != null) {
188                deskLocation = deskLocation.getOleLocation();
189            } else
190                deskLocation = null;
191        }
192        return fullLocationCode;
193    }
194
195    public void setFullLocationPath(String fullLocationPath) {
196        this.fullLocationPath = fullLocationPath;
197    }
198
199
200}