Examples of XUpdateQueryService


Examples of org.xmldb.api.modules.XUpdateQueryService

    /* (non-Javadoc)
     * @see org.exist.xmldb.test.concurrent.Action#execute()
     */
    public boolean execute() throws Exception {
        Collection col = DatabaseManager.getCollection(collectionPath, "admin", null);
    XUpdateQueryService service = (XUpdateQueryService)
      col.getService("XUpdateQueryService", "1.0");
    XPathQueryService query = (XPathQueryService)
        col.getService("XPathQueryService", "1.0");
    append(service);
    query(query);
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

  /* (non-Javadoc)
   * @see org.exist.xmldb.test.concurrent.Action#execute()
   */
  public boolean execute() throws Exception {
    Collection col = DatabaseManager.getCollection(collectionPath, "admin", null);
    XUpdateQueryService service = (XUpdateQueryService)
      col.getService("XUpdateQueryService", "1.0");
   
    // append a new section
    long mods = service.update(APPEND);
    Assert.assertEquals(1, mods);
   
    // update paragraph content
    String updateText = Integer.toString(rand.nextInt()) + " & " + Integer.toString(rand.nextInt());
    String update = UPDATE_START + updateText + UPDATE_END;
    mods = service.update(update);
   
    Assert.assertEquals(1, mods);
    System.out.println(mods + " nodes updated.");
   
    // query for section
    XPathQueryService query = (XPathQueryService)
      col.getService("XPathQueryService", "1.0");
    ResourceSet result = query.query("/article/section/para/text()");
    Assert.assertEquals(1, result.getSize());
    updateText = result.getResource(0).getContent().toString();
    result = query.query("/article/section/para[. = '" + updateText + "']");
    Assert.assertEquals(1, result.getSize());
    System.out.println(result.getResource(0).getContent().toString());
   
    mods = service.update(REMOVE);
    Assert.assertEquals(1, mods);
    return false;
  }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

  /* (non-Javadoc)
   * @see org.exist.xmldb.test.concurrent.ConcurrentXUpdateTest.Action#execute()
   */
  public boolean execute() throws Exception {
    Collection col = DatabaseManager.getCollection(collectionPath, "admin", null);
    XUpdateQueryService service = (XUpdateQueryService)
      col.getService("XUpdateQueryService", "1.0");
    append(service);
        remove(service);
        return false;
  }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

  /* (non-Javadoc)
   * @see org.exist.xmldb.test.concurrent.Action#execute()
   */
  public boolean execute() throws Exception {
    Collection col = DatabaseManager.getCollection(collectionPath, "admin", null);
    XUpdateQueryService service = (XUpdateQueryService)
      col.getService("XUpdateQueryService", "1.0");
    int attrSize = rand.nextInt(5);
    for (int i = 0; i < 10; i++) {
      String xupdate = XUPDATE_START + xmlGenerator.generateText(attrSize) + XUPDATE_END;
      long mods = service.update(xupdate);
      System.out.println(Thread.currentThread().getName() + ": " + mods + " attributes updated ...");
    }
    return false;
  }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

                } else {
                    log( msg, Project.MSG_ERR );
                }

            } else {
                final XUpdateQueryService service = (XUpdateQueryService)base.getService( "XUpdateQueryService", "1.0" );

                if( resource != null ) {
                    log( "Updating resource: " + resource, Project.MSG_INFO );
                    final Resource res = base.getResource( resource );

                    if( res == null ) {
                        final String msg = "Resource " + resource + " not found.";

                        if( failonerror ) {
                            throw( new BuildException( msg ) );
                        } else {
                            log( msg, Project.MSG_ERR );
                        }
                    } else {
                        service.updateResource( resource, commands );
                    }

                } else {
                    log( "Updating collection: " + base.getName(), Project.MSG_INFO );
                    service.update( commands );
                }
            }

        }
        catch( final XMLDBException e ) {
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

        final XMLResource doc = (XMLResource) testCollection.createResource(DOCUMENT_NAME, "XMLResource" );
        doc.setContent(DOCUMENT_CONTENT);
        testCollection.storeResource(doc);

        //TODO : trigger UPDATE events !
        final XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
        update.updateResource(DOCUMENT_NAME, DOCUMENT_UPDATE);

        idxConf.configureCollection(EMPTY_COLLECTION_CONFIG);

        final XPathQueryService service = (XPathQueryService) testCollection
            .getService("XPathQueryService", "1.0");
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

            String xupdate =
                LuceneIndexTest.XUPDATE_START +
                "   <xu:remove select=\"//SPEECH[ft:query(SPEAKER, 'juliet')]\"/>" +
                LuceneIndexTest.XUPDATE_END;
            XUpdateQueryService xuqs = (XUpdateQueryService) test.getService("XUpdateQueryService", "1.0");
            xuqs.update(xupdate);

            result = xqs.query("//SPEECH[ft:query(SPEAKER, 'juliet')]");
            assertEquals(0, result.getSize());
            result = xqs.query("//SPEECH[ft:query(LINE, 'king')]");
            assertEquals(98, result.getSize());
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

//            System.out.println(result.getResource(0).getContent());
//        }
//    }
   
    public void testAppendRemove() throws Exception {
        XUpdateQueryService service = (XUpdateQueryService)
        testCol.getService("XUpdateQueryService", "1.0");
        XPathQueryService query = (XPathQueryService)
            testCol.getService("XPathQueryService", "1.0");
        for (int i = 1; i <= 100; i++) {
            append(service, i);
           
            ResourceSet result = query.query("/test/item[@id='" + i + "']");
            assertEquals(result.getSize(), 1);
            System.out.println(result.getResource(0).getContent());
        }
       
        for (int i = 100; i > 10; i--) {
            String xu =
                "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
                "   <xu:remove select=\"/test/item[@id='" + i + "']\"/>" +
                "</xu:modifications>";
            long mods = service.update(xu);
            assertEquals(mods, 1);
           
            ResourceSet result = query.query("/test/item/e0");
            System.out.println(result.getResource(0).getContent());
        }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

          Resource res = test2.createResource("test_xmldb.xml", "XMLResource");
          assertNotNull(res);
          res.setContent(TEST_XML);
          test2.storeResource(res);
       
          XUpdateQueryService service = (XUpdateQueryService)
              test2.getService("XUpdateQueryService", "1.0");
          assertNotNull(service);
       
          String xupdate;
       
          System.out.println("Inserting new items  ...");
          // insert some nodes
          for (int i = 1; i <= 200; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:insert-before select=\"/products/product[1]\">" +
                  "       <product>" +
                  "           <description>Product " + i + "</description>" +
                  "           <price>" + (i * 2.5) + "</price>" +
                  "           <stock>" + (i * 10) + "</stock>" +
                  "       </product>" +
                  "   </xu:insert-before>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
         
          System.out.println("Adding attributes  ...");
          // add attribute
          for (int i = 1; i <= 200; i++) {
            xupdate =
                "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                "   <xu:append select=\"/products/product[" + i + "]\">" +
                "         <xu:attribute name=\"id\">" + i + "</xu:attribute>" +
                " </xu:append>" +
                "</xu:modifications>";
            service.updateResource("test_xmldb.xml", xupdate);
        }
         
          System.out.println("Replacing elements  ...");
          // replace some
          for (int i = 1; i <= 100; i++) {
            xupdate =
                "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                "   <xu:replace select=\"/products/product[" + i + "]\">" +
                "     <product id=\"" + i + "\">" +
                "         <description>Replaced product</description>" +
                "         <price>" + (i * 0.75) + "</price>" +
                "     </product>" +
                " </xu:replace>" +
                "</xu:modifications>";
            service.updateResource("test_xmldb.xml", xupdate);
        }
             
          System.out.println("Removing some elements ...");
          // remove some
          for (int i = 1; i <= 100; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:remove select=\"/products/product[last()]\"/>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
         
          System.out.println("Appending some elements ...");
          for (int i = 1; i <= 100; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:append select=\"/products\">" +
                  "       <product>" +
                  "           <xu:attribute name=\"id\"><xu:value-of select=\"count(/products/product) + 1\"/></xu:attribute>" +
                  "           <description>Product " + i + "</description>" +
                  "           <price>" + (i * 2.5) + "</price>" +
                  "           <stock>" + (i * 10) + "</stock>" +
                  "       </product>" +
                  "   </xu:append>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
         
          System.out.println("Renaming elements  ...");
          // rename element "description" to "descript"
          xupdate =
              "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
              "   <xu:rename select=\"/products/product/description\">descript</xu:rename>" +
              "</xu:modifications>";
          service.updateResource("test_xmldb.xml", xupdate);
         
          System.out.println("Updating attribute values ...");
          // update attribute values
          for (int i = 1; i <= 200; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:update select=\"/products/product[" + i + "]/@id\">" + i + "u</xu:update>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
          System.out.println("Append new element to each item ...");
          // append new element to records
          for (int i = 1; i <= 200; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:append select=\"/products/product[" + i + "]\">" +
                  "       <date><xu:value-of select=\"current-dateTime()\"/></date>" +
                  "   </xu:append>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
         
          System.out.println("Updating element content ...");
          // update element content
          for (int i = 1; i <= 200; i++) {
              xupdate =
                  "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
                  "   <xu:update select=\"/products/product[" + i + "]/price\">19.99</xu:update>" +
                  "</xu:modifications>";
              service.updateResource("test_xmldb.xml", xupdate);
          }
        } catch (Exception e) {           
            fail(e.getMessage());  
        }         
    }
View Full Code Here

Examples of org.xmldb.api.modules.XUpdateQueryService

            e.printStackTrace();
        }
    }
   
    private void insertTags() throws Exception {
        XUpdateQueryService service = (XUpdateQueryService)
            testCol.getService("XUpdateQueryService", "1.0");
        XPathQueryService xquery = (XPathQueryService)
            testCol.getService("XPathQueryService", "1.0");
       
        String[] tagsWritten = new String[RUNS];
        for (int i = 0; i < RUNS; i++) {
            String tag = tags[i];
            String parent;
            if (i > 0 && rand.nextInt(100) < 70) {
                parent = "//" + tagsWritten[rand.nextInt(i) / 2];
            } else
                parent = "/root";
            String xupdate = "<xupdate:modifications version=\"1.0\" xmlns:xupdate=\"http://www.xmldb.org/xupdate\">" +
                "<xupdate:append select=\"" + parent + "\">" +
                "<xupdate:element name=\"" + tag + "\"/>" +
                "</xupdate:append>" +
                "</xupdate:modifications>";
           
            long mods = service.updateResource("test.xml", xupdate);
            System.out.println("Inserted " + tag + ": " + mods + " ; parent = " + parent);
            assertEquals(mods, 1);
           
            tagsWritten[i] = tag;
            String query = "//" + tagsWritten[rand.nextInt(i + 1)];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.