Search in sources :

Example 6 with AppPropertyEntity

use of com.haulmont.cuba.core.config.AppPropertyEntity in project cuba by cuba-platform.

the class AppPropertiesEdit method ok.

public void ok() {
    AppPropertyEntity appPropertyEntity = appPropertyDs.getItem();
    // Save property through the client-side cache to ensure it is updated in the cache immediately
    Configuration configuration = AppBeans.get(Configuration.class);
    ConfigStorageService configStorageService = ((ConfigurationClientImpl) configuration).getConfigStorageService();
    configStorageService.setDbProperty(appPropertyEntity.getName(), appPropertyEntity.getCurrentValue());
    close(COMMIT_ACTION_ID);
}
Also used : AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity) Configuration(com.haulmont.cuba.core.global.Configuration) ConfigurationClientImpl(com.haulmont.cuba.client.sys.ConfigurationClientImpl) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService)

Example 7 with AppPropertyEntity

use of com.haulmont.cuba.core.config.AppPropertyEntity in project cuba by cuba-platform.

the class AppPropertiesExport method init.

@Override
public void init(Map<String, Object> params) {
    getDialogOptions().setHeight("400px");
    StringBuilder sb = new StringBuilder();
    for (AppPropertyEntity entity : exported) {
        sb.append("insert into SYS_CONFIG (ID, CREATE_TS, CREATED_BY, VERSION, NAME, VALUE_)\n");
        sb.append("values ('").append(entity.getId()).append("', current_timestamp, '").append(uss.getUserSession().getUser().getLogin()).append("', 0, '").append(entity.getName()).append("', '").append(entity.getCurrentValue()).append("');\n\n");
    }
    scriptArea.setValue(sb.toString());
}
Also used : AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity)

Example 8 with AppPropertyEntity

use of com.haulmont.cuba.core.config.AppPropertyEntity in project cuba by cuba-platform.

the class AppPropertiesBrowse method init.

@Override
public void init(Map<String, Object> params) {
    paramsDs.addItemChangeListener(e -> {
        boolean enabled = e.getItem() != null && !e.getItem().getCategory();
        editValueAction.setEnabled(enabled);
        exportBtn.setEnabled(enabled);
    });
    paramsTable.setItemClickAction(editValueAction);
    paramsTable.sort("name", SortDirection.ASCENDING);
    searchField.addValueChangeListener(e -> {
        paramsDs.refresh(ParamsMap.of("name", e.getValue()));
        if (StringUtils.isNotEmpty((String) e.getValue())) {
            paramsTable.expandAll();
        }
    });
    refreshAction.setBeforeRefreshHandler(() -> lastSelected = paramsTable.getSingleSelected());
    refreshAction.setAfterRefreshHandler(() -> {
        if (lastSelected != null) {
            for (AppPropertyEntity entity : paramsDs.getItems()) {
                if (entity.getName().equals(lastSelected.getName())) {
                    paramsTable.expand(entity.getId());
                    paramsTable.setSelected(entity);
                }
            }
        }
    });
}
Also used : AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity)

Example 9 with AppPropertyEntity

use of com.haulmont.cuba.core.config.AppPropertyEntity in project cuba by cuba-platform.

the class AppPropertiesDatasource method loadAppPropertyEntities.

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;
}
Also used : AppPropertiesLocator(com.haulmont.cuba.core.config.AppPropertiesLocator) AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService)

Aggregations

AppPropertyEntity (com.haulmont.cuba.core.config.AppPropertyEntity)9 ConfigStorageService (com.haulmont.cuba.core.app.ConfigStorageService)3 AppPropertiesLocator (com.haulmont.cuba.core.config.AppPropertiesLocator)2 Test (org.junit.Test)2 ConfigurationClientImpl (com.haulmont.cuba.client.sys.ConfigurationClientImpl)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 CustomHierarchicalDatasource (com.haulmont.cuba.gui.data.impl.CustomHierarchicalDatasource)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang.StringUtils)1