Package com.psddev.dari.db

Examples of com.psddev.dari.db.State


        page.write(ObjectUtils.toJson(jsonResponse));
    }

    private Object findContent(Object object, UUID id) {
        if (id != null) {
            State state = State.getInstance(object);

            if (state.getId().equals(id)) {
                return object;
            }

            for (Map.Entry<String, Object> entry : state.entrySet()) {
                String name = entry.getKey();
                Object value = entry.getValue();
                ObjectField field = state.getField(name);
                Object found = findEmbedded(value, id, field != null && field.isEmbedded());

                if (found != null) {
                    return found;
                }
View Full Code Here


    }

    private Object findEmbedded(Object value, UUID id, boolean embedded) {
        if (value != null) {
            if (value instanceof Recordable) {
                State valueState = ((Recordable) value).getState();

                if (valueState.isNew()) {
                    ObjectType type;

                    if (embedded ||
                            ((type = valueState.getType()) != null &&
                            type.isEmbedded())) {
                        Object found = findContent(value, id);

                        if (found != null) {
                            return found;
View Full Code Here

public class EmbeddedDataOperation extends Operation {

    @Override
    public void evaluate(
            Variation variation, Profile profile, Object object) {
        State state = State.getInstance(object);
        Map<String, Object> variationData = (Map<String, Object>)
                state.getValue("variations/" + variation.getId());
        if (variationData != null) {
            state.getValues().putAll(variationData);
        }
    }
View Full Code Here

    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        Object selected = page.findOrReserve(Workflow.class);
        State selectedState = State.getInstance(selected);

        if (page.tryStandardUpdate(selected)) {
            return;
        }

        page.writeHeader();
            page.writeStart("div", "class", "withLeftNav");
                page.writeStart("div", "class", "leftNav");
                    page.writeStart("div", "class", "widget");
                        page.writeStart("h1", "class", "icon icon-object-workflow");
                            page.writeHtml("Workflows");
                        page.writeEnd();

                        page.writeStart("ul", "class", "links");
                            page.writeStart("li", "class", "new " + (selectedState.isNew() ? "selected" : ""));
                                page.writeStart("a", "href", page.url(null));
                                    page.writeHtml("New Workflow");
                                page.writeEnd();
                            page.writeEnd();
View Full Code Here

                    page.writeEnd();

                    if (mainObject != null) {
                        for (Section section : mainObject.findSections()) {
                            if (section instanceof ContentSection) {
                                State content = State.getInstance(((ContentSection) section).getContent());

                                if (content != null) {
                                    page.writeStart("li");
                                        page.writeStart("a",
                                                "href", page.returnUrl("sectionId", section.getId(), "contentId", content.getId()),
                                                "target", "_top");
                                            page.writeHtml("Section: ");
                                            page.writeHtml(page.getObjectLabelOrDefault(section, "Unnamed"));
                                            page.writeHtml(" (");
                                            page.writeHtml(page.getTypeLabel(content));
View Full Code Here

                        pd.setDate(date);
                    }

                    Database.Static.overrideDefault(pd);

                    State mainState = State.getInstance(PageFilter.Static.getMainObject(request));

                    if (mainState != null) {
                        mainState.setDatabase(null);
                        mainState.setValues(mainState.getSimpleValues());
                    }

                    chain.doFilter(request, response);

                } finally {
View Full Code Here

            throw new IllegalArgumentException(String.format(
                    "[%s] is not a valid type ID!", typeId));

        } else {
            Object object = type.createObject(id);
            State state = State.getInstance(object);

            state.setResolveInvisible(true);
            state.setValues(jsonValues);

            return object;
        }
    }
View Full Code Here

    private String displayApi;
    private String updateApi;

    /** Creates a JSON string that represents the given {@code object}. */
    private static String getJson(Object object) {
        State state = State.getInstance(object);
        Map<String, Object> values = state.getSimpleValues();
        values.put("_id", state.getId().toString());
        values.put("_typeId", state.getTypeId().toString());
        return ObjectUtils.toJson(values);
    }
View Full Code Here

            } else if (object instanceof Renderer) {
                return true;

            } else {
                State state = State.getInstance(object);
                ObjectType type = state.getType();

                if (type != null) {
                    if (Template.Static.findUsedTypes(getSite()).contains(type)) {
                        return true;
View Full Code Here

                    OBJECT_ID_PARAMETER, history.getObjectId(),
                    DRAFT_ID_PARAMETER, null,
                    HISTORY_ID_PARAMETER, history.getId());

        } else {
            State state = State.getInstance(object);
            ObjectType type = state.getType();
            UUID objectId = state.getId();
            Draft draft = getOverlaidDraft(object);
            History history = getOverlaidHistory(object);

            parameters = pushToArray(parameters,
                    OBJECT_ID_PARAMETER, objectId,
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.