コード例 #1
0
 /*
  * Reset the underlying JDBC database tables
  */
 private Pair<Long, URI> resetDatabaseTables(
     NodeCentricOperationContext connectionContext, boolean hardReset) throws AnzoException {
   try {
     dropTables(connectionContext, hardReset);
     datasource.begin(connectionContext.getConnection(), true, true);
     Long ts = Long.valueOf(0);
     LastTransactionTime.insertFirstTransactionTime(
         connectionContext.getStatementProvider(), connectionContext.getConnection(), ts);
     URI serverUri = UriGenerator.generateServerIdURI();
     Long serverId =
         connectionContext.getNodeLayout().store(serverUri, connectionContext.getConnection(), 1);
     ServerRdbWrapper.setServerId(
         connectionContext.getStatementProvider(), connectionContext.getConnection(), serverId);
     connectionContext
         .getNodeLayout()
         .store(Constants.EVERYONE_ROLE, connectionContext.getConnection(), 1);
     datasource.commit(connectionContext.getConnection(), true, true);
     connectionContext.getNodeLayout().commitReferencedIds(connectionContext.getConnection(), 1);
     return new Pair<Long, URI>(serverId, serverUri);
   } catch (Exception e) {
     log.error(LogUtils.RDB_MARKER, "SQL Error resetting database tables", e);
     datasource.abort(connectionContext.getConnection(), true, true);
     throw new AnzoException(ExceptionConstants.RDB.OPERATION_ERROR, e, e.getMessage());
   }
 }
コード例 #2
0
 void handleStatement(boolean addition, Long graphId, Long subj, Long prop, Long obj)
     throws AnzoException {
   URI graphNode = getValue(graphId);
   Resource subjNode = getValue(subj);
   URI propNode = getValue(prop);
   Value objNode = getValue(obj);
   URI ngURI = graphNode;
   boolean meta = false;
   if (UriGenerator.isMetadataGraphUri(ngURI)) {
     ngURI = UriGenerator.stripEncapsulatedURI(NAMESPACES.METADATAGRAPH_PREFIX, ngURI);
     meta = true;
   }
   NamedGraphRevision ngr = ngs.get(ngURI);
   if (ngr == null) {
     throw new AnzoException(
         ExceptionConstants.DATASOURCE.NAMEDGRAPH.REVISION_NOT_FOUND, "?", ngURI.toString());
   }
   if (meta
       && (!ngr.readMeta
           && !(ngr.readGraph && subjNode.equals(ngURI) && isSpecialMeta(propNode)))) {
     return;
   } else if (!meta && !ngr.readGraph) {
     return;
   }
   if (lastNGRevision == null || !lastNGRevision.namedGraphUri.equals(ngURI)) {
     handler.handleNamedGraph(ngr.namedGraphUri, ngr.uuid, ngr.revision);
     lastNGRevision = ngr;
     if (newGraph.get(ngURI) && lastNGRevision.cache == null) {
       lastNGRevision.cache = new ArrayList<Statement>();
     }
   }
   handler.handleStatement(meta, addition, subjNode, propNode, objNode, graphNode);
   if (addition && lastNGRevision.cache != null) {
     lastNGRevision.cache.add(
         Constants.valueFactory.createStatement(subjNode, propNode, objNode, graphNode));
   }
 }