Package com.psddev.cms.db

Examples of com.psddev.cms.db.Schedule


        return null;
    }

    @Override
    protected void doService(final ToolPageContext page) throws IOException, ServletException {
        Schedule schedule = (Schedule) page.findOrReserve(Schedule.class);
        boolean newSchedule = schedule.getState().isNew();

        if (page.isFormPost()) {
            try {
                if (page.param(String.class, "action-save") != null) {
                    ToolUser toolUser = page.getUser();

                    page.include("/WEB-INF/objectPost.jsp", "object", schedule);

                    if (newSchedule) {
                        schedule.setTriggerUser(toolUser);
                        schedule.setTriggerSite(page.getSite());
                    }

                    schedule.save();

                    if (newSchedule) {
                        toolUser.setCurrentSchedule(schedule);
                        toolUser.save();
                    }

                } else if (page.param(String.class, "action-delete") != null) {
                    try {
                        schedule.beginWrites();
                        Query.from(Draft.class).where("schedule = ?", schedule).deleteAll();
                        schedule.delete();
                        schedule.commitWrites();

                    } finally {
                        schedule.endWrites();
                    }
                }

                page.writeStart("script", "type", "text/javascript");
                    page.writeRaw("window.location = window.location;");
                page.writeEnd();

                return;

            } catch (Exception error) {
                page.getErrors().add(error);
            }
        }

        page.writeStart("div", "class", "widget");
            page.writeFormHeading(schedule, "class", "icon icon-object-schedule");
            page.include("/WEB-INF/errors.jsp");

            page.writeStart("form",
                    "method", "post",
                    "action", page.url("", "id", schedule.getId()));
                page.include("/WEB-INF/objectForm.jsp", "object", schedule);

                page.writeStart("div", "class", "actions");
                    page.writeStart("button",
                            "class", "icon icon-action-save",
View Full Code Here


            if (!scheduled.isEmpty()) {
                page.writeStart("h2").writeHtml("Scheduled").writeEnd();

                page.writeStart("ul", "class", "links pageThumbnails");
                    for (Draft d : scheduled) {
                        Schedule s = d.getSchedule();
                        String sn = s.getName();

                        page.writeStart("li",
                                "class", d.equals(selected) ? "selected" : null,
                                "data-preview-url", "/_preview?_cms.db.previewId=" + d.getId());
                            page.writeStart("a", "href", page.objectUrl(null, d));
                                if (ObjectUtils.isBlank(sn)) {
                                    page.writeHtml(page.formatUserDateTime(s.getTriggerDate()));
                                    page.writeHtml(" by ");
                                    page.writeObjectLabel(s.getTriggerUser());

                                } else {
                                    page.writeHtml(sn);
                                }
                            page.writeEnd();
                        page.writeEnd();
                    }
                page.writeEnd();
            }

            if (!drafts.isEmpty()) {
                page.writeStart("h2").writeHtml("Drafts").writeEnd();

                page.writeStart("ul", "class", "links pageThumbnails");
                    for (Draft d : drafts) {
                        Content.ObjectModification dcd = d.as(Content.ObjectModification.class);

                        page.writeStart("li",
                                "class", d.equals(selected) ? "selected" : null,
                                "data-preview-url", "/_preview?_cms.db.previewId=" + d.getId());
                            page.writeStart("a", "href", page.objectUrl(null, d));
                                page.writeHtml(page.formatUserDateTime(dcd.getUpdateDate()));
                                page.writeHtml(" by ");
                                page.writeObjectLabel(dcd.getUpdateUser());
                            page.writeEnd();
                        page.writeEnd();
                    }
                page.writeEnd();
            }

            if (!namedHistories.isEmpty()) {
                page.writeStart("h2").writeHtml("Named Past").writeEnd();

                page.writeStart("ul", "class", "links pageThumbnails");
                    for (History h : namedHistories) {
                        page.writeStart("li",
                                "class", h.equals(selected) ? "selected" : null,
                                "data-preview-url", "/_preview?_cms.db.previewId=" + h.getId());
                            page.writeStart("a", "href", page.objectUrl(null, h));
                                page.writeObjectLabel(h);
                            page.writeEnd();
                        page.writeEnd();
                    }
                page.writeEnd();
            }

            if (!histories.isEmpty()) {
                page.writeStart("h2").writeHtml("Past").writeEnd();

                if (historiesResult.hasNext()) {
                    page.writeStart("p");
                        page.writeStart("a",
                                "class", "icon icon-action-search",
                                "target", "_top",
                                "href", page.cmsUrl("/searchAdvancedFull",
                                        Search.SELECTED_TYPE_PARAMETER, ObjectType.getInstance(History.class).getId(),
                                        Search.ADVANCED_QUERY_PARAMETER, "objectId = " + state.getId()));
                            page.writeHtml("View All ");
                            page.writeHtml(historiesResult.getCount());
                            page.writeHtml(" Past Revisions");
                        page.writeEnd();
                    page.writeEnd();

                    page.writeStart("h2");
                        page.writeHtml("Past 10");
                    page.writeEnd();
                }

                page.writeStart("ul", "class", "links pageThumbnails");
                    for (History h : histories) {
                        Map<String, Object> originals = h.getObjectOriginals();

                        page.writeStart("li",
                                "class", h.equals(selected) ? "selected" : null,
                                "data-preview-url", "/_preview?_cms.db.previewId=" + h.getId());

                            if (ObjectUtils.to(boolean.class, originals.get("cms.content.draft"))) {
                                page.writeStart("span", "class", "visibilityLabel");
                                    page.writeHtml("Draft");
                                page.writeEnd();

                            } else {
                                String workflowState = ObjectUtils.to(String.class, originals.get("cms.workflow.currentState"));

                                if (workflowState != null) {
                                    Workflow workflow = Query.
                                            from(Workflow.class).
                                            where("contentTypes = ?", h.getState().get("objectType")).
                                            first();

                                    if (workflow != null) {
                                        for (WorkflowState s : workflow.getStates()) {
                                            if (workflowState.equals(s.getName())) {
                                                workflowState = s.getDisplayName();
                                                break;
                                            }
                                        }
                                    }
View Full Code Here

                writeElement("meta", "name", "robots", "content", "noindex");
                writeStylesAndScripts();
            writeEnd();

            Schedule currentSchedule = getUser() != null ? getUser().getCurrentSchedule() : null;
            String broadcastMessage = cms.getBroadcastMessage();
            Date broadcastExpiration = cms.getBroadcastExpiration();
            boolean hasBroadcast = !ObjectUtils.isBlank(broadcastMessage) &&
                    (broadcastExpiration == null ||
                    broadcastExpiration.after(new Date()));

            writeTag("body", "class",
                    (currentSchedule != null || hasBroadcast ? "hasToolBroadcast " : "") +
                    (user != null ? "" : "noToolUser "));
                if (currentSchedule != null || hasBroadcast) {
                    writeStart("div", "class", "toolBroadcast");
                        if (currentSchedule != null) {
                            writeHtml("All editorial changes will be scheduled for: ");

                            writeStart("a",
                                    "href", cmsUrl("/scheduleEdit", "id", currentSchedule.getId()),
                                    "target", "scheduleEdit");
                                writeHtml(getObjectLabel(currentSchedule));
                            writeEnd();

                            writeHtml(" - ");
View Full Code Here

                if (state.as(Content.ObjectModification.class).isDraft()) {
                    state.delete();
                }

                Schedule schedule = draft.getSchedule();

                if (schedule != null &&
                        ObjectUtils.isBlank(schedule.getName())) {
                    schedule.delete();
                }

            } else {
                state.delete();
            }
View Full Code Here

                State.getInstance(original).getExtras().put("cms.variedObject", object);
                object = original;
                state = State.getInstance(object);
            }

            Schedule schedule = user.getCurrentSchedule();
            Date publishDate = null;

            if (schedule == null) {
                publishDate = getContentFormPublishDate();

            } else if (draft == null) {
                draft = Query.
                        from(Draft.class).
                        where("schedule = ?", schedule).
                        and("objectId = ?", object).
                        first();
            }

            if (schedule != null || publishDate != null) {
                if (!state.validate()) {
                    throw new ValidationException(Arrays.asList(state));
                }

                if (draft == null || param(boolean.class, "newSchedule")) {
                    draft = new Draft();
                    draft.setOwner(user);
                }

                draft.setObject(object);

                if (state.isNew() || contentData.isDraft()) {
                    contentData.setDraft(true);
                    publish(state);
                    draft.setObjectChanges(null);
                }

                if (schedule == null) {
                    schedule = draft.getSchedule();
                }

                if (schedule == null) {
                    schedule = new Schedule();
                    schedule.setTriggerSite(site);
                    schedule.setTriggerUser(user);
                }

                if (publishDate != null) {
                    schedule.setTriggerDate(publishDate);
                    schedule.save();
                }

                draft.setSchedule(schedule);
                publish(draft);
                state.commitWrites();
View Full Code Here

TOP

Related Classes of com.psddev.cms.db.Schedule

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.