Search in sources :

Example 46 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class InputValidatorTest method validate_correct_input_types.

@Test
public void validate_correct_input_types() {
    // Creates a property set
    final PropertySet propertySet = new PropertySet();
    propertySet.addString("setString", "ost");
    propertySet.addDouble("setDouble", 123d);
    // Creates the correct data to validate
    final PropertyTree data = new PropertyTree();
    data.addString("textLine", "textLine");
    data.addString("color", "#12345");
    data.addString("comboBox", "value2");
    data.addBoolean("checkbox", true);
    data.addString("phone", "+4797773223");
    data.addString("tag", "myTag");
    data.addReference("contentSelector", new Reference(new NodeId()));
    data.addString("contentTypeFilter", "article");
    data.addString("siteConfigurator", "my config here");
    data.addDouble("double", 1.1d);
    data.addLong("long", 12345678910L);
    data.addStrings("stringArray", "a", "b", "c");
    data.addLocalDateTime("localDateTime", LocalDateTime.parse("2015-01-14T10:00:00"));
    data.addInstant("dateTime", DateTimeFormatter.ISO_DATE_TIME.parse("2015-01-15T10:15:00+02:00", Instant::from));
    data.addLocalDate("date", LocalDate.parse("2015-01-15"));
    data.addLocalTime("time", LocalTime.parse("10:00:32.123"));
    data.addGeoPoint("geoPoint", GeoPoint.from("-45,34"));
    data.addString("htmlArea", "<stuff>staff</stuff>");
    // Validates the correct data
    inputValidator.validate(data);
}
Also used : Reference(com.enonic.xp.util.Reference) PropertyTree(com.enonic.xp.data.PropertyTree) NodeId(com.enonic.xp.node.NodeId) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 47 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class FlattenedPageDataUpgrader method addDescriptorBasedComponentData.

private void addDescriptorBasedComponentData(final PropertySet sourceComponentDataSet, final PropertySet targetComponentDataSet) {
    targetComponentDataSet.setString(TGT_DESCRIPTOR_KEY, sourceComponentDataSet.getString(SRC_TEMPLATE_KEY));
    final PropertySet sourceConfigSet = sourceComponentDataSet.getSet(SRC_CONFIG_KEY);
    final String sourceTemplateKey = sourceComponentDataSet.getString(SRC_TEMPLATE_KEY);
    if (sourceConfigSet != null && sourceTemplateKey != null) {
        final PropertySet targetConfigSet = targetComponentDataSet.addSet(TGT_CONFIG_KEY);
        final String applicationKey = getSanitizedApplicationKey(sourceTemplateKey);
        final PropertySet applicationConfigSet = targetConfigSet.addSet(applicationKey);
        final String componentName = getSanitizedComponentName(sourceTemplateKey);
        applicationConfigSet.setSet(componentName, sourceConfigSet);
    }
}
Also used : PropertySet(com.enonic.xp.data.PropertySet)

Example 48 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class IndexConfigUpgrader method upgradePageIndexConfig.

private PatternIndexConfigDocument upgradePageIndexConfig(final PatternIndexConfigDocument sourceDocument, final NodeVersion nodeVersion) {
    final List<PropertySet> components = Lists.newArrayList(nodeVersion.getData().getSets("components"));
    final String descriptorKeyStr = nodeVersion.getData().getString(PropertyPath.from("components.page.descriptor"));
    final DescriptorKey pageDescriptorKey = descriptorKeyStr != null ? DescriptorKey.from(descriptorKeyStr) : null;
    final FlattenedPageIndexUpgrader pageIndexUpgrader = new FlattenedPageIndexUpgrader(pageDescriptorKey, components);
    return pageIndexUpgrader.upgrade(sourceDocument);
}
Also used : PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) FlattenedPageIndexUpgrader(com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)

Example 49 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class FlattenedPageRegionsIndexUpgrader method upgradeComponents.

private void upgradeComponents() {
    this.components.forEach(propertySet -> {
        PropertySet componentSet;
        componentSet = propertySet.getSet(LAYOUT);
        if (componentSet != null) {
            upgradeDescriptorBasedComponent(componentSet, LAYOUT);
        }
        componentSet = propertySet.getSet(PART);
        if (componentSet != null) {
            upgradeDescriptorBasedComponent(componentSet, PART);
        }
    });
}
Also used : PropertySet(com.enonic.xp.data.PropertySet)

Example 50 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class TemplateControllerMappings method handle.

public void handle(final NodeId nodeId, final PropertyTree nodeData) {
    final String contentType = nodeData.getString(CONTENT_TYPE_KEY);
    final PropertySet sourcePageSet = nodeData.getSet(SRC_PAGE_KEY);
    if (sourcePageSet == null || !TEMPLATE_CONTENT_TYPE_VALUE.equals(contentType)) {
        return;
    }
    final String controllerKey = sourcePageSet.getString(SRC_CONTROLLER_KEY);
    if (controllerKey != null) {
        templateControllerMap.put(nodeId.toString(), controllerKey);
    }
}
Also used : PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 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 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 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