Search in sources :

Example 1 with Property

use of com.enonic.xp.data.Property 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());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) JsonNode(com.fasterxml.jackson.databind.JsonNode) Property(com.enonic.xp.data.Property) Test(org.junit.jupiter.api.Test)

Example 2 with Property

use of com.enonic.xp.data.Property 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());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) JsonNode(com.fasterxml.jackson.databind.JsonNode) Property(com.enonic.xp.data.Property) Test(org.junit.jupiter.api.Test)

Example 3 with Property

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

the class ScriptValueTranslatorTest method validateType.

private void validateType(final PropertyTree properties, final String propertyName, final ValueType valueType) {
    final Property prop = properties.getProperty(propertyName);
    assertEquals(valueType, prop.getType());
}
Also used : Property(com.enonic.xp.data.Property)

Example 4 with Property

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

the class PageHandlerWorker method renderShortcut.

private PortalResponse renderShortcut(final Content content) {
    final Property shortcut = content.getData().getProperty(SHORTCUT_TARGET_PROPERTY);
    final Reference target = shortcut == null ? null : shortcut.getReference();
    if (target == null || target.getNodeId() == null) {
        throw WebException.notFound("Missing shortcut target");
    }
    final PageUrlParams pageUrlParams = new PageUrlParams().id(target.toString()).portalRequest(this.request);
    final Multimap<String, String> params = pageUrlParams.getParams();
    params.putAll(this.request.getParams());
    params.putAll(getShortcutParameters(content));
    final String targetUrl = this.portalUrlService.pageUrl(pageUrlParams);
    return PortalResponse.create().status(HttpStatus.TEMPORARY_REDIRECT).header("Location", targetUrl).build();
}
Also used : Reference(com.enonic.xp.util.Reference) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Property(com.enonic.xp.data.Property)

Example 5 with Property

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

the class HtmlAreaContentProcessor method processPageData.

private void processPageData(final Page page, final ContentIds.Builder processedIds) {
    if (page == null) {
        return;
    }
    if (page.hasDescriptor()) {
        final PageDescriptor pageDescriptor = pageDescriptorService.getByKey(page.getDescriptor());
        final Collection<Property> properties = getProperties(page.getConfig(), pageDescriptor.getConfig().getFormItems());
        processDataTree(properties, processedIds);
    }
    if (page.hasRegions()) {
        processRegionsData(page.getRegions(), processedIds);
    }
}
Also used : PageDescriptor(com.enonic.xp.page.PageDescriptor) Property(com.enonic.xp.data.Property)

Aggregations

Property (com.enonic.xp.data.Property)44 PropertyTree (com.enonic.xp.data.PropertyTree)27 Test (org.junit.jupiter.api.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 PropertySet (com.enonic.xp.data.PropertySet)11 InputTypeProperty (com.enonic.xp.inputtype.InputTypeProperty)10 Value (com.enonic.xp.data.Value)4 ValueType (com.enonic.xp.data.ValueType)4 ValueTypes (com.enonic.xp.data.ValueTypes)3 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)3 Input (com.enonic.xp.form.Input)3 Node (com.enonic.xp.node.Node)3 List (java.util.List)3 PropertyPath (com.enonic.xp.data.PropertyPath)2 PropertyVisitor (com.enonic.xp.data.PropertyVisitor)2 Form (com.enonic.xp.form.Form)2 InputType (com.enonic.xp.inputtype.InputType)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 PageDescriptor (com.enonic.xp.page.PageDescriptor)2 RepositoryId (com.enonic.xp.repository.RepositoryId)2