本文整理了Java中org.apache.jackrabbit.oak.api.Tree.setOrderableChildren()
方法的一些代码示例,展示了Tree.setOrderableChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.setOrderableChildren()
方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.api.Tree
类名称:Tree
方法名:setOrderableChildren
[英]Changes the nature of this tree such that the order of the children is kept stable. The expected behavior is as follows:
Calling #orderBefore(String) on a tree, implicitly enables orderable children on the parent tree.
[中]改变了这棵树的性质,使孩子们的秩序保持稳定。预期的行为如下所示:
1.第一次在树上调用setOrderableChildren(true)将稳定现有子级的顺序。任何后续的#addChild(String)调用都保证插入新树和子列表的末尾。
1.在已对其子级进行排序的树上调用setOrderableChildren(true)无效。
1.在没有已排序子级的树上调用setOrderableChildren(false)无效
1.在具有有序子级的树上调用setOrderableChildren(false)将消除保持子级列表稳定的必要性。#getChildren()上的子项顺序随后未定义。
在树上调用#orderBefore(String)会隐式启用父树上的可排序子树。
代码示例来源:origin: apache/jackrabbit-oak
/**
* Enables or disabled orderable children on the underlying tree.
*
* @param enable whether to enable or disable orderable children.
*/
public void setOrderableChildren(boolean enable)
throws InvalidItemStateException {
getTree().setOrderableChildren(enable);
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
/**
* Enables or disabled orderable children on the underlying tree.
*
* @param enable whether to enable or disable orderable children.
*/
public void setOrderableChildren(boolean enable)
throws InvalidItemStateException {
getTree().setOrderableChildren(enable);
}
代码示例来源:origin: org.apache.jackrabbit/oak-jcr
/**
* Enables or disabled orderable children on the underlying tree.
*
* @param enable whether to enable or disable orderable children.
*/
public void setOrderableChildren(boolean enable)
throws InvalidItemStateException {
getTree().setOrderableChildren(enable);
}
代码示例来源:origin: apache/jackrabbit-oak
private static Tree getOrCreateChild(Tree tree, String name){
if (tree.hasChild(name)){
return tree.getChild(name);
}
Tree child = tree.addChild(name);
child.setOrderableChildren(true);
child.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
return child;
}
代码示例来源:origin: apache/jackrabbit-oak
public static Tree newRulePropTree(Tree indexDefn, String typeName) {
Tree rules = indexDefn.addChild(FulltextIndexConstants.INDEX_RULES);
rules.setOrderableChildren(true);
Tree rule = rules.addChild(typeName);
Tree props = rule.addChild(FulltextIndexConstants.PROP_NODE);
props.setOrderableChildren(true);
return props;
}
代码示例来源:origin: org.apache.jackrabbit/oak-lucene
private static Tree getOrCreateChild(Tree tree, String name){
if (tree.hasChild(name)){
return tree.getChild(name);
}
Tree child = tree.addChild(name);
child.setOrderableChildren(true);
child.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
return child;
}
代码示例来源:origin: apache/jackrabbit-oak
private static Tree getOrCreateChild(Tree tree, String name){
if (tree.hasChild(name)){
return tree.getChild(name);
}
Tree child = tree.addChild(name);
child.setOrderableChildren(true);
child.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME);
return child;
}
代码示例来源:origin: apache/jackrabbit-oak
public static Tree newRulePropTree(Tree indexDefn, String typeName){
Tree rules = indexDefn.addChild(FulltextIndexConstants.INDEX_RULES);
rules.setOrderableChildren(true);
Tree rule = rules.addChild(typeName);
Tree props = rule.addChild(FulltextIndexConstants.PROP_NODE);
props.setOrderableChildren(true);
return props;
}
代码示例来源:origin: apache/jackrabbit-oak
private Tree addUnstructuredChild(Tree tree, String name){
Tree child = tree.addChild(name);
child.setOrderableChildren(true);
child.setProperty("jcr:primaryType", "nt:unstructured", Type.NAME);
return child;
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testSetOrderableChildNodesOnHiddenTree() {
try {
Tree hidden = parent.getChild(HIDDEN_NAME);
hidden.setOrderableChildren(true);
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
// success
}
try {
Tree hidden = parent.getChild(HIDDEN_NAME);
hidden.setOrderableChildren(false);
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit-oak
public static void copyToTree(NodeState state, Tree tree){
tree.setOrderableChildren(state.hasProperty(OAK_CHILD_ORDER));
copyProps(state, tree);
Tree src = TreeFactory.createReadOnlyTree(state);
for (Tree srcChild : src.getChildren()){
String childName = srcChild.getName();
Tree child = tree.addChild(childName);
copyToTree(state.getChildNode(childName), child);
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
@Before
public void before() throws Exception {
super.before();
Tree a = root.getTree("/a");
a.setOrderableChildren(true);
root.commit();
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testSetOrderableChildrenSetsProperty() throws Exception {
Tree tree = root.getTree("/").addChild("test");
tree.setOrderableChildren(true);
assertTrue(((MutableTree) tree).getNodeState().hasProperty(TreeConstants.OAK_CHILD_ORDER));
tree.setOrderableChildren(false);
assertFalse(((MutableTree) tree).getNodeState().hasProperty(TreeConstants.OAK_CHILD_ORDER));
tree.setOrderableChildren(true);
root.commit();
assertTrue(((MutableTree) tree).getNodeState().hasProperty(TreeConstants.OAK_CHILD_ORDER));
tree.setOrderableChildren(false);
root.commit();
assertFalse(((MutableTree) tree).getNodeState().hasProperty(TreeConstants.OAK_CHILD_ORDER));
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void initialize(final NodeBuilder builder) {
if (!isAlreadyThere(builder)) {
Tree t = TreeFactory.createTree(builder.child(INDEX_DEFINITIONS_NAME));
t = t.addChild(name);
t.setProperty("jcr:primaryType", INDEX_DEFINITIONS_NODE_TYPE, NAME);
t.setProperty(COMPAT_MODE, 2L, LONG);
t.setProperty(TYPE_PROPERTY_NAME, TYPE_LUCENE, STRING);
t.setProperty(ASYNC_PROPERTY_NAME, "async", STRING);
t.setProperty(REINDEX_PROPERTY_NAME, true);
t = t.addChild(INDEX_RULES);
t.setOrderableChildren(true);
t.setProperty("jcr:primaryType", "nt:unstructured", NAME);
t = t.addChild("nt:base");
Tree propnode = t.addChild(PROP_NODE);
propnode.setOrderableChildren(true);
propnode.setProperty("jcr:primaryType", "nt:unstructured", NAME);
for (String p : properties) {
Tree t1 = propnode.addChild(PathUtils.getName(p));
t1.setProperty(PROP_PROPERTY_INDEX, true, BOOLEAN);
t1.setProperty(PROP_NAME, p);
}
}
}
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* @see <a href="https://issues.apache.org/jira/browse/OAK-842">OAK-842</a>
*/
@Test
public void testOrderableChildren() throws Exception {
Tree a = root.getTree("/a");
a.setOrderableChildren(true);
testRoot.refresh();
for (Tree t : testRoot.getTree("/a").getChildren()) {
if (!"b".equals(t.getName())) {
fail("Child " + t.getName() + " should not be accessible.");
}
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testSetOrderableChildren() throws Exception {
Tree tree = root.getTree("/").addChild("test2");
tree.setOrderableChildren(true);
String[] childNames = new String[]{"a", "b", "c", "d"};
for (String name : childNames) {
tree.addChild(name);
}
int index = 0;
for (Tree child : tree.getChildren()) {
assertEquals(childNames[index++], child.getName());
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testChildOrderWithoutPropertyReadAccess() throws Exception {
root.getTree("/a").setOrderableChildren(true);
root.getTree("/a/bb").orderBefore("b");
root.commit();
setupPermission("/", testPrincipal, true, PrivilegeConstants.REP_READ_NODES);
Root testRoot = getTestRoot();
Tree aTree = testRoot.getTree("/a");
// verify that properties cannot be read:
assertFalse(aTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE));
List<String> expected = ImmutableList.of("/a/bb", "/a/b");
Iterable<String> childPaths = Iterables.transform(aTree.getChildren(), new Function<Tree, String>() {
@Nullable
@Override
public String apply(Tree input) {
return input.getPath();
}
});
assertTrue(childPaths.toString(), Iterables.elementsEqual(expected, childPaths));
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void copyOrdered() throws Exception{
NodeBuilder testBuilder = EMPTY_NODE.builder();
Tree srcTree = TreeFactory.createTree(testBuilder);
srcTree.setOrderableChildren(true);
srcTree.setProperty("foo", "x");
srcTree.addChild("a").setOrderableChildren(true);
srcTree.addChild("a").setProperty("foo", "y");
srcTree.addChild("b").setOrderableChildren(true);
srcTree.addChild("b").setProperty("foo", "z");
Tree tree = TreeFactory.createTree(EMPTY_NODE.builder());
NodeStateCopyUtils.copyToTree(testBuilder.getNodeState(), tree);
assertEquals("x", tree.getProperty("foo").getValue(Type.STRING));
assertEquals(2, tree.getChildrenCount(100));
assertEquals("y", tree.getChild("a").getProperty("foo").getValue(Type.STRING));
assertEquals("z", tree.getChild("b").getProperty("foo").getValue(Type.STRING));
//Assert the order
Iterator<Tree> children = tree.getChildren().iterator();
assertEquals("a", children.next().getName());
assertEquals("b", children.next().getName());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void newIndexAndOrderableChildren() throws Exception{
String json = "{\"/oak:index/barIndex\": {\n" +
" \"compatVersion\": 2,\n" +
" \"type\": \"lucene\",\n" +
" \"barIndexProp\": \"barbar\",\n" +
" \"async\": \"async\",\n" +
" \"jcr:primaryType\": \"oak:QueryIndexDefinition\"\n" +
" }}";
NodeBuilder builder = store.getRoot().builder();
Tree root = TreeFactory.createTree(builder);
Tree oakIndex = root.addChild("oak:index");
oakIndex.setOrderableChildren(true);
Tree fooIndex = oakIndex.addChild("fooIndex");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
IndexDefinitionUpdater updater = new IndexDefinitionUpdater(json);
builder = store.getRoot().builder();
NodeBuilder idxBuilder = updater.apply(builder, "/oak:index/barIndex");
PropertyState childOrder = builder.getChildNode("oak:index").getProperty(":childOrder");
List<String> names = ImmutableList.copyOf(childOrder.getValue(Type.NAMES));
assertEquals(asList("fooIndex", "barIndex"), names);
}
代码示例来源:origin: apache/jackrabbit-oak
@Before
public void setUp() throws Exception {
Tree tree = root.getTree("/");
NodeUtil node = new NodeUtil(tree);
node.addChild("x", JcrConstants.NT_UNSTRUCTURED).addChild("y", JcrConstants.NT_UNSTRUCTURED).addChild("z", JcrConstants.NT_UNSTRUCTURED);
Tree orderable = node.addChild("orderable", JcrConstants.NT_UNSTRUCTURED).getTree();
orderable.setOrderableChildren(true);
root.commit();
immutable = new ImmutableTree(((AbstractTree) root.getTree("/")).getNodeState());
}
内容来源于网络,如有侵权,请联系作者删除!