Package com.psddev.cms.tool

Examples of com.psddev.cms.tool.Search


    @Override
    @SuppressWarnings("unchecked")
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        List<UUID> ids = page.params(UUID.class, ContentSearchAdvanced.ITEMS_PARAMETER);
        Query<?> query = ids.isEmpty() ? new Search(page).toQuery(page.getSite()) : Query.fromAll().where("_id = ?", ids);
        long count = query.count();
        ObjectType type = ObjectType.getInstance(page.param(UUID.class, "typeId"));
        State state = State.getInstance(type.createObject(page.param(UUID.class, "id")));

        state.clear();
View Full Code Here


        return null;
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        Search search = new Search(page);
        SearchResultRenderer resultRenderer = new SearchResultRenderer(page, search) {

            @Override
            public void renderBeforeItem(Object item) throws IOException {
                Reference enhancement = new Reference();
View Full Code Here

        return null;
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        Search search = new Search(page);
        Renderer renderer = new Renderer(page, search);

        renderer.render();

        String pageId = page.createId();
        Query<?> query = search.toQuery(page.getSite());
        State queryState = query.getState();

        queryState.put("cms.ui.search", search.getState().getSimpleValues());

        page.writeStart("div", "id", pageId);
        page.writeEnd();

        page.writeStart("script", "type", "text/javascript");
View Full Code Here

        return null;
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        Search search = new Search(page);
        Query<?> query = search.toQuery(page.getSite());
        DatabaseEnvironment environment = Database.Static.getDefault().getEnvironment();
        ObjectType type = search.getSelectedType();
        List<Display> allDisplays = new ArrayList<Display>();

        allDisplays.add(new ReferencesDisplay());
        allDisplays.add(new PathsDisplay());

        for (String name : new String[] {
                "cms.content.publishDate",
                "cms.content.publishUser",
                "cms.content.updateDate",
                "cms.content.updateUser" }) {

            allDisplays.add(new ObjectFieldDisplay(environment.getField(name)));
        }

        if (type != null) {
            for (ObjectField field : type.getFields()) {
                allDisplays.add(new ObjectFieldDisplay(field));
            }
        }

        List<String> displayNames = page.params(String.class, FIELDS_PARAMETER);
        List<Display> displays = new ArrayList<Display>();

        for (Display display : allDisplays) {
            if (displayNames.contains(display.getInternalName())) {
                displays.add(display);
            }
        }

        Collections.sort(allDisplays);
        Collections.sort(displays);

        List<UUID> ids = page.params(UUID.class, ITEMS_PARAMETER);

        if (page.param(String.class, "action-download") != null) {
            HttpServletResponse response = page.getResponse();

            response.setContentType("text/csv");
            response.setHeader("Content-Disposition", "attachment; filename=search-result-" + new DateTime(null, page.getUserDateTimeZone()).toString("yyyy-MM-dd-hh-mm-ss") + ".csv");
            page.write('\ufeff');

            page.write("\"");
            writeCsvItem(page, "Type");
            page.write("\",\"");
            writeCsvItem(page, "Label");
            page.write("\"");

            for (Display display : displays) {
                page.write(",\"");
                writeCsvItem(page, display.getDisplayName());
                page.write("\"");
            }

            page.write("\r\n");

            Iterator<?> queryIterator = ids.isEmpty() ?
                    query.iterable(0).iterator() :
                    Query.fromAll().where("_id = ?", ids).selectAll().iterator();

            try {
                while (queryIterator.hasNext()) {
                    Object item = queryIterator.next();
                    State itemState = State.getInstance(item);

                    page.write("\"");
                    writeCsvItem(page, page.getTypeLabel(item));
                    page.write("\",\"");
                    writeCsvItem(page, page.getObjectLabel(item));
                    page.write("\"");

                    for (Display display : displays) {
                        page.write(",\"");
                        writeCsvItem(page, display.getCsvItem(itemState));
                        page.write("\"");
                    }

                    page.write("\r\n");
                }

            } finally {
                if (queryIterator instanceof Closeable) {
                    ((Closeable) queryIterator).close();
                }
            }

            return;

        } else if (page.param(String.class, "action-trash") != null) {
            Iterator<?> queryIterator = ids.isEmpty() ?
                    query.iterable(0).iterator() :
                    Query.fromAll().where("_id = ?", ids).selectAll().iterator();

            try {
                while (queryIterator.hasNext()) {
                    page.trash(queryIterator.next());
                }

            } finally {
                if (queryIterator instanceof Closeable) {
                    ((Closeable) queryIterator).close();
                }
            }

            page.getResponse().sendRedirect(page.param(String.class, "returnUrl"));
            return;
        }

        if (search.getLimit() < 20) {
            search.setLimit(20);
        }

        search.setSuggestions(false);

        Renderer renderer = new Renderer(page, search, allDisplays, displays);

        page.putOverride(Recordable.class, new HtmlFormatter<Recordable>() {
View Full Code Here

TOP

Related Classes of com.psddev.cms.tool.Search

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.