Search in sources :

Example 1 with PropertySet

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();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 2 with PropertySet

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);
}
Also used : PropertySet(com.enonic.xp.data.PropertySet) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 3 with 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);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with PropertySet

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;
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) PropertySet(com.enonic.xp.data.PropertySet) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 5 with 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;
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)208 PropertyTree (com.enonic.xp.data.PropertyTree)134 Test (org.junit.jupiter.api.Test)68 Content (com.enonic.xp.content.Content)29 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ContentQuery (com.enonic.xp.content.ContentQuery)6 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5