NIHVIVO-2049 fix so classes, classgroups, etc. don't get indexed

This commit is contained in:
bjl23 2011-02-07 15:37:56 +00:00
parent b28fa05ffd
commit 3ad00d0ace
3 changed files with 30 additions and 7 deletions

View file

@ -47,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
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.servlet.setup.JenaDataSourceSetupBase;
public class IndividualDaoSDB extends IndividualDaoJena {
@ -333,8 +334,11 @@ public class IndividualDaoSDB extends IndividualDaoJena {
final List<String> list =
new LinkedList<String>();
// get all labeled resources from any non-tbox and non-metadata graphs.
String query = "SELECT DISTINCT ?ind WHERE { \n" +
" GRAPH ?g { ?ind <" + RDFS.label.getURI() + "> ?label } \n" +
" FILTER (?g != <" + JenaDataSourceSetupBase.JENA_APPLICATION_METADATA_MODEL + "> " +
" && !regex(str(?g),\"tbox\")) \n " +
"}";
Query q = QueryFactory.create(query);

View file

@ -110,7 +110,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
// This model doesn't exist yet. It's a placeholder for the application
// ontology.
static final String JENA_APPLICATION_METADATA_MODEL =
public static final String JENA_APPLICATION_METADATA_MODEL =
"http://vitro.mannlib.cornell.edu/default/vitro-kb-applicationMetadata";
// This is Brian C's application.owl file. We may not have to be concerned

View file

@ -36,6 +36,7 @@ import com.hp.hpl.jena.sdb.StoreDesc;
import com.hp.hpl.jena.sdb.sql.SDBConnection;
import com.hp.hpl.jena.sdb.store.DatabaseType;
import com.hp.hpl.jena.sdb.store.LayoutType;
import com.hp.hpl.jena.sdb.util.StoreUtils;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.RDF;
@ -317,6 +318,19 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
} catch (MigrationRequiredError mre) {
throw new MigrationRequiredError(mre.getMessage());
} catch (SQLException sqle) {
// SQL exceptions are fatal and should halt startup
AbortStartup.abortStartup(sce.getServletContext());
log.error("Error using SQL database; startup aborted.", sqle);
// print to catalina.out for good measure
System.out.println("Error using SQL database; startup aborted.");
sqle.printStackTrace();
throw new Error(this.getClass().getName() + "failed");
} catch (Throwable t) {
log.error("Throwable in " + this.getClass().getName(), t);
// printing the error because Tomcat doesn't print context listener
@ -616,6 +630,10 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
log.info("During initial SDB setup, created an application metadata model of size "
+ applicationMetadataModel.size());
// remove application metadata from ABox model
aboxAssertions.remove(applicationMetadataModel);
aboxInferences.remove(applicationMetadataModel);
// Make sure the reasoner takes into account the newly-set-up data.
SimpleReasonerSetup.setRecomputeRequired(ctx);
@ -631,12 +649,13 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
* @param store
* @return
*/
private boolean isSetUp(Store store) {
try {
return (SDBFactory.connectNamedModel(store, JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL)).size() > 0;
} catch (Exception e) {
return false;
}
private boolean isSetUp(Store store) throws SQLException {
return StoreUtils.isFormatted(store);
// try {
// return (SDBFactory.connectNamedModel(store, JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL)).size() > 0;
// } catch (Exception e) {
// return false;
// }
}
private static final String STOREDESC_ATTR = "storeDesc";