Package com.psddev.dari.db

Examples of com.psddev.dari.db.State


        /**
         * Returns {@code true} if the given {@code object} is accessible
         * by the given {@code site}.
         */
        public static boolean isObjectAccessible(Site site, Object object) {
            State objectState = State.getInstance(object);
            Site.ObjectModification objectSiteMod = objectState.as(Site.ObjectModification.class);
            Site objectOwner = objectSiteMod.getOwner();

            if (ObjectUtils.equals(site, objectOwner)) {
                return true;

View Full Code Here


        for (Object item : Query.
                fromAll().
                where("cms.bulkUpload.containerId = ?", getId().toString()).
                selectAll()) {
            State itemState = State.getInstance(item);

            itemState.as(BulkUploadDraft.class).setContainerId(null);
            itemState.saveImmediately();
        }
    }
View Full Code Here

        }
    }

    @Override
    protected void afterDelete() {
        State state = getState();

        if (state.isVisible()) {
            return;
        }

        for (Object item : Query.
                fromAll().
                where("cms.bulkUpload.containerId = ?", state.getId().toString()).
                selectAll()) {
            State.getInstance(item).deleteImmediately();
        }
    }
View Full Code Here

        return sortField;
    }

    public Query<?> toQuery() {
        State state = getState();
        Query<?> query = Query.fromType(getQueryType());
        Predicate predicate = query.getPredicate();

        for (ObjectField field : getIndexedFields()) {
            String name = field.getInternalName();
            Object value = state.get(FIELD_PREFIX + name);

            if (!ObjectUtils.isBlank(value)) {
                String type = field.getInternalItemType();
                String operator = (String) state.get(OPERATOR_PREFIX + name);

                if (operator == null) {
                    operator = ObjectField.REFERENTIAL_TEXT_TYPE.equals(type) || ObjectField.TEXT_TYPE.equals(type) ? "matchesAll" : "equalsAny";
                }
View Full Code Here

        if (section == null || section.getClass() != Section.class) {
            return section;
        }

        State state = State.getInstance(section);
        Section newSection;

        String orientation = (String) state.getValue("orientation");
        boolean isHorizontal = "HORIZONTAL".equals(orientation);
        if (isHorizontal || "VERTICAL".equals(orientation)) {

            ContainerSection container = isHorizontal ?
                    new HorizontalContainerSection() :
                    new VerticalContainerSection();

            String beginJsp = (String) state.getValue("beginJsp");
            if (!ObjectUtils.isBlank(beginJsp)) {
                container.setBeginEngine("JSP");
                container.setBeginScript(beginJsp);
            } else {
                String beginText = (String) state.getValue("beginText");
                if (!ObjectUtils.isBlank(beginText)) {
                    container.setBeginEngine("RawText");
                    container.setBeginScript(beginText);
                }
            }

            String endJsp = (String) state.getValue("endJsp");
            if (!ObjectUtils.isBlank(endJsp)) {
                container.setEndEngine("JSP");
                container.setEndScript(endJsp);
            } else {
                String endText = (String) state.getValue("endText");
                if (!ObjectUtils.isBlank(endText)) {
                    container.setEndEngine("RawText");
                    container.setEndScript(endText);
                }
            }

            List<Object> childReferences
                    = (List<Object>) state.getValue("children");
            if (!ObjectUtils.isBlank(childReferences)) {
                for (Object childReference : childReferences) {
                    Section child = convertLegacySection(
                            layout, resolveReference(Section.class,
                            childReference));
                    if (child != null) {
                        container.getChildren().add(child);
                    }
                }
            }

            newSection = container;

        } else {

            Object object = resolveReference(
                    Object.class, state.getValue("record"));

            ScriptSection scriptSection;
            if ("PLACEHOLDER".equals(orientation)) {
                scriptSection = new MainSection();

            } else if (object == null) {
                scriptSection = new ScriptSection();

            } else {
                ContentSection contentSection = new ContentSection();
                contentSection.setContent(object);
                scriptSection = contentSection;
            }

            String recordJsp = (String) state.getValue("recordJsp");
            if (!ObjectUtils.isBlank(recordJsp)) {
                scriptSection.setEngine("JSP");
                scriptSection.setScript(recordJsp);
            } else {
                String recordText = (String) state.getValue("recordText");
                if (!ObjectUtils.isBlank(recordText)) {
                    scriptSection.setEngine("RawText");
                    scriptSection.setScript(recordText);
                }
            }

            newSection = scriptSection;
        }

        newSection.setName((String) state.getValue("name"));
        return newSection;
    }
View Full Code Here

                }

                if (section instanceof Section) {
                    map.remove("_type");
                    map.remove("_id");
                    State state = State.getInstance(section);
                    state.getValues().putAll(map);
                    if (((Section) section).isShareable()) {
                        state.save();
                    } else {
                        state.setId(null);
                        state.setStatus(null);
                    }
                    return section;
                }
            }
View Full Code Here

    public Object getObject() {
        if (objectType == null) {
            return null;
        } else {
            Object object = objectType.createObject(objectId);
            State state = State.getInstance(object);
            if (objectValues != null) {
                state.getValues().putAll(objectValues);
            }
            return object;
        }
    }
View Full Code Here

    public Map<String, Object> toDefinition() {
        Map<String, Object> definition = super.toDefinition();
        Object content = getContent();

        if (content != null) {
            State contentState = State.getInstance(content);
            ObjectType contentType = contentState.getType();

            definition.put("content", contentState.getId().toString());
            definition.put("contentLabel", contentState.getLabel());

            if (contentType != null) {
                definition.put("contentTypeLabel", contentType.getLabel());
            }
        }
View Full Code Here

        this.transition = transition;
    }

    @Override
    protected String createMessage(Object object, ToolUser sender, Date date, ToolUser receiver) {
        State state = State.getInstance(object);
        StringBuilder message = new StringBuilder();

        message.append("User: ");
        message.append(sender.getLabel());
        message.append(", Workflow: ");
        message.append(getTransition());
        message.append(", Content: ");
        message.append(state.getLabel());
        message.append(" - ");
        message.append(Application.Static.getInstance(CmsTool.class).fullUrl("/content/edit.jsp", "id", state.getId()));

        return message.toString();
    }
View Full Code Here

                    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));
View Full Code Here

TOP

Related Classes of com.psddev.dari.db.State

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.