Search in sources :

Example 1 with ViewProperty

use of com.haulmont.cuba.core.global.ViewProperty in project cuba by cuba-platform.

the class ViewRepositoryInfo method dump.

protected void dump(View view, StringBuilder content) {
    content.append("\n");
    content.append("+ ").append(metadata.getSession().getClass(view.getEntityClass()).getName()).append("/").append(view.getName());
    for (ViewProperty viewProperty : view.getProperties()) {
        dump(viewProperty, content, "  ");
    }
    content.append("\n");
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty)

Example 2 with ViewProperty

use of com.haulmont.cuba.core.global.ViewProperty in project cuba by cuba-platform.

the class ViewRepositoryInfo method dumpHtml.

protected void dumpHtml(ViewProperty viewProperty, StringBuilder content, String indent) {
    content.append("<br/>").append("\n");
    content.append(indent);
    content.append("- ").append(viewProperty.getName());
    View innerView = viewProperty.getView();
    if (innerView != null) {
        if (StringUtils.isNotEmpty(innerView.getName())) {
            String metaClassName = metadata.getSession().getClass(innerView.getEntityClass()).getName();
            content.append(" -> <a href=\"#").append(metaClassName).append("__").append(innerView.getName()).append("\">").append(metaClassName).append("/").append(innerView.getName()).append("</a>");
        } else {
            for (ViewProperty innerProperty : innerView.getProperties()) {
                dumpHtml(innerProperty, content, "&nbsp;&nbsp;&nbsp;&nbsp;" + indent);
            }
        }
    }
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty) View(com.haulmont.cuba.core.global.View)

Example 3 with ViewProperty

use of com.haulmont.cuba.core.global.ViewProperty in project cuba by cuba-platform.

the class PropertyDatasourceImpl method getView.

@Override
public View getView() {
    if (view == null) {
        MetaClass metaMetaClass = masterDs.getMetaClass();
        if (metadata.getTools().isPersistent(metaMetaClass) || metadata.getTools().isEmbeddable(metaMetaClass)) {
            View masterView = masterDs.getView();
            if (masterView == null) {
                throw new DevelopmentException("No view for datasource " + masterDs.getId(), ParamsMap.of("masterDs", masterDs.getId(), "propertyDs", getId()));
            }
            ViewProperty property = masterView.getProperty(metaProperty.getName());
            if (property == null) {
                return null;
            }
            if (property.getView() == null) {
                throw new DevelopmentException(String.format("Invalid view definition: %s. Property '%s' must have a view", masterView, property), ParamsMap.of("masterDs", masterDs.getId(), "propertyDs", getId(), "masterView", masterView, "property", property));
            }
            view = metadata.getViewRepository().findView(getMetaClass(), property.getView().getName());
            // anonymous (nameless) view
            if (view == null)
                view = property.getView();
        }
    }
    return view;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) ViewProperty(com.haulmont.cuba.core.global.ViewProperty) View(com.haulmont.cuba.core.global.View) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Example 4 with ViewProperty

use of com.haulmont.cuba.core.global.ViewProperty in project cuba by cuba-platform.

the class ViewRepositoryInfo method dump.

protected void dump(ViewProperty viewProperty, StringBuilder content, String indent) {
    content.append("\n");
    content.append(indent);
    content.append("- ").append(viewProperty.getName());
    View innerView = viewProperty.getView();
    if (innerView != null) {
        if (StringUtils.isNotEmpty(innerView.getName())) {
            content.append(" -> ").append(metadata.getSession().getClass(innerView.getEntityClass()).getName()).append("/").append(innerView.getName());
        } else {
            for (ViewProperty innerProperty : innerView.getProperties()) {
                dump(innerProperty, content, "  " + indent);
            }
        }
    }
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty) View(com.haulmont.cuba.core.global.View)

Example 5 with ViewProperty

use of com.haulmont.cuba.core.global.ViewProperty in project cuba by cuba-platform.

the class ViewRepositoryInfo method dumpHtml.

protected void dumpHtml(View view, StringBuilder content) {
    content.append("<br/>").append("\n");
    String metaClassName = metadata.getSession().getClass(view.getEntityClass()).getName();
    String viewHtmlId = metaClassName + "__" + view.getName();
    content.append("+ <a href=\"#").append(viewHtmlId).append("\"><span id=\"").append(viewHtmlId).append("\">").append(metaClassName).append("/").append(view.getName()).append("</span></a>");
    for (ViewProperty viewProperty : view.getProperties()) {
        dumpHtml(viewProperty, content, "&nbsp;&nbsp;&nbsp;&nbsp;");
    }
    content.append("<br/>").append("\n");
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty)

Aggregations

ViewProperty (com.haulmont.cuba.core.global.ViewProperty)7 View (com.haulmont.cuba.core.global.View)5 MetaClass (com.haulmont.chile.core.model.MetaClass)1 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)1 Test (org.junit.Test)1