当前位置: 首页>>代码示例>>Java>>正文


Java View类代码示例

本文整理汇总了Java中com.haulmont.cuba.core.global.View的典型用法代码示例。如果您正苦于以下问题:Java View类的具体用法?Java View怎么用?Java View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


View类属于com.haulmont.cuba.core.global包,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCrossJoinViewParentReference

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testCrossJoinViewParentReference() throws Exception {
    List<Group> result;
    try (Transaction tx = cont.persistence().createTransaction()) {
        EntityManager em = cont.entityManager();
        View view = new View(Group.class).addProperty("parent");
        TypedQuery<Group> query = em.createQuery("select g from sec$Group g, sec$User u where u.group = g", Group.class);
        query.setView(view);
        result = query.getResultList();
        tx.commit();
    }
    for (Group g : result) {
        g = reserialize(g);
        if (g.equals(rootGroup))
            assertNull(g.getParent());
        else if (g.equals(group))
            assertEquals(rootGroup, g.getParent());
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:EclipseLinkQueriesTest.java

示例2: testReferenceToDeletedEntityThroughOneToMany

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@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());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:18,代码来源:SoftDeleteTest.java

示例3: CollectionDsWrapper

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public CollectionDsWrapper(CollectionDatasource datasource, Collection<MetaPropertyPath> properties,
                           boolean autoRefresh, CollectionDsListenersWrapper collectionDsListenersWrapper) {
    this.datasource = datasource;
    this.autoRefresh = autoRefresh;
    this.collectionDsListenersWrapper = collectionDsListenersWrapper;

    final View view = datasource.getView();
    final MetaClass metaClass = datasource.getMetaClass();

    if (properties == null) {
        createProperties(view, metaClass);
    } else {
        this.properties.addAll(properties);
    }

    cdsItemPropertyChangeListener = createItemPropertyChangeListener();
    cdsStateChangeListener = createStateChangeListener();
    cdsCollectionChangeListener = createCollectionChangeListener();

    collectionDsListenersWrapper.addItemPropertyChangeListener(cdsItemPropertyChangeListener);
    collectionDsListenersWrapper.addStateChangeListener(cdsStateChangeListener);
    collectionDsListenersWrapper.addCollectionChangeListener(cdsCollectionChangeListener);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:CollectionDsWrapper.java

示例4: testCrossJoinWithToManyView

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testCrossJoinWithToManyView() throws Exception {
    List<Group> result;
    try (Transaction tx = cont.persistence().createTransaction()) {
        EntityManager em = cont.entityManager();
        View view = new View(Group.class).addProperty("constraints");
        TypedQuery<Group> query = em.createQuery("select g from sec$Group g, sec$User u where u.group = g", Group.class);
        query.setView(view);
        result = query.getResultList();
        tx.commit();
    }
    for (Group group : result) {
        group = reserialize(group);
        group.getConstraints().size();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:EclipseLinkQueriesTest.java

示例5: getSingleResultFromCache

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
/**
 * Get single query results from query cache by specified {@code queryKey}
 * If query is cached and no results found exception is thrown
 */
@SuppressWarnings("unchecked")
public <T> T getSingleResultFromCache(QueryKey queryKey, List<View> views) {
    log.debug("Looking for query in cache: {}", queryKey.printDescription());
    QueryResult queryResult = queryCache.get(queryKey);
    if (queryResult != null) {
        MetaClass metaClass = metadata.getClassNN(queryResult.getType());
        if (!metadata.getTools().isCacheable(metaClass)) {
            log.warn("Using cacheable query without entity cache for {}", queryResult.getType());
        }
        if (queryResult.getException() != null) {
            RuntimeException ex = queryResult.getException();
            ex.fillInStackTrace();
            throw queryResult.getException();
        }
        EntityManager em = persistence.getEntityManager();
        for (Object id : queryResult.getResult()) {
            return (T) em.find(metaClass.getJavaClass(), id, views.toArray(new View[views.size()]));
        }
    }
    log.debug("Query results are not found in cache: {}", queryKey.printDescription());
    return null;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:QueryCacheManager.java

示例6: testCheckLoaded

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testCheckLoaded() {
    Server server = new Server();

    cont.persistence().runInTransaction((em) -> {
        em.persist(server);
    });

    View view = new View(Server.class).addProperty("name").addProperty("data")
            .setLoadPartialEntities(true);
    Server reloadedServer = cont.persistence().callInTransaction((em) -> {
        return em.find(Server.class, server.getId(), view);
    });

    PersistenceHelper.checkLoaded(reloadedServer, "name"); // fine

    try {
        PersistenceHelper.checkLoaded(reloadedServer, "data", "running");
        Assert.fail("Must throw exception");
    } catch (IllegalArgumentException e) {
        Assert.assertTrue(e.getMessage().contains("Server.running"));
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:PersistenceHelperTest.java

示例7: test

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void test() throws Exception {
    User user = metadata.create(User.class);
    try (Transaction tx = persistence.createTransaction()) {
        EntityManager em = persistence.getEntityManager();

        user.setGroup(em.getReference(Group.class, UUID.fromString("0fa2b1a5-1d68-4d69-9fbd-dff348347f93")));
        user.setLogin("u-" + user.getId());
        em.persist(user);

        TypedQuery<User> query = em.createQuery("select u from sec$User u where u.loginLowerCase = :login", User.class);
        query.setParameter("login", user.getLogin());
        query.setViewName(View.LOCAL); // setting a view leads to using FlushModeType.AUTO - see QueryImpl.getQuery()
        List<User> list = query.getResultList();
        assertEquals(1, list.size());
        assertEquals(user, list.get(0));

        tx.commit();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:EntityListenerImplicitFlushTest.java

示例8: testFind

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testFind() throws Exception {

    View view = new View(User.class, false)
            .addProperty("name")
            .addProperty("login")
            .addProperty("group", new View(Group.class)
                    .addProperty("name"));

    User user;

    try (Transaction tx = cont.persistence().createTransaction()) {
        EntityManager em = cont.persistence().getEntityManager();
        user = em.find(User.class, userId, view);

        tx.commit();
    }
    user = reserialize(user);

    assertNotNull(user.getCreatedBy());
    assertNotNull(user.getGroup());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:EntityManagerTest.java

示例9: loadUserSetting

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
private UserSetting loadUserSetting() throws Exception {
    UserSetting us;
    View usView = new View(UserSetting.class)
            .addProperty("name")
            .addProperty("user", new View(User.class)
                    .addProperty("login"));
    try (Transaction tx = cont.persistence().createTransaction()) {
        us = cont.entityManager().find(UserSetting.class, this.userSetting.getId(), usView);
        assertNotNull(us);
        tx.commit();
    }
    us = reserialize(us);
    assertEquals(userSetting, us);
    assertEquals(user, us.getUser());
    return us;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:EntityCacheTestClass.java

示例10: testDatasource

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testDatasource() {
    OptionsList component = factory.createComponent(OptionsList.class);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());

    component.setDatasource(testDs, "group");
    assertNotNull(component.getDatasource());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:OptionsListTest.java

示例11: getTestCollectionDatasource

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
protected CollectionDatasource<Group, UUID> getTestCollectionDatasource() {
    // noinspection unchecked
    CollectionDatasource<Group, UUID> collectionDatasource = new DsBuilder()
            .setId("testDs")
            .setJavaClass(Group.class)
            .setView(viewRepository.getView(Group.class, View.LOCAL))
            .setRefreshMode(CollectionDatasource.RefreshMode.NEVER)
            .setAllowCommit(false)
            .buildCollectionDatasource();

    for (int i = 0; i < 3; i++) {
        Group group = metadata.create(Group.class);
        group.setName("Group #" + (i + 1));

        Group parentGroup = metadata.create(Group.class);
        parentGroup.setName("Parent group #" + (i + 1));
        group.setParent(parentGroup);

        collectionDatasource.addItem(group);
    }
    ((CollectionDatasourceImpl) collectionDatasource).valid();

    return collectionDatasource;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:DsApiConsistencyTestCase.java

示例12: testDatasource

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testDatasource() {
    OptionsGroup component = factory.createComponent(OptionsGroup.class);

    //noinspection unchecked
    Datasource<User> testDs = new DsBuilder()
            .setId("testDs")
            .setJavaClass(User.class)
            .setView(viewRepository.getView(User.class, View.LOCAL))
            .buildDatasource();

    testDs.setItem(new User());
    ((DatasourceImpl) testDs).valid();

    assertNull(component.getValue());

    component.setDatasource(testDs, "group");
    assertNotNull(component.getDatasource());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:OptionsGroupTest.java

示例13: intersectViews

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
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;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:ViewHelper.java

示例14: migrateAttachmentsBatch

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
protected int migrateAttachmentsBatch() {
    List<SendingAttachment> resultList;
    Transaction tx = persistence.createTransaction();
    try {
        EntityManager em = persistence.getEntityManager();
        String qstr = "select a from sys$SendingAttachment a where a.content is not null";
        TypedQuery<SendingAttachment> query = em.createQuery(qstr, SendingAttachment.class);
        query.setMaxResults(50);
        query.setViewName(View.MINIMAL);

        resultList = query.getResultList();

        tx.commit();
    } finally {
        tx.end();
    }

    if (!resultList.isEmpty()) {
        emailer.migrateAttachmentsToFileStorage(resultList);
    }

    return resultList.size();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:24,代码来源:Emailer.java

示例15: testLoadDeletedObject

import com.haulmont.cuba.core.global.View; //导入依赖的package包/类
@Test
public void testLoadDeletedObject() {
    View taskView_Message = new View(SoftDelete_Task.class).addProperty("message");
    View taskView_Service = new View(SoftDelete_Task.class)
            .addProperty("service", new View(SoftDelete_Service.class).addProperty("code"));
    View taskValueView = new View(SoftDelete_TaskValue.class)
            .addProperty("task", taskView_Message);

    View projectView = new View(SoftDelete_Project.class)
            .addProperty("name")
            .addProperty("aValue", taskValueView)
            .addProperty("task", taskView_Service);

    LoadContext<SoftDelete_Project> loadContext = new LoadContext<>(SoftDelete_Project.class)
            .setView(projectView).setId(projectId);
    SoftDelete_Project project = dataManager.load(loadContext);

    Assert.assertNotNull(project);
    Assert.assertNotNull(project.getTask());
    Assert.assertTrue(project.getTask().isDeleted());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:SoftDeleteNotFoundDeletedTest.java


注:本文中的com.haulmont.cuba.core.global.View类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。