use of com.enonic.xp.data.PropertySet 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.PropertySet in project xp by enonic.
the class JsonToPropertyTreeTranslator method mapSet.
private static Value mapSet(final JsonNode value) {
PropertySet propertySet = new PropertySet();
value.fields().forEachRemaining((field) -> {
if (field.getValue().isArray()) {
for (final JsonNode arrayNode : field.getValue()) {
propertySet.addProperty(field.getKey(), resolveCoreValue(arrayNode));
}
} else {
propertySet.addProperty(field.getKey(), resolveCoreValue(field.getValue()));
}
});
return ValueFactory.newPropertySet(propertySet);
}
use of com.enonic.xp.data.PropertySet 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.PropertySet in project xp by enonic.
the class BaseContentHandler method createSitePropertySet.
private PropertySet createSitePropertySet(final Map<String, Object> siteConfig, final ContentTypeName contentTypeName) {
if (siteConfig == null) {
return null;
}
final ApplicationKey applicationKey = ApplicationKey.from(siteConfig.get("applicationKey").toString());
final Map<String, ?> appConfigData = (Map<String, ?>) siteConfig.get("config");
if (appConfigData == null) {
return null;
}
final PropertySet propertySet = new PropertySet();
propertySet.addString("applicationKey", applicationKey.toString());
propertySet.addSet("config", this.translateToPropertyTree(appConfigData, applicationKey, contentTypeName).getRoot());
return propertySet;
}
use of com.enonic.xp.data.PropertySet in project xp by enonic.
the class TestDataFixtures method getProfile.
private static PropertyTree getProfile() {
final PropertySet appPropertySet = new PropertySet();
appPropertySet.setString("subString", "subStringValue");
appPropertySet.setLong("subLong", 123L);
final PropertyTree profile = new PropertyTree();
profile.setSet("myApp", appPropertySet);
profile.setString("string", "stringValue");
return profile;
}
Aggregations