Search in sources :

Example 1 with ExtraData

use of com.enonic.xp.content.ExtraData in project xp by enonic.

the class TestDataFixtures method newContent.

public static Content newContent() {
    final Content.Builder builder = Content.create();
    builder.id(ContentId.from("123456"));
    builder.name("mycontent");
    builder.displayName("My Content");
    builder.parentPath(ContentPath.from("/a/b"));
    builder.modifier(PrincipalKey.from("user:system:admin"));
    builder.modifiedTime(Instant.ofEpochSecond(0));
    builder.creator(PrincipalKey.from("user:system:admin"));
    builder.createdTime(Instant.ofEpochSecond(0));
    builder.language(Locale.ENGLISH);
    builder.data(newPropertyTree());
    builder.addExtraData(new ExtraData(XDataName.from("com.enonic.myapplication:myschema"), newTinyPropertyTree()));
    builder.page(newPage());
    return builder.build();
}
Also used : Content(com.enonic.xp.content.Content) ExtraData(com.enonic.xp.content.ExtraData)

Example 2 with ExtraData

use of com.enonic.xp.content.ExtraData in project xp by enonic.

the class ProjectContentEventListenerTest method createExtraData.

private ExtraData createExtraData() {
    final PropertyTree mediaData = new PropertyTree();
    mediaData.setLong(IMAGE_INFO_PIXEL_SIZE, 300L);
    mediaData.setLong(IMAGE_INFO_IMAGE_HEIGHT, 200L);
    mediaData.setLong(IMAGE_INFO_IMAGE_WIDTH, 300L);
    mediaData.setLong(MEDIA_INFO_BYTE_SIZE, 100000L);
    return new ExtraData(XDataName.from("myApp:xData"), mediaData);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) ExtraData(com.enonic.xp.content.ExtraData)

Example 3 with ExtraData

use of com.enonic.xp.content.ExtraData in project xp by enonic.

the class PageRendererTest method createFragmentContent.

private Content createFragmentContent(final String id, final String name) {
    final PropertyTree metadata = new PropertyTree();
    metadata.setLong("myProperty", 1L);
    return Content.create().id(ContentId.from(id)).parentPath(ContentPath.ROOT).name(name).valid(true).createdTime(Instant.parse("2013-08-23T12:55:09.162Z")).creator(PrincipalKey.from("user:system:admin")).owner(PrincipalKey.from("user:myStore:me")).language(Locale.ENGLISH).displayName("My Content").modifiedTime(Instant.parse("2013-08-23T12:55:09.162Z")).modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.fragment()).addExtraData(new ExtraData(XDataName.from("myApplication:myField"), metadata)).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) ExtraData(com.enonic.xp.content.ExtraData)

Example 4 with ExtraData

use of com.enonic.xp.content.ExtraData in project xp by enonic.

the class ContentMappingConstraint method getXData.

private PropertyTree getXData(final ExtraDatas xDatas, final String appPrefix, final String name) {
    if (xDatas == null) {
        return null;
    }
    try {
        final ApplicationKey app = ExtraData.fromApplicationPrefix(appPrefix);
        final XDataName xDataName = XDataName.from(app, name);
        final ExtraData extraData = xDatas.getMetadata(xDataName);
        if (extraData == null) {
            return null;
        }
        return extraData.getData();
    } catch (Exception e) {
        return null;
    }
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ExtraData(com.enonic.xp.content.ExtraData) XDataName(com.enonic.xp.schema.xdata.XDataName) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 5 with ExtraData

use of com.enonic.xp.content.ExtraData in project xp by enonic.

the class ContentValidatorParamsTest method builder.

@Test
void builder() {
    final ContentValidatorParams params = ContentValidatorParams.create().contentType(ContentType.create().name("ct").superType(ContentTypeName.unstructured()).build()).contentId(ContentId.from("ci")).data(new PropertyTree()).createAttachments(CreateAttachments.create().add(CreateAttachment.create().name("att").byteSource(ByteSource.empty()).build()).build()).extraDatas(ExtraDatas.create().add(new ExtraData(XDataName.from("xd"), new PropertyTree())).build()).build();
    assertEquals(params.getContentType().getName(), ContentTypeName.from("ct"));
    assertEquals(params.getContentId(), ContentId.from("ci"));
    assertNotNull(params.getData());
    assertThat(params.getCreateAttachments()).extracting("name").containsExactly("att");
    assertThat(params.getExtraDatas()).extracting("name").containsExactly(XDataName.from("xd"));
}
Also used : ContentValidatorParams(com.enonic.xp.content.ContentValidatorParams) PropertyTree(com.enonic.xp.data.PropertyTree) ExtraData(com.enonic.xp.content.ExtraData) Test(org.junit.jupiter.api.Test)

Aggregations

ExtraData (com.enonic.xp.content.ExtraData)31 PropertyTree (com.enonic.xp.data.PropertyTree)18 Test (org.junit.jupiter.api.Test)10 XData (com.enonic.xp.schema.xdata.XData)8 XDataName (com.enonic.xp.schema.xdata.XDataName)8 Content (com.enonic.xp.content.Content)7 CreateContentParams (com.enonic.xp.content.CreateContentParams)5 ExtraDatas (com.enonic.xp.content.ExtraDatas)5 ApplicationKey (com.enonic.xp.app.ApplicationKey)4 Media (com.enonic.xp.content.Media)4 ProcessCreateParams (com.enonic.xp.content.processor.ProcessCreateParams)4 ProcessCreateResult (com.enonic.xp.content.processor.ProcessCreateResult)4 PropertySet (com.enonic.xp.data.PropertySet)4 Attachment (com.enonic.xp.attachment.Attachment)3 FormItem (com.enonic.xp.form.FormItem)3 Input (com.enonic.xp.form.Input)3 GeoPoint (com.enonic.xp.util.GeoPoint)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Map (java.util.Map)3 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)2