Package org.nuxeo.ecm.automation

Examples of org.nuxeo.ecm.automation.OperationChain


    protected static PaginableDocumentModelList getChildren(DocumentModel doc,
            int pageSize, int page) throws Exception {
        CoreSession session = doc.getCoreSession();

        OperationContext ctx = new OperationContext(session);
        OperationChain chain = new OperationChain("getChildren");

        String query = "SELECT * FROM Document "
                + "WHERE ecm:mixinType != 'HiddenInNavigation' "
                + "AND ecm:isCheckedInVersion = 0 "
                + "AND ecm:currentLifeCycleState != 'deleted'"
                + "AND ecm:parentId = '" + doc.getId() + "' "
                + "AND ecm:primaryType != 'VEVENT'"
                + "ORDER BY dc:title";

        chain.add(DocumentPageProviderOperation.ID).set("query", query).set(
                "page", page).set("pageSize", pageSize > 0 ? pageSize : 5);

        return (PaginableDocumentModelList) getAutomationService().run(ctx,
                chain);
    }
View Full Code Here


    protected static PaginableDocumentModelList search(DocumentModel doc,
            int pageSize, int page, String queryText) throws Exception {
        CoreSession session = doc.getCoreSession();

        OperationContext ctx = new OperationContext(session);
        OperationChain chain = new OperationChain("search");

        String escapedQueryText = NXQLQueryBuilder.prepareStringLiteral(
                queryText.trim(), false, true);

        String query = "SELECT * FROM Document "
                + "WHERE ecm:mixinType != 'HiddenInNavigation' "
                + "AND ecm:isCheckedInVersion = 0 " + "AND ecm:isProxy = 0 "
                + "AND ecm:currentLifeCycleState != 'deleted' "
                + "AND ecm:fulltext = '" + escapedQueryText + "%' "
                + "AND ecm:path STARTSWITH '" + doc.getPathAsString() + "' "
                + "ORDER BY dc:title";
        chain.add(DocumentPageProviderOperation.ID).set("query", query).set(
                "page", page).set("pageSize", pageSize > 0 ? pageSize : 5);

        return (PaginableDocumentModelList) getAutomationService().run(ctx,
                chain);
    }
View Full Code Here

        String subject = "Member Activity of " + sw.getTitle();
        String template = TEMPLATE_ADDED;
        String message = loadTemplate(template);

        try {
            OperationChain chain = new OperationChain("SendMail");
            chain.add(SendMail.ID).set("from", from).set("to", to).set("HTML",
                    true).set("subject", subject).set("message", message);
            Framework.getLocalService(AutomationService.class).run(ctx, chain);
        } catch (Exception e) {
            log.warn("Unable to notify members about a member management.", e);
            log.debug(e, e);
View Full Code Here

    public void shouldAddAMiniMessage() throws Exception {
        try (CoreSession newSession = openSessionAs("Leela")) {
            OperationContext ctx = new OperationContext(newSession);
            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(AddMiniMessage.ID).set("message",
                    "At the risk of sounding negative, no.");
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);
View Full Code Here

    public void shouldGetNoMiniMessage() throws Exception {
        try (CoreSession newSession = openSessionAs("Leela")) {
            OperationContext ctx = new OperationContext(newSession);
            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(GetMiniMessages.ID);
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);
View Full Code Here

        try (CoreSession newSession = openSessionAs("Leela")) {

            OperationContext ctx = new OperationContext(newSession);
            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(GetMiniMessages.ID);
            Blob result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            String json = result.getString();
            assertNotNull(json);

            ObjectMapper mapper = new ObjectMapper();
            Map<String, Object> m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
                    });
            List<Map<String, Object>> miniMessages = (List<Map<String, Object>>) m.get("miniMessages");
            assertEquals(5, miniMessages.size());

            chain = new OperationChain("testMiniMessageOperation");
            chain.add(GetMiniMessages.ID).set("offset", 5);
            result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            json = result.getString();
            assertNotNull(json);

            mapper = new ObjectMapper();
            m = mapper.readValue(json,
                    new TypeReference<Map<String, Object>>() {
                    });
            miniMessages = (List<Map<String, Object>>) m.get("miniMessages");
            assertEquals(5, miniMessages.size());

            chain = new OperationChain("testMiniMessageOperation");
            chain.add(GetMiniMessages.ID).set("offset", 10);
            result = (Blob) automationService.run(ctx, chain);
            assertNotNull(result);
            json = result.getString();
            assertNotNull(json);
View Full Code Here

            MiniMessage miniMessage = messages.get(0);

            OperationContext ctx = new OperationContext(newSession);
            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(RemoveMiniMessage.ID).set("miniMessageId",
                    String.valueOf(miniMessage.getId()));
            automationService.run(ctx, chain);

            messages = miniMessageService.getMiniMessageFrom(
                    benderActivityObject, 0, 0);
            assertEquals(4, messages.size());

            miniMessage = messages.get(0);
            chain = new OperationChain("testMiniMessageOperation");
            chain.add(RemoveMiniMessage.ID).set("miniMessageId",
                    String.valueOf(miniMessage.getId()));
            automationService.run(ctx, chain);

            messages = miniMessageService.getMiniMessageFrom(
                    benderActivityObject, 0, 0);
View Full Code Here

            MiniMessage miniMessage = messages.get(0);

            OperationContext ctx = new OperationContext(newSession);
            assertNotNull(ctx);

            OperationChain chain = new OperationChain(
                    "testMiniMessageOperation");
            chain.add(RemoveMiniMessage.ID).set("miniMessageId",
                    String.valueOf(miniMessage.getId()));
            automationService.run(ctx, chain);

            messages = miniMessageService.getMiniMessageFrom(
                    benderActivityObject, 0, 0);
View Full Code Here

    @Test
    public void testSocialProviderOperation() throws Exception {
        OperationContext ctx = new OperationContext(session);
        assertNotNull(ctx);

        OperationChain chain = new OperationChain("fakeChain");
        OperationParameters oParams = new OperationParameters(
                SocialProviderOperation.ID);
        oParams.set("query", "select * from Article where ecm:isProxy = 0");
        oParams.set("contextPath", "/sws2");
        chain.add(oParams);

        DocumentModelList result = (DocumentModelList) service.run(ctx, chain);
        assertEquals(2, result.size());

        // remove current user from admins of sws2
View Full Code Here

    @Test
    public void testOnlyPublicDocumentsParameters() throws Exception {
        OperationContext ctx = new OperationContext(session);
        assertNotNull(ctx);

        OperationChain chain = new OperationChain("fakeChain");
        OperationParameters oParams = new OperationParameters(
                SocialProviderOperation.ID);
        oParams.set("query", "select * from Article");
        oParams.set("contextPath", "/sws2");
        oParams.set("onlyPublicDocuments", "true");
        chain.add(oParams);

        DocumentModelList result = (DocumentModelList) service.run(ctx, chain);
        assertEquals(1, result.size());

        oParams.set("onlyPublicDocuments", "false");
View Full Code Here

TOP

Related Classes of org.nuxeo.ecm.automation.OperationChain

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.