private List<String> nameParts(AppPropertyEntity entity) { List<String> list = new ArrayList<>(); AppPropertyEntity e = entity; while (e != null) { list.add(e.getName()); e = e.getParent(); } Collections.reverse(list); return list; } }
private boolean nameEquals(String[] nameParts, AppPropertyEntity entity) { AppPropertyEntity e = entity; for (int i = nameParts.length - 1; i >= 0; i--) { String name = nameParts[i]; if (!e.getName().equals(name)) return false; if (i > 0) { e = e.getParent(); if (e == null) return false; } } return true; }
@Override protected Collection<AppPropertyEntity> getEntities(Map<String, Object> params) { List<AppPropertyEntity> entities = loadAppPropertyEntities(); String name = (String) params.get("name"); if (StringUtils.isNotEmpty(name)) { entities = entities.stream() .filter(it -> it.getName().toLowerCase().contains(name.toLowerCase())) .collect(Collectors.toList()); } return createEntitiesTree(entities); }
@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()); } }
protected void assignLastUpdated(AppPropertyEntity entity, List<com.haulmont.cuba.core.entity.Config> dbContent) { dbContent.stream() .filter(config -> config.getName().equals(entity.getName())) .findFirst() .ifPresent(config -> { entity.setUpdateTs(config.getUpdateTs() != null ? config.getUpdateTs() : config.getCreateTs()); entity.setUpdatedBy(config.getUpdatedBy() != null ? config.getUpdatedBy() : config.getCreatedBy()); }); }
List<AppPropertyEntity> createEntitiesTree(List<AppPropertyEntity> entities) { List<AppPropertyEntity> resultList = new ArrayList<>(); for (AppPropertyEntity entity : entities) { String[] parts = entity.getName().split("\\."); AppPropertyEntity parent = null; for (int i = 0; i < parts.length; i++) {
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); }
datatype.parse(v); } catch (ParseException e) { log.debug("Cannot parse '{}' with {} datatype, using StringDatatype for property {}", v, datatype, entity.getName()); entity.setDataTypeName(datatypes.getIdByJavaClass(String.class));
public void editValue() { AppPropertiesEdit editor = (AppPropertiesEdit) openWindow("appPropertyEditor", OpenType.DIALOG, ParamsMap.of("item", paramsDs.getItem())); editor.addCloseWithCommitListener(() -> { List<AppPropertyEntity> entities = paramsDs.loadAppPropertyEntities(); for (AppPropertyEntity entity : entities) { if (entity.getName().equals(paramsDs.getItem().getName())) { paramsDs.getItem().setCurrentValue(entity.getCurrentValue()); paramsDs.getItem().setUpdateTs(entity.getUpdateTs()); paramsDs.getItem().setUpdatedBy(entity.getUpdatedBy()); break; } } }); }