Package com.psddev.dari.db

Examples of com.psddev.dari.db.ObjectField


        if (type == null) {
            throw new IllegalArgumentException();
        }

        String fieldName = page.param(String.class, "field");
        ObjectField field = type.getField(fieldName);

        if (field == null) {
            field = type.getEnvironment().getField(fieldName);
        }

        page.writeHeader();
            page.writeStart("style", "type", "text/css");
                page.writeCss(".cms-guideField th",
                        "width", "25%;");
            page.writeEnd();

            page.writeStart("div", "class", "widget cms-guideField");
                page.writeStart("h1", "class", "icon icon-object-guide");
                    page.writeHtml(field.getLabel());
                page.writeEnd();

                page.writeStart("div", "class", "tabbed");

                    // Editorial field description.
                    page.writeStart("div", "data-tab", "For Editors");
                        GuideType guideType = GuideType.Static.getGuideType(type);
                        ReferentialText fieldDescription = null;

                        if (guideType != null) {
                            fieldDescription = guideType.getFieldDescription(fieldName, null, false);
                        }

                        if (fieldDescription != null && !fieldDescription.isEmpty()) {
                            StringBuilder cleaned = new StringBuilder();

                            for (Object item : fieldDescription) {
                                if (item != null) {
                                    if (item instanceof Reference) {
                                        StringWriter writer = new StringWriter();

                                        PageFilter.renderObject(
                                                page.getRequest(),
                                                page.getResponse(),
                                                writer,
                                                ((Reference) item).getObject());

                                        cleaned.append(writer.toString());

                                    } else {
                                        cleaned.append(item.toString());
                                    }
                                }
                            }

                            page.writeRaw(cleaned.toString().replaceAll("(?i)(\\s*<br[^>]*>\\s*)+$", ""));
                        }

                        // Constraints.
                        List<String> constraints = new ArrayList<String>();

                        if (field.isRequired()) {
                            constraints.add("Required");
                        }

                        Object absMin = GuideType.Static.getFieldMinimumValue(field);
                        Object absMax = GuideType.Static.getFieldMaximumValue(field);

                        if (absMin != null) {
                            constraints.add("Absolute Minimum: " + absMin);
                        }

                        if (absMax != null) {
                            constraints.add("Absolute Maximum: " + absMax);
                        }

                        ToolUi fieldUi = field.as(ToolUi.class);
                        Object sugMin = fieldUi.getSuggestedMinimum();
                        Object sugMax = fieldUi.getSuggestedMaximum();

                        if (sugMin != null) {
                            constraints.add("Suggested Minimum: " + sugMin);
                        }

                        if (sugMax != null) {
                            constraints.add("Suggested Maximum: " + sugMax);
                        }

                        if (!constraints.isEmpty()) {
                            page.writeStart("h2", "style", "margin-top:15px;");
                                page.writeHtml("Constraints");
                            page.writeEnd();

                            page.writeStart("ul");
                                for (String constraint : constraints) {
                                    page.writeStart("li");
                                        page.writeHtml(constraint);
                                    page.writeEnd();
                                }
                            page.writeEnd();
                        }

                        if ((fieldDescription == null ||
                                fieldDescription.isEmpty()) &&
                                constraints.isEmpty()) {
                            page.writeStart("div", "class", "message message-info");
                                page.writeHtml("No editorial production guide for this field.");
                            page.writeEnd();
                        }
                    page.writeEnd();

                    // Development help.
                    page.writeStart("div", "data-tab", "For Developers");
                        Class<?> fieldDeclaringClass = ObjectUtils.getClassByName(field.getJavaDeclaringClassName());

                        if (fieldDeclaringClass != null) {
                            Field javaField = field.getJavaField(fieldDeclaringClass);

                            page.writeStart("table", "class", "table-striped");
                                page.writeStart("tbody");
                                    page.writeStart("tr");
                                        page.writeStart("th");
                                            page.writeHtml("Declared In");
                                        page.writeEnd();

                                        page.writeStart("td");
                                            page.writeJavaClassLink(fieldDeclaringClass);
                                        page.writeEnd();
                                    page.writeEnd();

                                    page.writeStart("tr");
                                        page.writeStart("th");
                                            page.writeHtml("Field Type");
                                        page.writeEnd();

                                        page.writeStart("td");
                                            page.writeStart("code");
                                                page.writeHtml(javaField.getGenericType());
                                            page.writeEnd();
                                        page.writeEnd();
                                    page.writeEnd();

                                    page.writeStart("tr");
                                        page.writeStart("th");
                                            page.writeHtml("Field Name");
                                        page.writeEnd();

                                        page.writeStart("td");
                                            page.writeStart("code");
                                                page.writeHtml(field.getJavaFieldName());
                                            page.writeEnd();
                                        page.writeEnd();
                                    page.writeEnd();
                                page.writeEnd();
                            page.writeEnd();
View Full Code Here


            }

            String comparisonPath = page.param(String.class, comparisonPathParam);
            ComparisonOperator comparisonOperator = page.param(ComparisonOperator.class, comparisonOperatorParam);
            PathedField comparisonPathedField = null;
            ObjectField comparisonField = null;

            page.writeHtml(" ");
            page.writeMultipleTypeSelect(
                    null,
                    comparisonTypes,
View Full Code Here

            for (ObjectIndex index : struct.getIndexes()) {
                indexedFields.addAll(index.getFields());
            }

            for (Iterator<ObjectField> i = fields.iterator(); i.hasNext();) {
                ObjectField field = i.next();
                String declaring = field.getJavaDeclaringClassName();

                if (declaring != null &&
                        declaring.startsWith("com.psddev.dari.db.")) {
                    continue;
                }

                String fieldName = field.getInternalName();
                boolean embedded = field.isEmbedded();

                if (!embedded &&
                        ObjectField.RECORD_TYPE.equals(field.getInternalItemType())) {
                    embedded = true;

                    for (ObjectType t : field.getTypes()) {
                        if (!t.isEmbedded()) {
                            embedded = false;
                            break;
                        }
                    }
                }

                if (embedded) {
                    for (ObjectType t : field.getTypes()) {
                        addPathedFields(pathedFields, copyConcatenate(prefix, field), t);
                    }

                } else if (indexedFields.contains(fieldName) &&
                        !field.isDeprecated() &&
                        !field.as(ToolUi.class).isHidden()) {
                    pathedFields.add(new PathedField(copyConcatenate(prefix, field)));
                }
            }
        }
View Full Code Here

            }
        }

        query.setPredicate(predicate);

        ObjectField sortField = getSortField();
        if (ObjectField.DATE_TYPE.equals(sortField.getInternalItemType())) {
            query.sortDescending(sortField.getInternalName());
        } else {
            query.sortAscending(sortField.getInternalName());
        }

        return query;
    }
View Full Code Here

    }

    public ObjectField getSortField() {
        if (sortField == null) {
            ObjectType type = getQueryType();
            ObjectField newSortField = null;

            for (ObjectField field : getSortableFields()) {
                if (field.getInternalName().equals(getSortFieldName())) {
                    newSortField = field;
                    break;
View Full Code Here

            marker.append("<span style=\"display: none;\"");

            ObjectType type = state.getType();

            if (type != null) {
                ObjectField field = type.getField(name);

                if (field != null) {
                    String fieldType = field.getInternalType();

                    if (ObjectField.TEXT_TYPE.equals(fieldType)) {
                        Object value = state.get(name);

                        marker.append(" data-cms-field-text=\"");
View Full Code Here

TOP

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

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.