Package com.psddev.dari.db

Examples of com.psddev.dari.db.ObjectType


        State itemState = State.getInstance(item);
        String permalink = itemState.as(Directory.ObjectModification.class).getPermalink();
        Integer embedWidth = null;

        if (ObjectUtils.isBlank(permalink)) {
            ObjectType type = itemState.getType();

            if (type != null) {
                Renderer.TypeModification rendererData = type.as(Renderer.TypeModification.class);
                int previewWidth = rendererData.getEmbedPreviewWidth();

                if (previewWidth > 0 &&
                        !ObjectUtils.isBlank(rendererData.getEmbedPath())) {
                    permalink = "/_preview?_embed=true&_cms.db.previewId=" + itemState.getId();
View Full Code Here


    public static final class Static {

        public static ReferentialText getFieldDescription(State state,
                String fieldName) {
            if (state != null) {
                ObjectType typeDefinition = state.getType();
                GuideType guide = getGuideType(typeDefinition);
                if (guide != null) {
                    return guide.getFieldDescription(fieldName, null, false);
                }
            }
View Full Code Here

     * applied.
     *
     * @return {@code null} if {@code objectType} isn't set.
     */
    public Object getObject() {
        ObjectType type = getObjectType();

        if (type == null) {
            return null;
        }

        UUID id = getObjectId();
        Object object = Query.fromAll().
                where("_id = ?", id).
                using(getState().getDatabase()).
                master().
                noCache().
                resolveInvisible().
                first();

        if (object == null) {
            object = type.createObject(id);
        }

        State.getInstance(object).putAll(getObjectChanges());
        return object;
    }
View Full Code Here

            if (!ObjectUtils.isBlank(description)) {
                return description;
            }

            State state = getState();
            ObjectType type = state.getType();

            if (type != null) {
                for (String field : type.as(TypeModification.class).getDescriptionFields()) {
                    Object fieldDescription = state.getByPath(field);

                    if (fieldDescription != null) {
                        description = toMetaTagString(fieldDescription);
View Full Code Here

            };

            keywords.addAll(getKeywords());

            State state = getState();
            ObjectType type = state.getType();

            if (type != null) {
                for (String field : type.as(TypeModification.class).getKeywordsFields()) {
                    Iterable<?> fieldKeywords = ObjectUtils.to(Iterable.class, state.getByPath(field));

                    if (fieldKeywords != null) {
                        for (Object item : fieldKeywords) {
                            if (item != null) {
View Full Code Here

            if (!ObjectUtils.isBlank(ids)) {
                DatabaseEnvironment environment = type.getState().getDatabase().getEnvironment();

                for (Object idObject : ids) {
                    ObjectType compatibleType = environment.getTypeById(ObjectUtils.to(UUID.class, idObject));

                    if (compatibleType != null) {
                        types.add(compatibleType);
                    }
                }
View Full Code Here

    @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();

        page.writeHeader();
            if (page.isFormPost() &&
                    page.param(String.class, "action-save") != null) {
                try {
                    JspUtils.include(
                            page.getRequest(),
                            page.getResponse(),
                            page,
                            page.cmsUrl("/WEB-INF/objectPost.jsp"),
                            "object", state.getOriginalObject());

                    Map<String, Object> values = state.getValues();
                    Map<String, Object> replaces = new CompactMap<String, Object>();
                    Map<String, Object> adds = new CompactMap<String, Object>();
                    Map<String, Object> removes = new CompactMap<String, Object>();
                    Set<String> clears = new HashSet<String>();

                    for (ObjectField field : type.getFields()) {
                        String name = field.getInternalName();
                        Object value = values.get(name);

                        Operation op = page.param(Operation.class, OPERATION_PARAMETER_PREFIX + name);
View Full Code Here

                workflowStateLabels.put("ws." + s.getName(), s.getDisplayName());
            }
        }

        String state = page.pageParam(String.class, "state", null);
        final ObjectType type = ObjectType.getInstance(page.pageParam(UUID.class, "typeId", null));
        Query<?> draftsQuery;

        if ("draft".equals(state)) {
            draftsQuery = Query.
                    from(Object.class).
                    where("_type = ? or cms.content.draft = true", Draft.class);

        } else if (state != null && state.startsWith("ws.")) {
            draftsQuery = Query.
                    from(Object.class).
                    where("cms.workflow.currentState = ?", state.substring(3));

        } else {
            draftsQuery = Query.
                    from(Object.class).
                    where("_type = ? or cms.content.draft = true or cms.workflow.currentState != missing", Draft.class);
        }

        final UserType userType = page.pageParam(UserType.class, "userType", UserType.ANYONE);
        String userParameter = userType + ".value";
        final Object user = Query.from(Object.class).where("_id = ?", page.pageParam(UUID.class, userParameter, null)).first();
        QueryFilter<Object> queryFilter = null;

        if (type != null || userType != UserType.ANYONE) {
            queryFilter = new QueryFilter<Object>() {

                @Override
                public boolean include(Object item) {
                    State itemState = State.getInstance(item);
                    boolean typeOk = true;
                    boolean userOk = true;

                    if (type != null) {
                        ObjectType itemType = item instanceof Draft ? ((Draft) item).getObjectType() : itemState.getType();
                        typeOk = itemType != null && itemType.getGroups().contains(type.getInternalName());
                    }

                    if (userType != UserType.ANYONE) {
                        ToolUser updateUser = itemState.as(Content.ObjectModification.class).getUpdateUser();
View Full Code Here

     * @deprecated No replacement
     */
    @Deprecated
    private static String findStorageItemField(State state) {
        String field = null;
        ObjectType objectType = state.getType();
        if (objectType != null) {
            for (ObjectField objectField : objectType.getFields()) {
                if (ObjectField.FILE_TYPE.equals(objectField.getInternalType())) {
                    field = objectField.getInternalName();
                    break;
                }
            }
View Full Code Here

        return "area/dashboard";
    }

    @Override
    protected void doService(ToolPageContext page) throws IOException, ServletException {
        ObjectType itemType = Query.findById(ObjectType.class, page.pageParam(UUID.class, "itemType", null));
        Type type = page.pageParam(Type.class, "type", Type.ANYONE);
        String valueParameter = type + ".value";
        Object valueObject = Query.from(Object.class).where("_id = ?", page.pageParam(UUID.class, valueParameter, null)).first();
        long offset = page.param(long.class, "offset");
        int limit = page.pageParam(Integer.class, "limit", 20);
View Full Code Here

TOP

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

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.