Search in sources :

Example 1 with XDatas

use of com.enonic.xp.schema.xdata.XDatas in project xp by enonic.

the class ImageContentProcessor method processCreate.

@Override
public ProcessCreateResult processCreate(final ProcessCreateParams params) {
    final CreateContentParams createContentParams = params.getCreateContentParams();
    final MediaInfo mediaInfo = params.getMediaInfo();
    final CreateAttachments originalAttachments = createContentParams.getCreateAttachments();
    Preconditions.checkArgument(originalAttachments.getSize() == 1, "Expected only one attachment");
    final CreateAttachment sourceAttachment = originalAttachments.first();
    final XDatas contentXDatas = getXDatas(createContentParams.getType());
    ExtraDatas extraDatas = null;
    if (mediaInfo != null) {
        extraDatas = extractMetadata(mediaInfo, contentXDatas, sourceAttachment);
    }
    final CreateAttachments.Builder builder = CreateAttachments.create();
    builder.add(sourceAttachment);
    return new ProcessCreateResult(CreateContentParams.create(createContentParams).createAttachments(builder.build()).extraDatas(extraDatas).build());
}
Also used : CreateAttachments(com.enonic.xp.attachment.CreateAttachments) MediaInfo(com.enonic.xp.media.MediaInfo) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) CreateContentParams(com.enonic.xp.content.CreateContentParams) XDatas(com.enonic.xp.schema.xdata.XDatas) ExtraDatas(com.enonic.xp.content.ExtraDatas) ProcessCreateResult(com.enonic.xp.content.processor.ProcessCreateResult)

Example 2 with XDatas

use of com.enonic.xp.schema.xdata.XDatas in project xp by enonic.

the class XDataServiceImplTest method testSystemMixins.

@Test
public void testSystemMixins() {
    XDatas xDatas = service.getAll();
    assertNotNull(xDatas);
    assertEquals(3, xDatas.getSize());
    xDatas = service.getByApplication(ApplicationKey.MEDIA_MOD);
    assertNotNull(xDatas);
    assertEquals(2, xDatas.getSize());
    XData xData = service.getByName(MediaInfo.GPS_INFO_METADATA_NAME);
    assertNotNull(xData);
    xData = service.getByName(MediaInfo.IMAGE_INFO_METADATA_NAME);
    assertNotNull(xData);
    xData = service.getByName(MediaInfo.CAMERA_INFO_METADATA_NAME);
    assertNotNull(xData);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) XData(com.enonic.xp.schema.xdata.XData) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 3 with XDatas

use of com.enonic.xp.schema.xdata.XDatas in project xp by enonic.

the class XDataServiceImplTest method testEmpty.

@Test
public void testEmpty() {
    final XDatas types1 = this.service.getAll();
    assertNotNull(types1);
    assertEquals(3, types1.getSize());
    final XDatas types2 = this.service.getByApplication(ApplicationKey.from("other"));
    assertNotNull(types2);
    assertEquals(0, types2.getSize());
    final XData xData = service.getByName(XDataName.from("other:mytype"));
    assertEquals(null, xData);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) XData(com.enonic.xp.schema.xdata.XData) Test(org.junit.jupiter.api.Test) AbstractSchemaTest(com.enonic.xp.core.impl.schema.AbstractSchemaTest)

Example 4 with XDatas

use of com.enonic.xp.schema.xdata.XDatas in project xp by enonic.

the class BuiltinXDataTypesTest method testGetAll.

@Test
public void testGetAll() {
    final XDatas xdatas = new BuiltinXDataTypes().getAll();
    assertEquals(3, xdatas.getSize());
    assertSchema(xdatas.get(0), XDataName.from(ApplicationKey.MEDIA_MOD + ":imageInfo"), false);
    assertSchema(xdatas.get(1), XDataName.from(ApplicationKey.MEDIA_MOD + ":cameraInfo"), false);
    assertSchema(xdatas.get(2), XDataName.from(ApplicationKey.BASE + ":gpsInfo"), false);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) Test(org.junit.jupiter.api.Test)

Example 5 with XDatas

use of com.enonic.xp.schema.xdata.XDatas in project xp by enonic.

the class BuiltinXDataTypesTest method getGetByApplication.

@Test
public void getGetByApplication() {
    XDatas xdatas = new BuiltinXDataTypes().getByApplication(ApplicationKey.MEDIA_MOD);
    assertEquals(2, xdatas.getSize());
    assertSchema(xdatas.get(0), XDataName.from(ApplicationKey.MEDIA_MOD + ":imageInfo"), false);
    assertSchema(xdatas.get(1), XDataName.from(ApplicationKey.MEDIA_MOD + ":cameraInfo"), false);
    xdatas = new BuiltinXDataTypes().getByApplication(ApplicationKey.BASE);
    assertEquals(1, xdatas.getSize());
    assertSchema(xdatas.get(0), XDataName.from(ApplicationKey.BASE + ":gpsInfo"), false);
}
Also used : XDatas(com.enonic.xp.schema.xdata.XDatas) Test(org.junit.jupiter.api.Test)

Aggregations

XDatas (com.enonic.xp.schema.xdata.XDatas)12 Test (org.junit.jupiter.api.Test)7 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)5 XData (com.enonic.xp.schema.xdata.XData)5 ContentType (com.enonic.xp.schema.content.ContentType)3 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)2 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 ExtraData (com.enonic.xp.content.ExtraData)2 ExtraDatas (com.enonic.xp.content.ExtraDatas)2 ProcessCreateResult (com.enonic.xp.content.processor.ProcessCreateResult)2 Property (com.enonic.xp.data.Property)2 MediaInfo (com.enonic.xp.media.MediaInfo)2 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)2 Application (com.enonic.xp.app.Application)1 Attachment (com.enonic.xp.attachment.Attachment)1 ContentEditor (com.enonic.xp.content.ContentEditor)1 ContentService (com.enonic.xp.content.ContentService)1 EditableContent (com.enonic.xp.content.EditableContent)1 Media (com.enonic.xp.content.Media)1