Related to VIVO-954. Added handling of null vClass for odd objects like \'count per year\'

This commit is contained in:
Tim Worrall 2015-01-30 11:33:17 -05:00
parent 9297c90946
commit 3b85239642

View file

@ -14,6 +14,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -136,7 +137,10 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
if ( label != null ) { if ( label != null ) {
List<String> msTypes = ind.getMostSpecificTypeURIs(); List<String> msTypes = ind.getMostSpecificTypeURIs();
if ( hasSubclasses && msTypes.size() > 0 ) { if ( hasSubclasses && msTypes.size() > 0 ) {
label += " (" + getMsTypeLocalName(msTypes.get(0), wDaoFact) + ")"; String theType = getMsTypeLocalName(msTypes.get(0), wDaoFact);
if ( theType.length() > 0 ) {
label += " (" + theType + ")";
}
} }
optionsMap.put(uri, label); optionsMap.put(uri, label);
++optionsCount; ++optionsCount;
@ -202,7 +206,13 @@ public class IndividualsViaObjectPropetyOptions implements FieldOptions {
private String getMsTypeLocalName(String theUri, WebappDaoFactory wDaoFact) { private String getMsTypeLocalName(String theUri, WebappDaoFactory wDaoFact) {
VClassDao vcDao = wDaoFact.getVClassDao(); VClassDao vcDao = wDaoFact.getVClassDao();
VClass vClass = vcDao.getVClassByURI(theUri); VClass vClass = vcDao.getVClassByURI(theUri);
String theType = ((vClass.getName() == null) ? "" : vClass.getName()); String theType = "";
if ( vClass == null ) {
return "";
}
else {
theType = ((vClass.getName() == null) ? "" : vClass.getName());
}
return theType; return theType;
} }