Skip to content

Commit

Permalink
Merge pull request #805 from gopalponnusamy/OLE-8610
Browse files Browse the repository at this point in the history
OLE-8610 Full location name in docstore REST API
  • Loading branch information
peris authored Jun 17, 2016
2 parents d198d81 + 3179ee2 commit 5a5035d
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,39 @@
<field-descriptor name="versionNumber" column="VER_NBR" jdbc-type="BIGINT" locking="true"/>
</class-descriptor>

<class-descriptor class="org.kuali.ole.docstore.common.document.content.instance.OleLocationLevel" table="ole_locn_level_t">
<field-descriptor name="levelId" column="LEVEL_ID " jdbc-type="VARCHAR" primarykey="true" index="true"
autoincrement="true" sequence-name="ole_locn_level_s"></field-descriptor>
<field-descriptor name="levelCode" column="LEVEL_CD" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="levelName" column="LEVEL_NAME" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="parentLevelId" column="PARENT_LEVEL" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="objectId" column="OBJ_ID" jdbc-type="VARCHAR" index="true"/>
<field-descriptor name="versionNumber" column="VER_NBR" jdbc-type="BIGINT" locking="true"/>
<reference-descriptor name="oleLocationLevel" class-ref="org.kuali.ole.docstore.common.document.content.instance.OleLocationLevel"
auto-retrieve="true" auto-update="none" auto-delete="none" proxy="false">
<foreignkey field-ref="parentLevelId" target-field-ref="levelCode"/>
</reference-descriptor>
</class-descriptor>

<class-descriptor class="org.kuali.ole.docstore.common.document.content.instance.OleLocation" table="ole_locn_t">
<field-descriptor name="locationId" column="LOCN_ID " jdbc-type="VARCHAR" primarykey="true" index="true"
autoincrement="true" sequence-name="ole_locn_s"></field-descriptor>
<field-descriptor name="locationCode" column="LOCN_CD" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="locationName" column="LOCN_NAME" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="parentLocationId" column="PARENT_LOCN_ID" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="levelId" column="LEVEL_ID" jdbc-type="VARCHAR"></field-descriptor>
<field-descriptor name="objectId" column="OBJ_ID" jdbc-type="VARCHAR" index="true"/>
<field-descriptor name="versionNumber" column="VER_NBR" jdbc-type="BIGINT" locking="true"/>
<reference-descriptor name="oleLocation" class-ref="org.kuali.ole.docstore.common.document.content.instance.OleLocation" auto-retrieve="true"
auto-update="none" auto-delete="none" proxy="false">
<foreignkey field-ref="parentLocationId" target-field-ref="locationId"/>
</reference-descriptor>
<reference-descriptor name="oleLocationLevel" class-ref="org.kuali.ole.docstore.common.document.content.instance.OleLocationLevel"
auto-retrieve="true" auto-update="none" auto-delete="none" proxy="false">
<foreignkey field-ref="levelId" target-field-ref="levelId"/>
</reference-descriptor>
</class-descriptor>



</descriptor-repository>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package org.kuali.ole.docstore.common.document.content.instance;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import org.kuali.rice.krad.service.KRADServiceLocator;


/**
* Created by IntelliJ IDEA.
Expand Down Expand Up @@ -38,6 +44,7 @@
"name",
"level",
"code",
"fullName",
"locationLevel",

})
Expand All @@ -51,6 +58,8 @@ public class LocationLevel {
protected String level;
//@XmlElement(name = "locationLevel")
protected LocationLevel locationLevel;
@XmlElement(required = true)
protected String fullName;

/**
* Gets the value of the name property.
Expand All @@ -70,6 +79,7 @@ public String getName() {
*/
public void setName(String value) {
this.name = value;
fullName = findOutFullName();
}

