Search in sources :

Example 11 with DataService

use of com.haulmont.cuba.core.app.DataService in project cuba by cuba-platform.

the class PresentationsImpl method checkLoad.

private void checkLoad() {
    if (presentations == null) {
        DataService ds = AppBeans.get(DataService.NAME);
        LoadContext ctx = new LoadContext(Presentation.class);
        ctx.setView("app");
        UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
        UserSession session = sessionSource.getUserSession();
        User user = session.getCurrentOrSubstitutedUser();
        ctx.setQueryString("select p from sec$Presentation p " + "where p.componentId = :component and (p.user is null or p.user.id = :userId)").setParameter("component", name).setParameter("userId", user.getId());
        final List<Presentation> list = ds.loadList(ctx);
        presentations = new LinkedHashMap<>(list.size());
        for (final Presentation p : list) {
            presentations.put(p.getId(), p);
        }
    }
}
Also used : User(com.haulmont.cuba.security.entity.User) UserSession(com.haulmont.cuba.security.global.UserSession) Presentation(com.haulmont.cuba.security.entity.Presentation) DataService(com.haulmont.cuba.core.app.DataService)

Example 12 with DataService

use of com.haulmont.cuba.core.app.DataService in project cuba by cuba-platform.

the class PresentationsImpl method commit.

@Override
public void commit() {
    if (!needToUpdate.isEmpty() || !needToRemove.isEmpty()) {
        DataService ds = AppBeans.get(DataService.NAME);
        CommitContext ctx = new CommitContext(Collections.unmodifiableSet(needToUpdate), Collections.unmodifiableSet(needToRemove));
        Set<Entity> commitResult = ds.commit(ctx);
        commited(commitResult);
        clearCommitList();
        firePresentationsSetChanged();
    }
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) DataService(com.haulmont.cuba.core.app.DataService)

Aggregations

DataService (com.haulmont.cuba.core.app.DataService)12 Entity (com.haulmont.cuba.core.entity.Entity)6 Test (org.junit.Test)5 LoadContext (com.haulmont.cuba.core.global.LoadContext)4 User (com.haulmont.cuba.security.entity.User)3 UserSession (com.haulmont.cuba.security.global.UserSession)2 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)1 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)1 Server (com.haulmont.cuba.core.entity.Server)1 Frame (com.haulmont.cuba.gui.components.Frame)1 Window (com.haulmont.cuba.gui.components.Window)1 LoginWorker (com.haulmont.cuba.security.app.LoginWorker)1 Permission (com.haulmont.cuba.security.entity.Permission)1 Presentation (com.haulmont.cuba.security.entity.Presentation)1 Role (com.haulmont.cuba.security.entity.Role)1 ScreenHistoryEntity (com.haulmont.cuba.security.entity.ScreenHistoryEntity)1 UserSubstitution (com.haulmont.cuba.security.entity.UserSubstitution)1 TestUserSessionSource (com.haulmont.cuba.testsupport.TestUserSessionSource)1