Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.CoreValue


        RootImpl root = createRootImpl(null);
        Tree tree = root.getTree("/");

        assertEquals(3, tree.getPropertyCount());

        CoreValue value = valueFactory.createValue("foo");
        tree.setProperty("a", value);
        assertEquals(3, tree.getPropertyCount());

        tree.removeProperty("a");
        assertEquals(2, tree.getPropertyCount());
View Full Code Here


    @Test
    public void propertyStatus() throws CommitFailedException {
        RootImpl root = createRootImpl(null);
        Tree tree = root.getTree("/");
        CoreValue value1 = valueFactory.createValue("V1");
        CoreValue value2 = valueFactory.createValue("V2");

        tree.setProperty("new", value1);
        assertEquals(Tree.Status.NEW, tree.getPropertyStatus("new"));
        root.commit(DefaultConflictHandler.OURS);
View Full Code Here

        NodeBuilder testBuilder = rootBuilder.getChildBuilder("test");
        NodeBuilder newNodeBuilder = testBuilder.getChildBuilder("newNode");

        testBuilder.removeNode("x");

        CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        // Assert changes are present in the builder
        NodeState testState = rootBuilder.getNodeState().getChildNode("test");
        assertNotNull(testState.getChildNode("newNode"));
View Full Code Here

        NodeState root = store.getRoot();
        NodeBuilder rootBuilder= store.getBuilder(root);
        NodeBuilder testBuilder = rootBuilder.getChildBuilder("test");
        NodeBuilder newNodeBuilder = testBuilder.getChildBuilder("newNode");

        CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        testBuilder.removeNode("a");

        NodeState newRoot = rootBuilder.getNodeState();
View Full Code Here

        NodeState root = store.getRoot();
        NodeBuilder rootBuilder = store.getBuilder(root);
        NodeBuilder testBuilder = rootBuilder.getChildBuilder("test");
        NodeBuilder newNodeBuilder = testBuilder.getChildBuilder("newNode");

        final CoreValue fortyTwo = store.getValueFactory().createValue(42);
        newNodeBuilder.setProperty("n", fortyTwo);

        testBuilder.removeNode("a");

        NodeState newRoot = rootBuilder.getNodeState();
View Full Code Here

    }

    private Operation createAddProperty() {
        String parent = chooseNodePath();
        String name = createPropertyName();
        CoreValue value = createValue();
        return new SetProperty(parent, name, value);
    }
View Full Code Here

    private Operation createSetProperty() {
        String path = choosePropertyPath();
        if (path == null) {
            return null;
        }
        CoreValue value = createValue();
        return new SetProperty(PathUtils.getParentPath(path), PathUtils.getName(path), value);
    }
View Full Code Here

        String uuid = UUID.randomUUID().toString();
        singleValueMap.put(valueFactory.createValue(uuid, PropertyType.REFERENCE), "\"ref:" +uuid+ '\"');
        singleValueMap.put(valueFactory.createValue(uuid, PropertyType.WEAKREFERENCE), "\"wea:" +uuid+ '\"');

        CoreValue binary = valueFactory.createValue(new ByteArrayInputStream("123".getBytes()));
        singleValueMap.put(binary, "\"bin:"+ binary.getString()+ '\"');

        // multi valued properties
        mvValueMap = new HashMap<String, List<CoreValue>>();
        mvValueMap.put("[]", Collections.<CoreValue>emptyList());

        List<CoreValue> strValues = new ArrayList<CoreValue>();
        strValues.add(valueFactory.createValue("abc"));
        strValues.add(valueFactory.createValue("a:bc"));
        strValues.add(valueFactory.createValue("boo:abc"));
        strValues.add(valueFactory.createValue("str:abc"));
        strValues.add(valueFactory.createValue("str:"));
        mvValueMap.put("[\"abc\",\"a:bc\",\"str:boo:abc\",\"str:str:abc\",\"str:str:\"]", strValues);

        List<CoreValue> boValues = new ArrayList<CoreValue>();
        boValues.add(valueFactory.createValue(true));
        boValues.add(valueFactory.createValue(false));
        mvValueMap.put("[true,false]", boValues);

        List<CoreValue> longs = new ArrayList<CoreValue>();
        longs.add(valueFactory.createValue(1));
        longs.add(valueFactory.createValue(2));
        longs.add(valueFactory.createValue(3));
        mvValueMap.put("[1,2,3]", longs);

        List<CoreValue> doubles = new ArrayList<CoreValue>();
        doubles.add(valueFactory.createValue(1.23));
        mvValueMap.put("[\"dou:1.23\"]", doubles);

        List<CoreValue> decimals = new ArrayList<CoreValue>();
        decimals.add(valueFactory.createValue(decimal));
        decimals.add(valueFactory.createValue(decimal));
        mvValueMap.put("[\"dec:" + decimal.toString() + "\",\"dec:" + decimal.toString() + "\"]", decimals);

        List<CoreValue> dates = Collections.singletonList(valueFactory.createValue("2012-05-01T12:00.000:00GMT", PropertyType.DATE));
        mvValueMap.put("[\"dat:2012-05-01T12:00.000:00GMT\"]", dates);

        List<CoreValue> names = Collections.singletonList(valueFactory.createValue("jcr:primaryType", PropertyType.NAME));
        mvValueMap.put("[\"nam:jcr:primaryType\"]", names);

        List<CoreValue> paths = new ArrayList<CoreValue>();
        paths.add(valueFactory.createValue("/jcr:system", PropertyType.PATH));
        paths.add(valueFactory.createValue("../../content", PropertyType.PATH));
        mvValueMap.put("[\"pat:/jcr:system\",\"pat:../../content\"]", paths);

        List<CoreValue> uris = Collections.singletonList(valueFactory.createValue("http://jackrabbit.apache.org", PropertyType.URI));
        mvValueMap.put("[\"uri:http://jackrabbit.apache.org\"]", uris);

        List<CoreValue> refs = new ArrayList<CoreValue>();
        refs.add(valueFactory.createValue(uuid, PropertyType.REFERENCE));
        mvValueMap.put("[\"ref:" +uuid+ "\"]", refs);

        List<CoreValue> wr = new ArrayList<CoreValue>();
        wr.add(valueFactory.createValue(uuid, PropertyType.WEAKREFERENCE));
        mvValueMap.put("[\"wea:" +uuid+ "\"]", wr);

        mvValueMap.put("[\"bin:"+ binary.getString()+ "\"]", Collections.singletonList(binary));
    }
View Full Code Here

                    return null;
                } else {
                    int targetType = getTargetType(value, type);
                    Value targetValue =
                            ValueHelper.convert(value, targetType, getValueFactory());
                    CoreValue oakValue =
                            ValueConverter.toCoreValue(targetValue, sessionDelegate);
                    return new PropertyImpl(dlg.setProperty(oakName, oakValue));
                }
            }
        });
View Full Code Here

                    throw new ConstraintViolationException();
                }
                // TODO: END

                String jcrPrimaryType = sessionDelegate.getOakPathOrThrow(Property.JCR_PRIMARY_TYPE);
                CoreValue cv = ValueConverter.toCoreValue(nodeTypeName, PropertyType.NAME, sessionDelegate);
                dlg.setProperty(jcrPrimaryType, cv);
                return null;
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.CoreValue

Copyright © 2018 www.massapicom. 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.