Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Collection


        Map<String, String> params = new HashMap <String, String> ();
        params.put("query", sql);
        params.put(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                RegistryConstants.COMMENTS_RESULT_TYPE);
        params.put("1", "commentXX1%");
        Collection qResults = registry.executeQuery("/test/qap", params);

        String[] qPaths = (String[]) qResults.getContent();

        assertEquals("Query result count should be 1", qPaths.length, 1);
    }
View Full Code Here


        configSystemRegistry.put("/test/comments/q1", comQuery);

        Map<String, String> params = new HashMap<String, String>();
        params.put("1", "%comment%");
        params.put("2", "r1x");
        Collection qResults = registry.executeQuery("/test/comments/q1", params);

        String[] qPaths = (String[]) qResults.getContent();

        assertEquals("Query result count should be 4", qPaths.length, 4);
        // we can't expect the comment number to be 4 , 3, 2, 1 if already comments there in the
        // database it will take different numbers
        assertEquals("Comment query result is invalid",
                ((Comment) registry.get(qPaths[0])).getText(),
                "a new test comment");
        assertEquals("Comment query result is invalid",
                ((Comment) registry.get(qPaths[1])).getText(),
                "commentXX3 on this resource :)");
        assertEquals("Comment query result is invalid",
                ((Comment) registry.get(qPaths[2])).getText(),
                "commentXX2 on this resource :)");
        assertEquals("Comment query result is invalid",
                ((Comment) registry.get(qPaths[3])).getText(),
                "commentXX1 on this resource :)");

        Resource qResult = registry.get(qPaths[0]);

        assertTrue("Comment query should return Comment objects as results",
                qResult instanceof Comment);

        Comment c1 = (Comment) qResult;

        assertNotNull("Comment query result is invalid", c1.getText());
        assertNotNull("Comment query result is invalid", c1.getUser());
        assertNotNull("Comment query result is invalid", c1.getCreatedTime());

        Resource r2 = registry.newResource();
        r2.setContent("r2 content");
        registry.put("/test/comments/r2", r2);

        registry.addComment("/test/comments/r2", new Comment("commentXX1 on this resource :)"));
        registry.addComment("/test/comments/r2", new Comment("commentXX2 on this resource :)"));
        registry.addComment("/test/comments/r2", new Comment("commentXX3 on this resource :)"));
        registry.addComment("/test/comments/r2", new Comment("a new test comment"));

        comQuery = configSystemRegistry.newResource();
        sql = "SELECT REG_COMMENT_ID FROM REG_COMMENT C, REG_RESOURCE_COMMENT RC " +
                "WHERE C.REG_COMMENT_TEXT LIKE ? AND C.REG_ID=RC.REG_COMMENT_ID " +
                "AND RC.REG_RESOURCE_NAME=? ORDER BY C.REG_COMMENTED_TIME LIMIT ?, ?";

        comQuery.setContent(sql);

        comQuery.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
        comQuery.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME,
                RegistryConstants.COMMENTS_RESULT_TYPE);

        configSystemRegistry.put("/test/comments/q1", comQuery);

        params = new HashMap<String, String>();
        params.put("1", "%comment%");
        params.put("2", "r2");
        params.put("3", "1");
        params.put("4", "4");
        qResults = registry.executeQuery("/test/comments/q1", params);

        qPaths = (String[]) qResults.getContent();

        assertEquals("Query result count should be 3", qPaths.length, 3);
        assertEquals("Comment query result is invalid",
                ((Comment) registry.get(qPaths[2])).getText(),
                "a new test comment");
