use of com.enonic.xp.schema.xdata.XData in project xp by enonic.
the class BuiltinXDataTypes method generateSystemXDatas.
private List<XData> generateSystemXDatas(Iterable<XData> systemXDatas) {
final List<XData> generatedSystemXDatas = new ArrayList<>();
for (XData mixin : systemXDatas) {
mixin = XData.create(mixin).icon(loadSchemaIcon(XDATA_FOLDER, mixin.getName().getLocalName())).build();
generatedSystemXDatas.add(mixin);
}
return generatedSystemXDatas;
}
use of com.enonic.xp.schema.xdata.XData in project xp by enonic.
the class XDataServiceImpl method getAll.
@Override
public XDatas getAll() {
final Set<XData> list = new LinkedHashSet<>(this.builtInTypes.getAll().getList());
for (final Application application : this.applicationService.getInstalledApplications()) {
final XDatas types = getByApplication(application.getKey());
list.addAll(types.getList());
}
return XDatas.from(list);
}
use of com.enonic.xp.schema.xdata.XData in project xp by enonic.
the class ExtraDataValidator method validate.
@Override
public void validate(final ContentValidatorParams params, final ValidationErrors.Builder validationErrorsBuilder) {
for (final ExtraData extraData : params.getExtraDatas()) {
final XDataName name = extraData.getName();
final XData xData = this.xDataService.getByName(name);
if (xData == null) {
LOG.warn("Mixin not found: '" + name);
continue;
}
final Form mixinForm = xData.getForm();
if (extraData.getData().getRoot().getPropertySize() > 0) {
OccurrenceValidator.validate(mixinForm, extraData.getData().getRoot(), validationErrorsBuilder);
}
}
}
use of com.enonic.xp.schema.xdata.XData in project xp by enonic.
the class CreateContentHandlerTest method mockCreateContent.
private void mockCreateContent() {
when(this.contentService.create(any(CreateContentParams.class))).thenAnswer(mock -> createContent((CreateContentParams) mock.getArguments()[0]));
final FormItemSet eSet = FormItemSet.create().name("e").addFormItem(Input.create().label("f").name("f").inputType(InputTypeName.DOUBLE).build()).addFormItem(Input.create().label("g").name("g").inputType(InputTypeName.CHECK_BOX).build()).build();
final FormItemSet dSet = FormItemSet.create().name("d").addFormItem(eSet).build();
final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.LONG).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.LONG).build()).addFormItem(Input.create().label("c").name("c").occurrences(0, 10).inputType(InputTypeName.TEXT_LINE).build()).addFormItem(dSet).build();
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
when(this.contentTypeService.getByName(Mockito.eq(getContentType))).thenReturn(contentType);
final PropertyTree extraData = new PropertyTree();
extraData.addDouble("a", 1.0);
extraData.addBoolean("b", true);
final XData xData = XData.create().name(XDataName.from("com.enonic.myapplication:myschema")).addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.DOUBLE).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.CHECK_BOX).build()).build();
final SiteDescriptor siteDescriptor1 = SiteDescriptor.create().form(Form.create().addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.TEXT_LINE).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.CHECK_BOX).build()).build()).build();
final SiteDescriptor siteDescriptor2 = SiteDescriptor.create().form(Form.create().addFormItem(Input.create().label("c").name("c").inputType(InputTypeName.LONG).build()).build()).build();
when(this.siteService.getDescriptor(ApplicationKey.from("appKey1"))).thenReturn(siteDescriptor1);
when(this.siteService.getDescriptor(ApplicationKey.from("appKey2"))).thenReturn(siteDescriptor2);
when(this.xDataService.getByName(Mockito.eq(XDataName.from("com.enonic.myapplication:myschema")))).thenReturn(xData);
when(this.mixinService.inlineFormItems(any(Form.class))).then(returnsFirstArg());
}
use of com.enonic.xp.schema.xdata.XData in project xp by enonic.
the class ModifyContentHandlerTest method mockXData.
private void mockXData() {
final FormItemSet cSet = FormItemSet.create().name("c").occurrences(0, 10).addFormItem(Input.create().label("d").name("d").inputType(InputTypeName.CHECK_BOX).build()).addFormItem(Input.create().label("e").name("e").occurrences(0, 0).inputType(InputTypeName.TEXT_LINE).build()).addFormItem(Input.create().label("f").name("f").inputType(InputTypeName.LONG).build()).build();
final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.DOUBLE).build()).addFormItem(Input.create().label("b").name("b").inputType(InputTypeName.TEXT_LINE).build()).addFormItem(cSet).addFormItem(Input.create().label("z").name("z").occurrences(0, 10).inputType(InputTypeName.TEXT_LINE).build()).build();
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
when(this.contentTypeService.getByName(eq(getContentType))).thenReturn(contentType);
final XData xData1 = XData.create().name(XDataName.from("com.enonic.myapplication:myschema")).addFormItem(Input.create().label("a").name("a").inputType(InputTypeName.DOUBLE).build()).build();
when(this.xDataService.getByName(eq(xData1.getName()))).thenReturn(xData1);
final XData xData2 = XData.create().name(XDataName.from("com.enonic.myapplication:other")).addFormItem(Input.create().label("name").name("name").inputType(InputTypeName.TEXT_LINE).build()).build();
when(this.xDataService.getByName(eq(xData1.getName()))).thenReturn(xData1);
when(this.xDataService.getByName(eq(xData2.getName()))).thenReturn(xData2);
when(this.mixinService.inlineFormItems(any(Form.class))).then(returnsFirstArg());
}
Aggregations