Clean up of error handeling in ObjectPropertyStatementDaoSDB.fillExistingObjectPropertyStatements() NIHVIVO-2080

This commit is contained in:
bdc34 2011-02-09 16:31:18 +00:00
parent 1341d23a25
commit c7a7625ec3

View file

@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.IndividualSDB.IndividualNotFoundException;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode;
public class ObjectPropertyStatementDaoSDB extends
@ -96,13 +97,9 @@ public class ObjectPropertyStatementDaoSDB extends
ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl();
objPropertyStmt.setSubjectURI(entity.getURI());
objPropertyStmt.setSubject(entity);
try {
objPropertyStmt.setObjectURI(((Resource)st.getObject()).getURI());
} catch (Throwable t) {
t.printStackTrace();
}
objPropertyStmt.setPropertyURI(st.getPredicate().getURI());
try {
Property prop = st.getPredicate();
if( uriToObjectProperty.containsKey(prop.getURI())){
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
@ -116,12 +113,9 @@ public class ObjectPropertyStatementDaoSDB extends
continue;
}
}
} catch (Throwable g) {
//do not add statement to list
log.debug("exception while trying to get object property for statement list, statement skipped.", g);
continue;
}
if (objPropertyStmt.getObjectURI() != null) {
//this might throw IndividualNotFoundException
Individual objInd = new IndividualSDB(
objPropertyStmt.getObjectURI(),
this.dwf,
@ -130,14 +124,19 @@ public class ObjectPropertyStatementDaoSDB extends
objPropertyStmt.setObject(objInd);
}
//add object property statement to list for Individual
//only add statement to list if it has its values filled out
if ( (objPropertyStmt.getSubjectURI() != null)
&& (objPropertyStmt.getPropertyURI() != null)
&& (objPropertyStmt.getObject() != null) ) {
objPropertyStmtList.add(objPropertyStmt);
}
} catch (IndividualNotFoundException t) {
log.error(t,t);
continue;
} catch (Throwable t){
t.printStackTrace();
log.error(t,t);
continue;
}
}
}