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;
}
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);
}
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()));
}
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();
}
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;
}
Aggregations