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