View Full Code Here

        rootSystemRegistry.put("/test/resources/q1", comQuery);

        Map<String, String> params = new HashMap<String, String>();
        params.put("1", "%content");
        Collection qResults = rootSystemRegistry.executeQuery("/test/resources/q1", params);

        String[] qPaths = (String[]) qResults.getContent();

        assertEquals("Query result count should be 3", qPaths.length, 3);
        assertEquals("Comment query result is invalid", qPaths[0], "/test/resources/rx0");
        assertEquals("Comment query result is invalid", qPaths[1], "/test/resources/rx2");
        assertEquals("Comment query result is invalid", qPaths[2], "/test/resources/rx1");

        comQuery = rootSystemRegistry.newResource();
        sql = "SELECT REG_PATH_ID, REG_NAME FROM REG_RESOURCE R " +
                "ORDER BY R.REG_CREATED_TIME DESC";

        comQuery.setContent(sql);

        comQuery.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);

        rootSystemRegistry.put("/test/resources/q1", comQuery);

        params = new HashMap<String, String>();

        qResults = rootSystemRegistry.executeQuery("/test/resources/q1", params);

        qPaths = (String[]) qResults.getContent();

        List<String> paths = new LinkedList<String>();
        for (String temp : qPaths) {
            if (temp.startsWith("/test/resources/rx")) {
                paths.add(temp);
View Full Code Here

                RegistryConstants.RATINGS_RESULT_TYPE);
        systemRegistry.put("/qs/q2", q1);

        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("1", "%production%");
        Collection result = registry.executeQuery("/qs/q2", parameters);

        String[] ratingPaths = result.getChildren();
        assertEquals("There should be two match ratings.", ratingPaths.length, 2);

//        Resource rating1 = registry.get(ratingPaths[0]);
//        assertEquals("First matching rating should be 3",
//                rating1.getContent().toString(), "3");
View Full Code Here

                RegistryConstants.TAGS_RESULT_TYPE);
        systemRegistry.put("/qs/q3", q1);

        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("1", "%production%");
        Collection result = registry.executeQuery("/qs/q3", parameters);

        String[] tagPaths = result.getChildren();
        assertEquals("There should be two matching tags.", tagPaths.length, 2);

        Resource tag2 = registry.get(tagPaths[0]);
        assertEquals("First matching tag should be 'java'",
                (String)tag2.getContent(), "java");
View Full Code Here

                RegistryConstants.COMMENTS_RESULT_TYPE);
        systemRegistry.put("/qs/q4", q1);

        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("1", "%production%");
        Collection result = registry.executeQuery("/qs/q4", parameters);

        String[] commentPaths = result.getChildren();
        assertEquals("There should be two match comments.", commentPaths.length, 2);

        Resource c1 = registry.get(commentPaths[0]);
        Resource c2 = registry.get(commentPaths[1]);
View Full Code Here

        r1New.setContent("New r1");
        registry.put("/r1", r1New);

        // put a collection in to the root

        Collection c1 = registry.newCollection();
        registry.put("/c1", c1);

        // put a content artifact in to /c1/r2

        String r2Content = "this is r2 content";
View Full Code Here

            Registry registry = UserMgtDSComponent.getRegistryService().getGovernanceSystemRegistry();
            for (ManagementPermission uiPermission : uiPermissions) {
                if (registry.resourceExists(uiPermission.getResourceId())) {
                    continue;
                }
                Collection resource = registry.newCollection();
                resource.setProperty(UserMgtConstants.DISPLAY_NAME, uiPermission.getDisplayName());
                registry.put(uiPermission.getResourceId(), resource);
            }
        }
    }
View Full Code Here

                        registry.put(resourcePath, resource);
                    }
                    continue;
                }

                Collection resource = registry.newCollection();
                resource.setProperty(UserMgtConstants.DISPLAY_NAME, displayName);
                registry.put(resourcePath, resource);

            }

            // realm is taken from the registry rather than realm service to fix
View Full Code Here

        Resource r2 = registry.newResource();
        r2.setContent("another content");
        registry.put("/test/paths2/r2/", r2);

        Collection c1 = registry.newCollection();
        registry.put("/test/paths2/c1", c1);

        Collection c2 = registry.newCollection();
        registry.put("/test/paths2/c2/", c2);

        assertTrue("Resource not found.", registry.resourceExists("/test/paths2/r1/"));
        assertTrue("Resource not found.", registry.resourceExists("/test/paths2/r2"));
        assertTrue("Resource not found.", registry.resourceExists("/test/paths2/c1/"));
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Collection

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.