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


Java AppBeans.get方法代码示例

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


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

示例1: test

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Test
public void test() throws LoginException {
    LoginWorker lw = AppBeans.get(LoginWorker.NAME);

    UserSession userSession = lw.login(USER_NAME, passwordEncryption.getPlainHash(USER_PASSW), Locale.getDefault());
    assertNotNull(userSession);

    boolean permitted = userSession.isPermitted(PermissionType.SCREEN, PERM_TARGET_SCREEN);
    assertFalse(permitted);

    permitted = userSession.isPermitted(PermissionType.SCREEN, "some action");
    assertTrue(permitted); // permitted all if not explicitly denied

    permitted = userSession.isPermitted(PermissionType.ENTITY_ATTR, PERM_TARGET_ATTR);
    assertTrue(permitted); // READ access permitted

    permitted = userSession.isPermitted(PermissionType.ENTITY_ATTR, PERM_TARGET_ATTR, 2);
    assertFalse(permitted); // READ/WRITE access denied
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:20,代码来源:PermissionTest.java

示例2: testSecurityToken

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Test
@Ignore
public void testSecurityToken() throws Exception {
    SecurityTokenManager securityTokenManager = AppBeans.get(SecurityTokenManager.class);
    User user = new User();
    UUID id1 = UUID.randomUUID();
    UUID id2 = UUID.randomUUID();
    UUID id3 = UUID.randomUUID();
    UUID id4 = UUID.randomUUID();
    securityTokenManager.addFiltered(user, "userRoles", id1);
    securityTokenManager.addFiltered(user, "userRoles", id2);
    securityTokenManager.addFiltered(user, "userRoles", id3);
    securityTokenManager.addFiltered(user, "userRoles", id4);

    securityTokenManager.writeSecurityToken(user);
    securityTokenManager.readSecurityToken(user);

    List<Object> userRoles = (List<Object>) BaseEntityInternalAccess.getFilteredData(user).get("userRoles");
    Assert.assertEquals(4, userRoles.size());
    Assert.assertEquals(id1, userRoles.get(0));
    Assert.assertEquals(id2, userRoles.get(1));
    Assert.assertEquals(id3, userRoles.get(2));
    Assert.assertEquals(id4, userRoles.get(3));
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:SecurityTokenManagerTest.java

示例3: activate

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
public void activate() {
    if (timer != null) {
        return;
    }

    Configuration configuration = AppBeans.get(Configuration.NAME);
    int timeout = configuration.getConfig(DesktopConfig.class).getSessionMessagesIntervalSec();

    if (timeout > 0) {
        timer = new Timer(timeout * 1000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                syncMessages();
            }
        });
        timer.start();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:SessionMessagesNotifier.java

示例4: setUp

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    persistence = cont.persistence();
    metadata = cont.metadata();

    try (Transaction tx = persistence.createTransaction()) {
        user = metadata.create(User.class);
        user.setGroup(persistence.getEntityManager().find(Group.class, TestSupport.COMPANY_GROUP_ID));
        user.setLogin("user-" + user.getId());
        persistence.getEntityManager().persist(user);
        tx.commit();
    }

    entityListenerManager = AppBeans.get(EntityListenerManager.class);
    entityListenerManager.addListener(User.class, TestCascadingEntityListener.class);

    TestCascadingEntityListener.events.clear();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:EntityListenerCascadingTest.java

示例5: setCredentialsParams

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
protected void setCredentialsParams(AbstractClientCredentials credentials, Map<String, Object> loginParams) {
    credentials.setClientInfo(makeClientInfo());
    credentials.setClientType(ClientType.DESKTOP);

    Optional<InetAddress> address = Optional.empty();
    try {
        address = Optional.ofNullable(InetAddress.getLocalHost());
    } catch (UnknownHostException e) {
        log.warn("Unable to obtain local IP address", e);
    }

    if (address.isPresent()) {
        credentials.setIpAddress(address.get().getHostAddress());
        credentials.setHostName(address.get().getHostName());
    }

    credentials.setParams(loginParams);

    Configuration configuration = AppBeans.get(Configuration.class);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    if (!globalConfig.getLocaleSelectVisible()) {
        credentials.setOverrideLocale(false);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:Connection.java

示例6: KeyValueMetaProperty

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
public KeyValueMetaProperty(MetaClass metaClass, String name, Class javaClass) {
    this.name = name;
    this.javaClass = javaClass;
    this.metaClass = metaClass;
    this.mandatory = false;

    Metadata metadata = AppBeans.get(Metadata.NAME);
    Session metadataSession = metadata.getSession();
    if (Entity.class.isAssignableFrom(javaClass)) {
        range = new ClassRange(metadataSession.getClass(javaClass));
        this.type = Type.ASSOCIATION;
    } else if (EnumClass.class.isAssignableFrom(javaClass)) {
        @SuppressWarnings("unchecked")
        EnumerationImpl enumeration = new EnumerationImpl(javaClass);
        this.range = new EnumerationRange(enumeration);
        this.type = Type.ENUM;
    } else {
        this.range = new DatatypeRange(Datatypes.getNN(javaClass));
        this.type = Type.DATATYPE;
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:KeyValueMetaProperty.java

示例7: loadConfig

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Override
protected void loadConfig(Element rootElem) {
    for (Element serviceElem : Dom4j.elements(rootElem, "service")) {
        String serviceName = serviceElem.attributeValue("name");
        if (!AppBeans.containsBean(serviceName)) {
            log.error("Service not found: {}", serviceName);
            continue;
        }
        Object service = AppBeans.get(serviceName);
        List<RestMethodInfo> methodInfos = new ArrayList<>();

        for (Element methodElem : Dom4j.elements(serviceElem, "method")) {
            String methodName = methodElem.attributeValue("name");
            // allowAnonymous has a default of "false"
            boolean anonymous = Boolean.parseBoolean(methodElem.attributeValue("allowAnonymous", "false"));
            List<RestMethodParamInfo> params = new ArrayList<>();
            for (Element paramEl : Dom4j.elements(methodElem, "param")) {
                params.add(new RestMethodParamInfo(paramEl.attributeValue("name"), paramEl.attributeValue("type")));
            }
            Method method = _findMethod(serviceName, methodName, params);
            if (method != null) {
                methodInfos.add(new RestMethodInfo(methodName, params, method, anonymous));
            }
        }

        serviceInfosMap.put(serviceName, new RestServiceInfo(serviceName, Collections.unmodifiableList(methodInfos)));
    }
}
 
开发者ID:pfurini,项目名称:cuba-component-forgot-password,代码行数:29,代码来源:RestServicesConfiguration.java

示例8: openEditor

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Override
public Window.Editor openEditor(String windowAlias, Entity item, WindowManager.OpenType openType) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openEditor(windowInfo, item, openType);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:WebFrame.java

示例9: fromString

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
public static HoursAndMinutes fromString(@Nullable String timeStr) {
    if (timeStr == null) {
        return new HoursAndMinutes();
    }

    TimeParser timeParser = AppBeans.get(TimeParser.NAME);
    return timeParser.parseToHoursAndMinutes(timeStr);
}
 
开发者ID:cuba-platform,项目名称:sample-timesheets,代码行数:9,代码来源:HoursAndMinutes.java

示例10: testQuerySubstitutions

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Test
public void testQuerySubstitutions() throws Exception {
    ViewRepository viewRepository = AppBeans.get(ViewRepository.NAME);
    View userView = new View(new View.ViewParams().src(viewRepository.getView(User.class, View.LOCAL)));

    View substitutedUserView = new View(User.class);
    substitutedUserView.addProperty("login");

    View substitutionsView = new View(UserSubstitution.class);
    substitutionsView.addProperty("substitutedUser", substitutedUserView);
    substitutionsView.addProperty("startDate");

    userView.addProperty("substitutions", substitutionsView);

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

        tx.commit();
    }

    assertNotNull(loadedUser);
    assertNotNull(loadedUser.getSubstitutions());
    Assert.assertEquals(1, loadedUser.getSubstitutions().size());

    UserSubstitution loadedSubstitution = loadedUser.getSubstitutions().iterator().next();
    assertEquals(user, loadedSubstitution.getUser());
    assertEquals(substitutedUser, loadedSubstitution.getSubstitutedUser());
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:31,代码来源:LoadSubstitutionsTest.java

示例11: validate

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Override
public void validate(Object value) throws ValidationException {
    BeanValidation beanValidation = AppBeans.get(BeanValidation.NAME);
    Validator validator = beanValidation.getValidator();

    Class[] groups = this.validationGroups;
    if (groups == null || groups.length == 0) {
        groups = new Class[]{Default.class, UiComponentChecks.class};
    }

    @SuppressWarnings("unchecked")
    Set<ConstraintViolation> violations = validator.validateValue(beanClass, beanProperty, value, groups);

    if (!violations.isEmpty()) {
        List<CompositeValidationException.ViolationCause> causes = new ArrayList<>();
        for (ConstraintViolation violation : violations) {
            causes.add(new BeanValidationViolationCause(violation));
        }

        String validationMessage = this.validationErrorMessage;
        if (validationMessage == null) {
            validationMessage = getDefaultErrorMessage();
        }

        throw new CompositeValidationException(validationMessage, causes);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:28,代码来源:BeanValidator.java

示例12: afterRemove

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Override
protected void afterRemove(Set removedItems) {
    super.afterRemove(removedItems);

    Events events = AppBeans.get(Events.NAME);
    for (Object removedItem : removedItems) {
        UserRemovedEvent event = new UserRemovedEvent((User) removedItem);
        events.publish(event);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:11,代码来源:UserRemoveAction.java

示例13: validate

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Override
public void validate(Object value) throws ValidationException {
    if (value != null) {
        ServerInfoService serverInfoService = AppBeans.get(ServerInfoService.NAME);
        Messages messages = AppBeans.get(Messages.NAME);
        try {
            new CronSequenceGenerator(value.toString(), serverInfoService.getTimeZone());
        } catch (Exception e) {
            throw new ValidationException(messages.getMessage(CronValidator.class, "validation.cronInvalid"));
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:13,代码来源:CronValidator.java

示例14: loadAppPropertyEntities

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
public List<AppPropertyEntity> loadAppPropertyEntities() {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    List<AppPropertyEntity> entities = configStorageService.getAppProperties();

    AppPropertiesLocator appPropertiesLocator = AppBeans.get(AppPropertiesLocator.class);
    entities.addAll(appPropertiesLocator.getAppProperties());
    return entities;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:9,代码来源:AppPropertiesDatasource.java

示例15: setUp

import com.haulmont.cuba.core.global.AppBeans; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    addEntityPackage("com.haulmont.cuba");
    setViewConfig("/com/haulmont/cuba/gui/data/impl/testmodel1/test-views.xml");
    setupInfrastructure();

    metadataSession = metadata.getSession();
    dataService = new TestDataSupplier();

    dataService.commitCount = 0;

    new NonStrictExpectations() {
        {
            backgroundWorker.checkUIAccess(); result = null;
            AppBeans.get(BackgroundWorker.NAME); result = backgroundWorker;
            AppBeans.get(BackgroundWorker.class); result = backgroundWorker;
            AppBeans.get(BackgroundWorker.NAME, BackgroundWorker.class); result = backgroundWorker;

            configuration.getConfig(ClientConfig.class); result = clientConfig;

            clientConfig.getCollectionDatasourceDbSortEnabled(); result = true;

            persistenceManager.getMaxFetchUI(anyString); result = 10000;

            PersistenceHelper.isNew(any); result = false;
        }
    };
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:29,代码来源:DsContextTest.java


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