【问题标题】:How to create Custom Document Type in Nuxeo without Nuxeo Studio如何在没有 Nuxeo Studio 的 Nuxeo 中创建自定义文档类型
【发布时间】:2020-03-29 10:34:57
【问题描述】:

我们目前正在开发没有 Studio 的 Nuxeo 项目,因为它超出了我们的预算。我们的目标是创建自定义 UI 并将 Nuxeo 用作内容管理系统。我们能够使用 SDK 执行 CRUD(创建新文档并添加标题和描述等属性)。

但是我们需要其他自定义属性,例如组织名称、地址、电话号码等。有没有什么方法可以在不使用 Studio 的情况下创建我们自己的文档类型?是否可以在该自定义类型上使用 SDK 执行 CRUD?

有人可以帮忙吗?

【问题讨论】:

    标签: java content-management-system nuxeo


    【解决方案1】:

    首先创建定义新属性的架构(例如myType.xsd):

    <?xml version="1.0"?>
    <xs:schema targetNamespace="http://www.nuxeo.org/ecm/schemas/cf-client/"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="organization" type="xs:string"/>
        <xs:element name="phone" type="xs:string"/>
        <xs:element name="expired" type="xs:date"/>
    </xs:schema>
    

    然后定义引用新创建模式的类型扩展:

    <?xml version="1.0"?>
    <component name="my.project.nuxeo.types">
        <require>org.nuxeo.ecm.core.CoreExtensions</require>
    
        <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
            <schema name="myType" prefix="mt" src="schema/myType.xsd"/>
        </extension>
    
        <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
            <doctype name="MyType" extends="Document">
                <schema name="myType"/>
                <schema name="common" />
                <schema name="dublincore" />
                <schema name="uid" />
                <schema name="file"/>
                <schema name="files" />
                <facet name="Commentable"/>
                <facet name="NXTag"/>
            </doctype>
        </extension>
    </component>
    

    注意:您还可以:

    然后在 MANIFEST.MF 文件中注册上一步中的新类型扩展:

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-ActivationPolicy: lazy
    Bundle-ClassPath: .
    Bundle-Vendor: my.project.nuxeo
    Bundle-Name: my-project-nuxeo-core
    Bundle-SymbolicName: my.project.nuxeo.my-project-nuxeo-core;singleton=true
    Bundle-Version: 1.0.0
    Nuxeo-Component: OSGI-INF/types.xml
    

    使用这种结构将所有这些文件压缩到 jar 存档中:

    my-project-nuxeo-core.jar
    ├── META-INF
    │   └── MANIFEST.MF
    ├── OSGI-INF
    │   └── types.xml
    └── schema
        └── myType.xsd
    

    然后将该结果 jar 存档复制到 Nuxeo 安装的 nxserver/bundles 目录中。重启 Nuxeo,它会自动更新数据库结构。

    您可以在 Nuxeo 文档中找到更多信息 - 例如:https://doc.nuxeo.com/nxdoc/data-modeling/

    【讨论】:

    • 感谢您的回复 :) 您是否有任何资源可以在没有工作室的情况下使用工作流(例如使用您刚刚演示的架构)
    • 在没有 Studio 的情况下设计 Workflow 可能是最困难的过程:-( 其他一切都很容易实现。
    • 感谢您的回复 :) 您如何看待使用 Nuxeo 的出色品质?您出于什么目的使用和选择 Nuxeo 而不是其他技术?您能对此发表看法吗?谢谢
    猜你喜欢
    • 2021-05-13
    • 2014-10-11
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多