Package com.sonyericsson.hudson.plugins.metadata.model.definitions

Examples of com.sonyericsson.hudson.plugins.metadata.model.definitions.TreeNodeMetadataDefinition


                    child3
                        child31
                            child312=something else
             */
        TreeNodeMetadataDefinition[] startTree = createTreePath("", "root", "child1");
        TreeNodeMetadataDefinition startChild1 = startTree[1];
        startChild1.addChild(new StringMetadataDefinition("child11", "something"));
        TreeNodeMetadataDefinition startRoot = startTree[0];
        startRoot.addChild(new StringMetadataDefinition("child2", "something"));
        addValue(startRoot, "something", "", "child3", "child31", "child311");
        addValue(startRoot, "something", "", "child3", "child31", "child312");

        TreeNodeMetadataDefinition addRoot = createPath("something", "", "root", "child1", "child12");
        addValue(addRoot, "something else", "", "child2");
        addValue(addRoot, "something else", "", "child3", "child31", "child312");
        addValue(addRoot, "something", "", "child3", "child31", "child313");

        Collection<MetadataDefinition> returnedValues = startRoot.addChildren(addRoot.getChildren());

        //Verify the tree
        Metadata leaf = TreeStructureUtil.getPath(startRoot, "child1", "child11");
        assertNotNull(leaf);
        assertEquals("something", leaf.getValue());
View Full Code Here


     * @param path        the path to create.
     * @return the root and the leaf.
     */
    public static TreeNodeMetadataDefinition[] createTreePath(String description, String... path) {
        TreeNodeMetadataDefinition[] arr = new TreeNodeMetadataDefinition[2];
        arr[1] = new TreeNodeMetadataDefinition(path[path.length - 1], description);
        arr[0] = createPath(arr[1], Arrays.copyOf(path, path.length - 1));
        return arr;
    }
View Full Code Here

     */
    public static TreeNodeMetadataDefinition createPath(AbstractMetadataDefinition leaf, String... parentPath) {
        if (parentPath == null || parentPath.length < 1) {
            throw new IllegalArgumentException("The leaf must have at least one parent.");
        }
        TreeNodeMetadataDefinition root = null;
        TreeNodeMetadataDefinition parent = null;

        for (String name : parentPath) {
            TreeNodeMetadataDefinition val = new TreeNodeMetadataDefinition(name);
            if (parent != null) {
                parent.addChild(val);
            }
            parent = val;
            if (root == null) {
View Full Code Here

     */
    public static boolean addValue(MetadataParent root, AbstractMetadataDefinition value, String... parentPath) {
        if (parentPath == null || parentPath.length <= 0) {
            return root.addChild(value) == null;
        } else {
            TreeNodeMetadataDefinition path = createPath(value, parentPath);
            return root.addChild(path) == null;
        }
    }
View Full Code Here

     *
     * @throws Exception if so.
     */
    public void testNodeConversion() throws Exception {
        StringMetadataDefinition string = new StringMetadataDefinition("string", "myValue");
        TreeNodeMetadataDefinition tree = new TreeNodeMetadataDefinition("tree");
        tree.addChild(string);
        List<AbstractMetadataDefinition> list = new LinkedList<AbstractMetadataDefinition>();
        list.add(tree);
        PluginImpl.getInstance().setDefinitions(list);
        FreeStyleProject freeStyleProject = createFreeStyleProject();
        configRoundtrip(freeStyleProject);
View Full Code Here

        TreeNodeMetadataValue treeValue = startTree[0];
        TreeStructureUtil.addValue(treeValue, "nonDefaultVal", "", "child1", "child12");
        values = new LinkedList<MetadataValue>();
        values.add(treeValue);
        StringMetadataDefinition stringDef = new StringMetadataDefinition("child12", "defaultVal");
        TreeNodeMetadataDefinition subTreeDef = new TreeNodeMetadataDefinition("child1");
        subTreeDef.addChild(stringDef);
        startTreeNode = new TreeNodeMetadataDefinition("root", new LinkedList<MetadataDefinition>());
        startTreeNode.addChild(subTreeDef);
    }
View Full Code Here

                        LinkedList<MetadataValue> list = (LinkedList<MetadataValue>)leftOvers;
                        treeNode = new TreeNodeMetadataValue(value.getName(), value.getDescription(),
                                list, value.isExposedToEnvironment());
                    } else if (value instanceof MetadataDefinition) {
                        LinkedList<MetadataDefinition> list = (LinkedList<MetadataDefinition>)leftOvers;
                        treeNode = new TreeNodeMetadataDefinition(value.getName(), value.getDescription(), list, false);
                    }
                    returnList = new LinkedList<T>();
                    returnList.add((T)treeNode);
                    return returnList;
                }
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.metadata.model.definitions.TreeNodeMetadataDefinition

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.