use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class ModifyProfileHandler method updateUser.
private void updateUser(final EditableUser target, final ScriptValue value) {
if (value == null) {
if (scope != null) {
target.profile.removeProperty(scope);
}
return;
}
final ScriptValueTranslatorResult scriptValueTranslatorResult = new ScriptValueTranslator(false).create(value);
final PropertyTree propertyTree = scriptValueTranslatorResult.getPropertyTree();
if (this.scope == null) {
target.profile = propertyTree;
} else {
target.profile.setSet(scope, propertyTree.getRoot());
}
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class TestDataFixtures method getTestUserWithProfile.
public static User getTestUserWithProfile() {
final PropertySet data = new PropertySet();
data.setString("untouchedString", "originalValue");
data.setBoolean("untouchedBoolean", true);
data.setDouble("untouchedDouble", 2.0);
data.setLong("untouchedLong", 2L);
data.setLink("untouchedLink", Link.from("myLink"));
data.setInstant("untouchedInstant", Instant.parse("2017-01-02T10:00:00Z"));
data.setBinaryReference("untouchedBinaryRef", BinaryReference.from("abcd"));
data.setGeoPoint("untouchedGeoPoint", GeoPoint.from("30,-30"));
data.setLocalDate("untouchedLocalDate", LocalDate.parse("2017-03-24"));
data.setReference("untouchedReference", Reference.from("myReference"));
final PropertyTree profile = new PropertyTree();
profile.setSet("myApp", data);
return User.create().key(PrincipalKey.ofUser(IdProviderKey.from("enonic"), "user1")).displayName("User 1").modifiedTime(Instant.now(clock)).email("user1@enonic.com").login("user1").profile(profile).build();
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class BaseContentHandler method createPropertyTree.
PropertyTree createPropertyTree(final Map<String, Object> value, final ContentTypeName contentTypeName) {
if (value == null) {
return null;
}
if (value.containsKey(ContentPropertyNames.SITECONFIG)) {
Map<String, Object> newValue = new LinkedHashMap<>(value);
newValue.remove(ContentPropertyNames.SITECONFIG);
final PropertyTree result = this.translateToPropertyTree(newValue, contentTypeName);
final List<PropertySet> siteConfigs = createSiteConfigSets(value.get(ContentPropertyNames.SITECONFIG), contentTypeName);
if (siteConfigs != null) {
siteConfigs.forEach(propertySet -> {
final PropertySet newSet = propertySet.copy(result);
result.addSet(ContentPropertyNames.SITECONFIG, newSet);
});
}
return result;
}
return this.translateToPropertyTree(value, contentTypeName);
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class JsonToPropertyTreeTranslatorTest method boolean_value.
@Test
public void boolean_value() throws Exception {
final JsonNode node = loadJson("allInputTypes");
final PropertyTree data = JsonToPropertyTreeTranslator.translate(node);
final Property property = data.getProperty("checkbox");
assertTrue(property.getValue().isBoolean());
assertEquals(true, property.getBoolean());
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class JsonToPropertyTreeTranslatorTest method all_input_types.
@Test
public void all_input_types() throws Exception {
final JsonNode node = loadJson("allInputTypes");
final PropertyTree data = JsonToPropertyTreeTranslator.translate(node);
final Property media = data.getProperty("media");
assertNotNull(media);
assertEquals(ValueTypes.PROPERTY_SET.getName(), media.getType().getName());
}
Aggregations