Пример #1
0
 @Override
 protected void execute(
     final @NonNull KernelHttpRequest request, final @NonNull KernelHttpResponse response) {
   if (!request.isPrivileged()) throw new AdminAccessException();
   final String queryType = request.getParameter("queryType");
   final PrintWriter writer = response.getWriter();
   writer.print("[");
   try {
     final ValidatingKernel kernel = getKernel();
     final BeginTransactionResult btr = kernel.beginTransaction();
     final NodesTransaction txn = btr.getTxn();
     boolean commit = false;
     try {
       final Processor processor = processors.get(queryType);
       if (processor == null) writer.println("Query type '" + queryType + "' not found");
       else processor.process(txn, request, writer);
       commit = true;
     } finally {
       txn.finish(commit);
     }
     writer.print("]");
   } finally {
     writer.close();
   }
 }
Пример #2
0
 @Override
 public void execute() {
   final BeginTransactionResult btr = kernel.beginTransaction();
   final NodesTransaction txn = btr.getTxn();
   boolean commit = false;
   try {
     txn.deleteLink(linkNodeId, wordParentMeaningNodeId);
     txn.deleteLink(linkNodeId, wordMeaningNodeId);
     txn.deleteNodeRecursively(linkNodeId);
     commit = true;
   } finally {
     txn.finish(commit);
   }
 }
Пример #3
0
 @Override
 public void execute() {
   final WordIndexContextProvider wicp = wicpReactor.getInstance();
   // add new link and possibly word
   final NodeId contextNodeId = wicp.getWordIndexContext();
   final NodeKey nodeKey = new NamedNodeKey(contextNodeId, word);
   //
   final Coordinator coordinator = coordReactor.getInstance();
   final Reservation reservation =
       coordinator.reserve(
           CoordinatorUtil.makeSetOfRules(new BaseKeyRule(nodeKey)),
           CoordinatorUtil.makeSetOfIntents(new BaseKeyIntent(nodeKey)));
   try {
     final BeginTransactionResult btr = kernel.beginTransaction();
     final NodesTransaction txn = btr.getTxn();
     boolean commit = false;
     try {
       NodeId wordNodeId = txn.getNode(nodeKey);
       if (wordNodeId == null) {
         // TODO use unique datum?
         wordNodeId = txn.insertNode(new StringDatum(word));
         txn.insertKey(nodeKey, wordNodeId, false);
         txn.dereference(wordNodeId);
       }
       final NodeId linkNodeId = txn.insertNode();
       txn.insertLink(linkNodeId, nodeBeingIndexed, wordParentMeaningNodeId, false);
       txn.insertLink(linkNodeId, wordNodeId, wordMeaningNodeId, false);
       txn.dereference(linkNodeId);
       commit = true;
     } finally {
       txn.finish(commit);
     }
   } finally {
     reservation.release();
   }
 }