Search in sources :

Example 11 with ExtraData

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

the class ExtraDataSerializer method fromData.

@Override
public ExtraDatas fromData(final PropertySet metadataSet) {
    if (metadataSet != null) {
        final ExtraDatas.Builder extradatasBuilder = ExtraDatas.create();
        for (final String metadataApplicationPrefix : metadataSet.getPropertyNames()) {
            final PropertySet xDataApplication = metadataSet.getSet(metadataApplicationPrefix);
            for (final String metadataLocalName : xDataApplication.getPropertyNames()) {
                final ApplicationKey applicationKey = ExtraData.fromApplicationPrefix(metadataApplicationPrefix);
                final XDataName metadataName = XDataName.from(applicationKey, metadataLocalName);
                extradatasBuilder.add(new ExtraData(metadataName, xDataApplication.getSet(metadataLocalName).toTree()));
            }
        }
        return extradatasBuilder.build();
    }
    return null;
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ExtraDatas(com.enonic.xp.content.ExtraDatas) PropertySet(com.enonic.xp.data.PropertySet) ExtraData(com.enonic.xp.content.ExtraData) XDataName(com.enonic.xp.schema.xdata.XDataName)

Example 12 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 13 with ExtraData

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

the class ContentOutboundDependenciesIdsResolverTest method resolve_outbound_from_xdata.

@Test
public void resolve_outbound_from_xdata() throws Exception {
    final PropertyTree data = new PropertyTree();
    final Content folderRefContent1 = createContent("folderRefContent1", data, ContentTypeName.folder());
    final Content folderRefContent2 = createContent("folderRefContent2", data, ContentTypeName.folder());
    final Content siteRefContent1 = createContent("siteRefContent1", data, ContentTypeName.site());
    data.addReference("myRef1", Reference.from(folderRefContent1.getId().toString()));
    data.addReference("myRef2", Reference.from(folderRefContent2.getId().toString()));
    data.addReference("myRef3", Reference.from(siteRefContent1.getId().toString()));
    data.addReference("refToMyself", Reference.from("contentId"));
    final Content content = createContent("contentId", new PropertyTree(), ContentTypeName.site(), ExtraDatas.create().add(new ExtraData(XDataName.from("x-data"), data)).build());
    Mockito.when(contentService.getByIds(Mockito.any())).thenReturn(Contents.from(folderRefContent1, folderRefContent2, siteRefContent1));
    Mockito.when(contentService.getById(content.getId())).thenReturn(content);
    final ContentIds result = resolver.resolve(content.getId());
    assertEquals(result.getSize(), 3);
    assertTrue(result.contains(folderRefContent1.getId()));
    assertTrue(result.contains(folderRefContent2.getId()));
    assertTrue(result.contains(siteRefContent1.getId()));
}
Also used : Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIds(com.enonic.xp.content.ContentIds) ExtraData(com.enonic.xp.content.ExtraData) Test(org.junit.jupiter.api.Test)

Example 14 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 15 with ExtraData

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

the class MediaInfoServiceTest method createMedia.

private Media createMedia(String name, ContentPath parentPath, boolean addOrientation) {
    final PropertyTree imageDataTree = new PropertyTree();
    if (addOrientation) {
        imageDataTree.addProperty(ContentPropertyNames.ORIENTATION, ValueFactory.newString("3"));
    }
    final ExtraData eData = new ExtraData(MediaInfo.CAMERA_INFO_METADATA_NAME, imageDataTree);
    final Content content = Content.create(ContentTypeName.imageMedia()).name(name).parentPath(parentPath).addExtraData(eData).build();
    final Media media = (Media) content;
    return media;
}
Also used : Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Media(com.enonic.xp.content.Media) ExtraData(com.enonic.xp.content.ExtraData)

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