Search in sources :

Example 1 with ApplicationRelativeResolver

use of com.enonic.xp.app.ApplicationRelativeResolver in project xp by enonic.

the class XmlContentTypeParser method doParse.

@Override
protected void doParse(final DomElement root) throws Exception {
    this.resolver = new ApplicationRelativeResolver(this.currentApplication);
    assertTagName(root, "content-type");
    this.builder.displayName(root.getChildValueTrimmed("display-name"));
    this.builder.displayNameI18nKey(root.getChild("display-name") != null ? root.getChild("display-name").getAttribute("i18n") : null);
    this.builder.description(root.getChildValue("description"));
    this.builder.descriptionI18nKey(root.getChild("description") != null ? root.getChild("description").getAttribute("i18n") : null);
    this.builder.displayNameExpression(root.getChildValueTrimmed("display-name-expression"));
    this.builder.superType(this.resolver.toContentTypeName(root.getChildValueTrimmed("super-type")));
    this.builder.setAbstract(root.getChildValueAs("is-abstract", Boolean.class, false));
    this.builder.setFinal(root.getChildValueAs("is-final", Boolean.class, false));
    this.builder.allowChildContent(root.getChildValueAs("allow-child-content", Boolean.class, true));
    this.builder.xData(buildMetaData(root));
    this.builder.displayNameLabel(root.getChildValueTrimmed("display-name-label"));
    this.builder.displayNameLabelI18nKey(root.getChild("display-name-label") != null ? root.getChild("display-name-label").getAttribute("i18n") : null);
    final XmlFormMapper mapper = new XmlFormMapper(this.currentApplication);
    this.builder.form(mapper.buildForm(root.getChild("form")));
    this.builder.schemaConfig(CONFIG_MAPPER.build(root.getChild("config")));
    this.builder.allowChildContentType(root.getChildren("allow-child-content-type").stream().map(e -> e.getValue().trim()).collect(Collectors.toList()));
}
Also used : ApplicationRelativeResolver(com.enonic.xp.app.ApplicationRelativeResolver)

Example 2 with ApplicationRelativeResolver

use of com.enonic.xp.app.ApplicationRelativeResolver in project xp by enonic.

the class XmlRelationshipTypeParser method parseTypes.

private List<ContentTypeName> parseTypes(final DomElement root, final String name) {
    final DomElement types = root.getChild(name);
    if (types == null) {
        return Collections.emptyList();
    }
    final ApplicationRelativeResolver resolver = new ApplicationRelativeResolver(this.currentApplication);
    return types.getChildren("content-type").stream().map(child -> resolver.toContentTypeName(child.getValue().trim())).collect(Collectors.toList());
}
Also used : PublicApi(com.enonic.xp.annotation.PublicApi) List(java.util.List) RelationshipType(com.enonic.xp.schema.relationship.RelationshipType) ApplicationRelativeResolver(com.enonic.xp.app.ApplicationRelativeResolver) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) DomElement(com.enonic.xp.xml.DomElement) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) DomElement(com.enonic.xp.xml.DomElement) ApplicationRelativeResolver(com.enonic.xp.app.ApplicationRelativeResolver)

Example 3 with ApplicationRelativeResolver

use of com.enonic.xp.app.ApplicationRelativeResolver in project xp by enonic.

the class XmlSiteParser method toXDataMapping.

private XDataMapping toXDataMapping(final DomElement xDataElement) {
    final XDataMapping.Builder builder = XDataMapping.create();
    final ApplicationRelativeResolver resolver = new ApplicationRelativeResolver(this.currentApplication);
    final String name = xDataElement.getAttribute(X_DATA_ATTRIBUTE_NAME);
    builder.xDataName(resolver.toXDataName(name));
    final String allowContentTypes = xDataElement.getAttribute(X_DATA_CONTENT_TYPE_ATTRIBUTE);
    builder.allowContentTypes(allowContentTypes);
    final String optional = xDataElement.getAttribute(X_DATA_OPTIONAL_ATTRIBUTE);
    if (optional != null) {
        builder.optional(Boolean.valueOf(optional));
    }
    return builder.build();
}
Also used : XDataMapping(com.enonic.xp.site.XDataMapping) ApplicationRelativeResolver(com.enonic.xp.app.ApplicationRelativeResolver)

Aggregations

ApplicationRelativeResolver (com.enonic.xp.app.ApplicationRelativeResolver)3 PublicApi (com.enonic.xp.annotation.PublicApi)1 ContentTypeName (com.enonic.xp.schema.content.ContentTypeName)1 RelationshipType (com.enonic.xp.schema.relationship.RelationshipType)1 XDataMapping (com.enonic.xp.site.XDataMapping)1 DomElement (com.enonic.xp.xml.DomElement)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1