/**
Expand Down Expand Up @@ -119,4 +129,22 @@ public String getCode() {
public void setCode(String code) {
this.code = code;
}


/**
*
* Finds the full name for the location code
*
* @return The full name as string
*/
private String findOutFullName(){
Map<String, String> criteria = new HashMap<String, String>();
criteria.put("locationCode", name);
List<OleLocation> oleLocation = (List<OleLocation>) KRADServiceLocator.getBusinessObjectService().findMatching(OleLocation.class, criteria);

if (oleLocation.size() > 0){
return oleLocation.get(0).getLocationName();
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
package org.kuali.ole.docstore.common.document.content.instance;

import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;

import java.util.LinkedHashMap;

/**
* The OleLocation is a BO class that defines the location fields with getters and setters which
* is used for interacting the location data with the persistence layer in OLE.
*/
public class OleLocation extends PersistableBusinessObjectBase {

private String locationId;
private String locationCode;
private String locationName;
private String parentLocationId;
private String levelId;
private String levelCode;
private OleLocation oleLocation;
private OleLocationLevel oleLocationLevel;
private String fullLocationPath;

/**
* Gets the levelCode string value from this OleLocation class
*
* @return levelCode
*/
public String getLevelCode() {
return oleLocationLevel.getLevelCode();
}

/**
* Sets the levelCode string value inside this OleLocation class
*
* @param levelCode
*/
public void setLevelCode(String levelCode) {
this.levelCode = levelCode;
}

/**
* Gets the parentLocationId string value from this OleLocation class
*
* @return parentLocationId
*/
public String getParentLocationId() {
return parentLocationId;
}

/**
* Sets the parentLocationId string value inside this OleLocation class
*
* @param parentLocationId
*/
public void setParentLocationId(String parentLocationId) {
if (parentLocationId != null && parentLocationId.equals(""))
this.parentLocationId = null;
else
this.parentLocationId = parentLocationId;
}

/**
* Gets the locationName string value from this OleLocation class
*
* @return locationName
*/
public String getLocationName() {
return locationName;
}

/**
* Sets the locationName string value inside this OleLocation class
*
* @param locationName
*/
public void setLocationName(String locationName) {
this.locationName = locationName;
}

/**
* Gets the locationCode string value from this OleLocation class
*
* @return locationCode
*/
public String getLocationCode() {
return locationCode;
}

/**
* Sets the locationCode string value inside this OleLocation class
*
* @param locationCode
*/
public void setLocationCode(String locationCode) {
this.locationCode = locationCode;
}

/**
* Gets the locationId string value from this OleLocation class
*
* @return locationId
*/
public String getLocationId() {
return locationId;
}

/**
* Sets the locationId string value inside this OleLocation class
*
* @param locationId
*/
public void setLocationId(String locationId) {
this.locationId = locationId;
}

/**
* Gets the oleLocation object value from this OleLocation class
*
* @return oleLocation
*/
public OleLocation getOleLocation() {
return oleLocation;
}

/**
* Sets the oleLocation value inside this OleLocation class
*
* @param oleLocation
*/
public void setOleLocation(OleLocation oleLocation) {
this.oleLocation = oleLocation;
}

/**
* Gets the levelId string value from this OleLocation class
*
* @return levelId
*/
public String getLevelId() {
return levelId;
}

/**
* Sets the levelId string value inside this OleLocation class
*
* @param levelId
*/
public void setLevelId(String levelId) {
this.levelId = levelId;
}

/**
* Gets the oleLocationLevel object value from this OleLocation class
*
* @return oleLocationLevel
*/
public OleLocationLevel getOleLocationLevel() {
return oleLocationLevel;
}

/**
* Sets the oleLocationLevel value inside this OleLocation class
*
* @param oleLocationLevel
*/
public void setOleLocationLevel(OleLocationLevel oleLocationLevel) {
this.oleLocationLevel = oleLocationLevel;
}

/**
* This method returns a map that contains the Primary Key value of this OleLocation class
*
* @return toStringMap
*/
protected LinkedHashMap toStringMapper() {
LinkedHashMap toStringMap = new LinkedHashMap();
toStringMap.put("locationId", locationId);
return toStringMap;
}


public String getFullLocationPath() {
String fullLocationCode = this.getLocationCode();
OleLocation deskLocation = this.getOleLocation();
while (deskLocation != null) {
fullLocationCode = deskLocation.getLocationCode() + "/" + fullLocationCode;
if (deskLocation.getParentLocationId() != null) {
deskLocation = deskLocation.getOleLocation();
} else
deskLocation = null;
}
return fullLocationCode;
}

public void setFullLocationPath(String fullLocationPath) {
this.fullLocationPath = fullLocationPath;
}


}
Loading

0 comments on commit 5a5035d

Please sign in to comment.