Fixing NPE when individual has no moniker and no types. NIHVIVO-1927

This commit is contained in:
bdc34 2011-01-27 23:22:04 +00:00
parent d68faf2cec
commit 347c09ef51

View file

@ -565,6 +565,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
// may have more than 1 VClass // may have more than 1 VClass
List<VClass> clasList = this.getVClasses(true); List<VClass> clasList = this.getVClasses(true);
if (clasList == null || clasList.size() < 2) { if (clasList == null || clasList.size() < 2) {
if( getVClass() != null )
moniker = getVClass().getName(); moniker = getVClass().getName();
} else { } else {
VClass preferredClass = null; VClass preferredClass = null;
@ -644,12 +645,12 @@ public class IndividualSDB extends IndividualImpl implements Individual {
dataset.getLock().enterCriticalSection(Lock.READ); dataset.getLock().enterCriticalSection(Lock.READ);
try { try {
String[] graphVars = { "?g" }; String[] graphVars = { "?g" };
String queryStr = "CONSTRUCT { ?ind <" + String queryStr =
propertyURI + "> ?value } \n" + "CONSTRUCT { <"+ind.getURI()+"> <" + propertyURI + "> ?value } \n" +
"WHERE { GRAPH ?g { ?ind <" + "WHERE { GRAPH ?g { \n" +
propertyURI + "> ?value } \n" + "<" + ind.getURI() +"> <" + propertyURI + "> ?value } \n" +
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) + WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
"\n} \n"; "\n} ";
Query query = QueryFactory.create(queryStr); Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create( QueryExecution qe = QueryExecutionFactory.create(
query, dataset); query, dataset);
@ -666,11 +667,10 @@ public class IndividualSDB extends IndividualImpl implements Individual {
}else{ }else{
String[] graphVars = { "?g" }; String[] graphVars = { "?g" };
String getPropertyValue = String getPropertyValue =
"SELECT ?value" + "SELECT ?value \n" +
"WHERE { GRAPH ?g { <" + individualURI + ">" + "WHERE { GRAPH ?g { \n" +
webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT + "<" +individualURI+ "> <" +webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT+ "> ?value} \n" +
"?value} \n" + WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) + "\n" +
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
"}"; "}";
DatasetWrapper w = getDatasetWrapper(); DatasetWrapper w = getDatasetWrapper();
Dataset dataset = w.getDataset(); Dataset dataset = w.getDataset();