org.apache.jackrabbit.oak.api.Root.commit()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.apache.jackrabbit.oak.api.Root.commit方法的一些代码示例,展示了Root.commit的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Root.commit方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.api.Root
类名称:Root
方法名:commit

Root.commit介绍

[英]Atomically persists all changes made to the tree attached to this root. Calling this method is equivalent to calling the #commit(Map info) method with an empty info map.
[中]原子化地保存对附加到此根的树所做的所有更改。调用此方法相当于使用空的信息映射调用#commit(Map info)方法。

代码示例

代码示例来源:origin: apache/jackrabbit-oak

private static void setup(Root root) throws Exception {
  Tree tree = root.getTree("/");
  tree.addChild("c").setProperty("p", "base");
  root.commit();
}

代码示例来源:origin: apache/jackrabbit-oak

@Test(expected = CommitFailedException.class)
public void oakIndexableFailing() throws IOException, CommitFailedException {
  registerNodeType(root, "oak3725-1.cnd");
  
  Tree test = root.getTree("/").addChild("test");
  test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME);            
  test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
  root.commit();
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void orderByScore() throws Exception {
  Tree idx = createIndex("test1", of("propa"));
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("propa", "a");
  root.commit();
  assertQuery("select [jcr:path] from [nt:base] where propa is not null order by [jcr:score]", asList("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void indexDefinitionBelowRoot3() throws Exception {
  Tree parent = root.getTree("/").addChild("test");
  Tree idx = createIndex(parent, "test1", of("propa"));
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  parent.setProperty("propa", "a");
  parent.addChild("test1").setProperty("propa", "a");
  root.commit();
  //asert that (1) result gets returned correctly, (2) parent isn't there, and (3) child is returned
  assertQuery("select [jcr:path] from [nt:base] as s where ISDESCENDANTNODE(s, '/test') and propa = 'a'", asList("/test/test1"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void containsPath() throws Exception {
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("name", "/parent/child/node");
  root.commit();
  assertQuery("//*[jcr:contains(., '/parent/child')]", "xpath", ImmutableList.of("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testWithRelativeProperty() throws Exception{
  Tree parent = root.getTree("/");
  Tree idx = createIndex(parent, "test1", of("b/propa", "propb"));
  root.commit();
  Tree test = parent.addChild("test2");
  test.addChild("a").addChild("b").setProperty("propa", "a");
  root.commit();
  assertQuery("select [jcr:path] from [nt:base] as s where [b/propa] = 'a'", asList("/test2/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void indexDefinitionBelowRoot() throws Exception {
  Tree parent = root.getTree("/").addChild("test");
  Tree idx = createIndex(parent, "test1", of("propa", "propb"));
  idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true);
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  Tree test = parent.addChild("test2");
  test.addChild("a").setProperty("propa", "a");
  root.commit();
  assertQuery("select [jcr:path] from [nt:base] as s where ISDESCENDANTNODE(s, '/test') and propa = 'a'", asList("/test/test2/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testMultiAndEquals() throws Exception {
  Tree c = root.getTree("/").addChild("content");
  c.addChild("one").setProperty("prop", "aaa");
  c.addChild("two").setProperty("prop",
      ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS);
  c.addChild("three").setProperty("prop", ImmutableList.of("aaa", "bbb"),
      Type.STRINGS);
  root.commit();
  assertQuery("//*[(@prop = 'aaa' and @prop = 'bbb' and @prop = 'ccc')]",
      "xpath", ImmutableList.of("/content/two"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testMultiNotEqual() throws Exception {
  Tree c = root.getTree("/").addChild("content");
  c.addChild("one").setProperty("prop", "value");
  c.addChild("two").setProperty("prop",
      ImmutableList.of("aaa", "value", "bbb"), Type.STRINGS);
  c.addChild("three").setProperty("prop",
      ImmutableList.of("aaa", "bbb", "ccc"), Type.STRINGS);
  root.commit();
  assertQuery("//*[@prop != 'value']", "xpath",
      ImmutableList.of("/content/two", "/content/three"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void propertyExistenceQuery() throws Exception {
  Tree idx = createIndex("test1", of("propa", "propb"));
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("propa", "a");
  test.addChild("b").setProperty("propa", "c");
  test.addChild("c").setProperty("propb", "e");
  root.commit();
  assertQuery("select [jcr:path] from [nt:base] where propa is not null", asList("/test/a", "/test/b"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void containsPath() throws Exception {
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("name", "/parent/child/node");
  root.commit();
  StringBuffer stmt = new StringBuffer();
  stmt.append("//*[jcr:contains(., '/parent/child')]");
  assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void explainScoreTest() throws Exception {
  Tree idx = createIndex("test1", of("propa"));
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("propa", "a");
  root.commit();
  String query = "select [oak:scoreExplanation] from [nt:base] where propa='a'";
  List<String> result = executeQuery(query, SQL2, false, false);
  assertEquals(1, result.size());
  assertTrue(result.get(0).contains("(MATCH)"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void oakIndexableSuccessful() throws IOException, CommitFailedException {
  registerNodeType(root, "oak3725-2.cnd");
  
  Tree test = root.getTree("/").addChild("test");
  test.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, NAME);
  test.setProperty(JCR_MIXINTYPES, of(MIX_INDEXABLE), Type.NAMES);
  test.addChild("oak:index").setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
  root.commit();
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testMultiAndLike() throws Exception {
  Tree c = root.getTree("/").addChild("content");
  c.addChild("one").setProperty("prop", "aaaBoom");
  c.addChild("two").setProperty("prop",
      ImmutableList.of("aaaBoom", "bbbBoom", "cccBoom"), Type.STRINGS);
  c.addChild("three").setProperty("prop", ImmutableList.of("aaaBoom", "bbbBoom"),
      Type.STRINGS);
  root.commit();
  assertQuery("//*[(jcr:like(@prop, 'aaa%') and jcr:like(@prop, 'bbb%') and jcr:like(@prop, 'ccc%'))]",
      "xpath", ImmutableList.of("/content/two"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testLowercaseOnArrays() throws Exception {
  // OAK-1829
  Tree content = root.getTree("/").addChild("content");
  content.setProperty("array", Arrays.asList("X", "Y"), Type.STRINGS);
  root.commit();
  assertQuery("//*[jcr:like(fn:lower-case(@array), '%x%')]", "xpath",
      Arrays.asList("/content"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void containsPathNum() throws Exception {
  Tree test = root.getTree("/").addChild("test");
  Tree a = test.addChild("a");
  a.setProperty("name", "/segment1/segment2/segment3");
  root.commit();
  StringBuffer stmt = new StringBuffer();
  stmt.append("//*[jcr:contains(., '/segment1/segment2')]");
  assertQuery(stmt.toString(), "xpath", ImmutableList.of("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void multiPhraseQuery() throws Exception {
  Tree test = root.getTree("/").addChild("test");
  test.addChild("a").setProperty("dc:format", "type:application/pdf");
  root.commit();
  assertQuery(
      "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]",
      "xpath", ImmutableList.of("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void containsPathNum() throws Exception {
  Tree test = root.getTree("/").addChild("test");
  Tree a = test.addChild("a");
  a.setProperty("name", "/segment1/segment2/segment3");
  root.commit();
  assertQuery("//*[jcr:contains(., '/segment1/segment2')]", "xpath", ImmutableList.of("/test/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void indexDefinitionBelowRoot2() throws Exception {
  Tree parent = root.getTree("/").addChild("test");
  Tree idx = createIndex(parent, "test1", of("propa", "propb"));
  idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true);
  idx.addChild(PROP_NODE).addChild("propa");
  root.commit();
  Tree test = parent.addChild("test2").addChild("test3");
  test.addChild("a").setProperty("propa", "a");
  root.commit();
  assertQuery("select [jcr:path] from [nt:base] as s where ISDESCENDANTNODE(s, '/test/test2') and propa = 'a'",
      asList("/test/test2/test3/a"));
}

代码示例来源:origin: apache/jackrabbit-oak

@Test
public void testAddExistingNode() throws CommitFailedException {
  theirRoot.getTree("/").addChild("n").setProperty("p", THEIR_VALUE);
  ourRoot.getTree("/").addChild("n").setProperty("p", OUR_VALUE);
  theirRoot.commit();
  ourRoot.commit();
  Tree n = ourRoot.getTree("/n");
  assertTrue(n.exists());
  assertEquals(OUR_VALUE, n.getProperty("p").getValue(STRING));
}

相关文章