Search in sources :

Example 51 with View

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

the class SoftDeleteTest method testReferenceToDeletedEntityThroughOneToMany.

@Test
public void testReferenceToDeletedEntityThroughOneToMany() throws Exception {
    View userRoleView = new View(UserRole.class).addProperty("role", new View(Role.class).addProperty("deleteTs"));
    View userView = new View(User.class).addProperty("userRoles", userRoleView);
    Role deleted = cont.persistence().callInTransaction((em) -> em.find(Role.class, role3Id));
    assertNull(deleted);
    UserRole userRole = cont.persistence().callInTransaction((em) -> em.find(UserRole.class, userRole3Id, userRoleView));
    assertNotNull(userRole.getRole());
    assertEquals(role3Id, userRole.getRole().getId());
    assertTrue(userRole.getRole().isDeleted());
    User user = cont.persistence().callInTransaction((em) -> em.find(User.class, user1Id, userView));
    assertEquals(role3Id, user.getUserRoles().iterator().next().getRole().getId());
    Assert.assertTrue(user.getUserRoles().iterator().next().getRole().isDeleted());
}
Also used : View(com.haulmont.cuba.core.global.View)

Example 52 with View

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

the class EntitiesMetadataControllerManager method getAllViewsForMetaClass.

public String getAllViewsForMetaClass(String entityName) {
    MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
    StringBuilder sb = new StringBuilder();
    sb.append("[");
    List<String> jsonViews = new ArrayList<>();
    for (String viewName : viewRepository.getViewNames(metaClass)) {
        View view = viewRepository.getView(metaClass, viewName);
        jsonViews.add(viewSerializationAPI.toJson(view));
    }
    sb.append(Joiner.on(",").join(jsonViews));
    sb.append("]");
    return sb.toString();
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) View(com.haulmont.cuba.core.global.View)

Example 53 with View

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

the class EntitiesMetadataControllerManager method getView.

public String getView(String entityName, String viewName) {
    MetaClass metaClass = restControllersUtils.getMetaClass(entityName);
    View view = viewRepository.findView(metaClass, viewName);
    if (view == null) {
        throw new RestAPIException("View not found", String.format("View %s for metaClass %s not found", viewName, entityName), HttpStatus.NOT_FOUND);
    }
    return viewSerializationAPI.toJson(view);
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) RestAPIException(com.haulmont.restapi.exception.RestAPIException) View(com.haulmont.cuba.core.global.View)

Example 54 with View

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

the class AbstractViewRepositoryTest method notIntersectPropertiesExtendedViews.

@Test
public void notIntersectPropertiesExtendedViews() {
    View view = metadata.getViewRepository().getView(testMasterEntity, "detailAndDetails");
    assertNotNull(view);
    assertTrue(view.containsProperty("detail"));
    assertTrue(view.containsProperty("details"));
}
Also used : View(com.haulmont.cuba.core.global.View) Test(org.junit.Test)

Example 55 with View

use of com.haulmont.cuba.core.global.View 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

View (com.haulmont.cuba.core.global.View)55 Test (org.junit.Test)24 EntityManager (com.haulmont.cuba.core.EntityManager)22 Transaction (com.haulmont.cuba.core.Transaction)21 User (com.haulmont.cuba.security.entity.User)19 Group (com.haulmont.cuba.security.entity.Group)10 MetaClass (com.haulmont.chile.core.model.MetaClass)5 ViewProperty (com.haulmont.cuba.core.global.ViewProperty)5 UserRole (com.haulmont.cuba.security.entity.UserRole)5 SoftDeleteOneToOneA (com.haulmont.cuba.testmodel.softdelete_one_to_one.SoftDeleteOneToOneA)3 MetaProperty (com.haulmont.chile.core.model.MetaProperty)2 Entity (com.haulmont.cuba.core.entity.Entity)2 ViewRepository (com.haulmont.cuba.core.global.ViewRepository)2 Role (com.haulmont.cuba.security.entity.Role)2 SoftDeleteOneToOneB (com.haulmont.cuba.testmodel.softdelete_one_to_one.SoftDeleteOneToOneB)2 QueryRunner (com.haulmont.bali.db.QueryRunner)1 MetadataObject (com.haulmont.chile.core.model.MetadataObject)1 DynamicAttributesMetaProperty (com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesMetaProperty)1 QueryResult (com.haulmont.cuba.core.entity.QueryResult)1 Server (com.haulmont.cuba.core.entity.Server)1