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,48 +97,46 @@ 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.setObjectURI(((Resource)st.getObject()).getURI());
objPropertyStmt.setPropertyURI(st.getPredicate().getURI());
try {
Property prop = st.getPredicate();
if( uriToObjectProperty.containsKey(prop.getURI())){
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
}else{
ObjectProperty p = getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURI(prop.getURI());
if( p != null ){
uriToObjectProperty.put(prop.getURI(), p);
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
}else{
//if ObjectProperty not found in ontology, skip it
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;
}
Property prop = st.getPredicate();
if( uriToObjectProperty.containsKey(prop.getURI())){
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
}else{
ObjectProperty p = getWebappDaoFactory().getObjectPropertyDao().getObjectPropertyByURI(prop.getURI());
if( p != null ){
uriToObjectProperty.put(prop.getURI(), p);
objPropertyStmt.setProperty(uriToObjectProperty.get(prop.getURI()));
}else{
//if ObjectProperty not found in ontology, skip it
continue;
}
}
if (objPropertyStmt.getObjectURI() != null) {
Individual objInd = new IndividualSDB(
objPropertyStmt.getObjectURI(),
this.dwf,
datasetMode,
getWebappDaoFactory());
objPropertyStmt.setObject(objInd);
//this might throw IndividualNotFoundException
Individual objInd = new IndividualSDB(
objPropertyStmt.getObjectURI(),
this.dwf,
datasetMode,
getWebappDaoFactory());
objPropertyStmt.setObject(objInd);
}
//add object property statement to list for Individual
if ((objPropertyStmt.getSubjectURI() != null)
&& (objPropertyStmt.getPropertyURI() != null)
&& (objPropertyStmt.getObject() != null)){
//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 (Throwable t) {
t.printStackTrace();
} catch (IndividualNotFoundException t) {
log.error(t,t);
continue;
} catch (Throwable t){
log.error(t,t);
continue;
}
}
}