use of com.haulmont.cuba.core.entity.KeyValueEntity in project cuba by cuba-platform.
the class CustomValueCollectionDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
Collection<KeyValueEntity> entities = getEntities(params);
detachListener(data.values());
data.clear();
if (entities != null) {
for (KeyValueEntity entity : entities) {
data.put(entity.getId(), entity);
attachListener(entity);
entity.setMetaClass(metaClass);
}
}
}
use of com.haulmont.cuba.core.entity.KeyValueEntity in project cuba by cuba-platform.
the class CustomValueHierarchicalDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
Collection<KeyValueEntity> entities = getEntities(params);
detachListener(data.values());
data.clear();
if (entities != null) {
for (KeyValueEntity entity : entities) {
data.put(entity.getId(), entity);
attachListener(entity);
entity.setMetaClass(metaClass);
}
}
}
use of com.haulmont.cuba.core.entity.KeyValueEntity in project cuba by cuba-platform.
the class ValueDatasourceDelegate method afterLoadValues.
protected void afterLoadValues(Map<String, Object> params, ValueLoadContext context, List<KeyValueEntity> entities) {
ds.detachListener(ds.data.values());
ds.data.clear();
boolean hasEnumerations = ds.metaClass.getOwnProperties().stream().anyMatch(p -> p.getRange().isEnum());
if (!hasEnumerations) {
for (KeyValueEntity entity : entities) {
ds.data.put(entity.getId(), entity);
ds.attachListener(entity);
entity.setMetaClass(ds.metaClass);
}
} else {
List<MetaProperty> enumProperties = getEnumProperties(ds.metaClass);
for (KeyValueEntity entity : entities) {
convertEnumValues(entity, enumProperties);
ds.data.put(entity.getId(), entity);
ds.attachListener(entity);
entity.setMetaClass(ds.metaClass);
}
}
}
use of com.haulmont.cuba.core.entity.KeyValueEntity in project cuba by cuba-platform.
the class AboutWindow method init.
@Override
public void init(Map<String, Object> params) {
BuildInfo.Content content = buildInfo.getContent();
for (Map.Entry<String, String> entry : content.getProperties().entrySet()) {
KeyValueEntity entity = new KeyValueEntity();
String name = messages.getMainMessage("buildInfo." + entry.getKey());
if (name.equals("buildInfo." + entry.getKey()))
name = entry.getKey();
entity.setValue("name", name);
entity.setValue("value", entry.getValue());
buildInfoDs.includeItem(entity);
}
}
use of com.haulmont.cuba.core.entity.KeyValueEntity in project cuba by cuba-platform.
the class NonEntityQueryTest method testConstraints.
@Test
public void testConstraints() throws Exception {
LoginWorker lw = AppBeans.get(LoginWorker.NAME);
UserSession userSession = lw.login(USER_NAME_2, passwordEncryption.getPlainHash(USER_PASSWORD), Locale.getDefault());
assertNotNull(userSession);
UserSessionSource uss = AppBeans.get(UserSessionSource.class);
UserSession savedUserSession = uss.getUserSession();
((TestUserSessionSource) uss).setUserSession(userSession);
try {
ValueLoadContext context = ValueLoadContext.create();
context.setQueryString("select s.name from sys$Server s");
context.addProperty("name");
List<KeyValueEntity> list = dataManager.secure().loadValues(context);
assertEquals(0, list.size());
} finally {
((TestUserSessionSource) uss).setUserSession(savedUserSession);
}
}
Aggregations