Package com.psddev.dari.db

Examples of com.psddev.dari.db.ReferentialText


        this.fieldDescriptions = fieldDescriptions;
    }

    public ReferentialText getFieldDescription(String fieldName, String fieldDisplayName,
            boolean createIfMissing) {
        ReferentialText desc = null;
        if (fieldDescriptions != null) {
            for (GuideField gf : fieldDescriptions) {
                if (gf.getFieldName().equals(fieldName)) {
                    // we take this opportunity to synch the display name
                    if (createIfMissing && fieldDisplayName != null) {
View Full Code Here


        return null;
    }

    public void setFieldDescription(String fieldName, String fieldDisplayName,
            ReferentialText description) {
        ReferentialText desc = null;
        if (fieldDescriptions != null) {
            for (GuideField gf : fieldDescriptions) {
                if (gf.getFieldName().equals(fieldName)) {
                    if (fieldDisplayName != null) {
                        gf.setDisplayName(fieldDisplayName);
View Full Code Here

            } else if (getFieldMaximumValue(field) != null) {
                return true;
            } else if (getFieldMinimumValue(field) != null) {
                return true;
            }
            ReferentialText desc = getFieldDescription(state, fieldName);
            if (desc != null && !desc.isEmpty()) {
                return true;
            }

            return false;
        }
View Full Code Here

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

TOP

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

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.