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.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; 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; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode;
public class ObjectPropertyStatementDaoSDB extends public class ObjectPropertyStatementDaoSDB extends
@ -96,48 +97,46 @@ public class ObjectPropertyStatementDaoSDB extends
ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl(); ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl();
objPropertyStmt.setSubjectURI(entity.getURI()); objPropertyStmt.setSubjectURI(entity.getURI());
objPropertyStmt.setSubject(entity); objPropertyStmt.setSubject(entity);
try { objPropertyStmt.setObjectURI(((Resource)st.getObject()).getURI());
objPropertyStmt.setObjectURI(((Resource)st.getObject()).getURI());
} catch (Throwable t) {
t.printStackTrace();
}
objPropertyStmt.setPropertyURI(st.getPredicate().getURI()); objPropertyStmt.setPropertyURI(st.getPredicate().getURI());
try { Property prop = st.getPredicate();
Property prop = st.getPredicate(); if( uriToObjectProperty.containsKey(prop.getURI())){
if( uriToObjectProperty.containsKey(prop.getURI())){ objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI())); }else{
}else{ ObjectProperty p = getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURI(prop.getURI());
ObjectProperty p = getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURI(prop.getURI()); if( p != null ){
if( p != null ){ uriToObjectProperty.put(prop.getURI(), p);
uriToObjectProperty.put(prop.getURI(), p); objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI())); }else{
}else{ //if ObjectProperty not found in ontology, skip it
//if ObjectProperty not found in ontology, skip it continue;
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) { if (objPropertyStmt.getObjectURI() != null) {
Individual objInd = new IndividualSDB( //this might throw IndividualNotFoundException
objPropertyStmt.getObjectURI(), Individual objInd = new IndividualSDB(
this.dwf, objPropertyStmt.getObjectURI(),
datasetMode, this.dwf,
getWebappDaoFactory()); datasetMode,
objPropertyStmt.setObject(objInd); getWebappDaoFactory());
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) if ( (objPropertyStmt.getSubjectURI() != null)
&& (objPropertyStmt.getPropertyURI() != null) && (objPropertyStmt.getPropertyURI() != null)
&& (objPropertyStmt.getObject() != null)){ && (objPropertyStmt.getObject() != null) ) {
objPropertyStmtList.add(objPropertyStmt); objPropertyStmtList.add(objPropertyStmt);
} }
} catch (Throwable t) {
t.printStackTrace(); } catch (IndividualNotFoundException t) {
log.error(t,t);
continue;
} catch (Throwable t){
log.error(t,t);
continue;
} }
} }
} }