Search in sources :

Example 6 with ViewProperty

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

the class ViewHelper method intersectViews.

public static View intersectViews(View first, View second) {
    if (first == null)
        throw new IllegalArgumentException("View is null");
    if (second == null)
        throw new IllegalArgumentException("View is null");
    View resultView = new View(first.getEntityClass());
    Collection<ViewProperty> firstProps = first.getProperties();
    for (ViewProperty firstProperty : firstProps) {
        if (second.containsProperty(firstProperty.getName())) {
            View resultPropView = null;
            ViewProperty secondProperty = second.getProperty(firstProperty.getName());
            if ((firstProperty.getView() != null) && (secondProperty.getView() != null)) {
                resultPropView = intersectViews(firstProperty.getView(), secondProperty.getView());
            }
            resultView.addProperty(firstProperty.getName(), resultPropView);
        }
    }
    return resultView;
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty) View(com.haulmont.cuba.core.global.View)

Example 7 with ViewProperty

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

the class AbstractViewRepositoryTest method intersectPropertiesExtendedViewsTwoLevel.

@Test
public void intersectPropertiesExtendedViewsTwoLevel() {
    View view = metadata.getViewRepository().getView(testMasterEntity, "intersectViewTwo");
    assertTrue(view.containsProperty("detail"));
    ViewProperty detail = view.getProperty("detail");
    assertTrue(detail.getView().containsProperty("embeddable"));
    assertTrue(detail.getView().containsProperty("parts"));
}
Also used : ViewProperty(com.haulmont.cuba.core.global.ViewProperty) View(com.haulmont.cuba.core.global.View) Test(org.junit.Test)

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