在 Alfresco 内容模型中创建一个方面 [英] Create an aspect in Alfresco Content Model

查看:22
本文介绍了在 Alfresco 内容模型中创建一个方面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前开始使用 Alfresco CMS.我需要在我的内容模型中创建一个方面",它必须包含许多属性:

I am starting currently using Alfresco CMS. I need to create an "aspect" in my content model which must contains a number of properties as:

Aspect: 
    property 1 : String
    property 2 : int
    property 3 : int
    property 4 : long

此外,它必须包含另外两个属性,这些属性由以下任一属性组成:

Moreover it must contains two more properties which are composed either of number of properties as:

Format: 
   FormatProperty1: int
   FormatProperty2: int
   FormatProperty3: int

Metadata:
   list1: List<String>
   list2: List<String>
   MetadataProperty 3: boolean

我尚未在 Alfresco 中创建简单的内容模型或方面.根据我之前在关系数据库中的知识,我认为上述结构是表之间的关联.如何在具有方面或更多方面的 Alfresco 内容模型中执行该操作?

I have not yet created neither a simple content model nor an aspect in Alfresco. Based on my previous knowledge in Relational Databases I perceive the above structure as association between tables. How can I carry out that in Alfresco content model with an aspect or more?

推荐答案

你应该看看 这里 首先.在 Alfresco 中创建模型与 DB 相去甚远.

You should take a look here first. Creating a model in Alfresco is far away from a DB.

它只是一个定义良好的 XML.您必须先编写 XML,然后通过引导程序对其进行初始化.

it's just an XML well defined. You have to write the XML first, then initialize it through bootstrap.

示例 XML 模型 cmodModel.xml:

Example XML Model cmodModel.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="custom:custommodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <!-- Optional meta-data about the model -->
    <description>Custom Model</description>
    <author>Whatever</author>
    <version>1.0</version>
    <!-- Imports are required to allow references to definitions in other models -->
    <imports>
        <!-- Import Alfresco Dictionary Definitions -->
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <!-- Import Alfresco Content Domain Model Definitions -->
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
    </imports>
    <!-- Introduction of new namespaces defined by this model -->
    <namespaces>
        <namespace uri="custom.model" prefix="cmod" />
    </namespaces>
    <!-- Lists <String> -->
    <constraints>
        <constraint name="cmod:liststring1" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>value 1</value>
                    <value>value 2</value>
                </list>
            </parameter>
        </constraint>
        <constraint name="cmod:liststring2" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>value 1</value>
                    <value>value 2</value>
                </list>
            </parameter>
        </constraint>
    </constraints> 
    <types>
        <!-- Document Type -->
        <type name="cmod:customDoc">
            <title>Document</title>
            <description>Document</description>
            <parent>cm:content</parent>
            <mandatory-aspects>
                <aspect>cmod:aspectBase</aspect>
                <aspect>cmod:aspectFormat</aspect>
                <aspect>cmod:aspectMetadata</aspect>
            </mandatory-aspects>
        </type>
</types> 
    <!-- Definition of custom aspects  -->
    <aspects>
        <aspect name="cmod:aspectBase">
            <title>Aspect base properties</title>
            <properties>
                <property name="cmod:property1">
                    <title>p1</title>
                    <description>p1</description>
                    <type>d:text</type>
                </property>
                <property name="cmod:property2">
                    <title>p2</title>
                    <description>p2</description>
                    <type>d:int</type>
                </property>
                <property name="cmod:property3">
                    <title>p3</title>
                    <description>p3</description>
                    <type>d:int</type>
                </property>
                <property name="cmod:property4">
                    <title>p4</title>
                    <description>p4</description>
                    <type>d:text</type>
                </property>
            </properties>
        </aspect>
        <aspect name="cmod:aspectFormat">
            <title>Aspect Format</title>
            <properties>
                <property name="cmod:formatProperty1">
                    <title>fp1</title>
                    <description>fp1</description>
                    <type>d:int</type>
                </property>
                <property name="cmod:formatProperty2">
                    <title>fp2</title>
                    <description>fp2</description>
                    <type>d:int</type>
                </property>
                <property name="cmod:formatProperty3">
                    <title>fp3</title>
                    <description>fp3</description>
                    <type>d:int</type>
                </property>
            </properties>
        </aspect>
        <aspect name="cmod:aspectMetadata">
            <title>Aspetto Metadata</title>
            <properties>
                <property name="cmod:metadataProperty1">
                    <title>mp1</title>
                    <description>mp1</description>
                    <type>d:text</type>
                    <constraints>
                        <constraint ref="cmod:liststring1" />
                    </constraints>
                </property>
                <property name="cmod:metadataProperty2">
                    <title>mp2</title>
                    <description>mp2</description>
                    <type>d:text</type>
                    <constraints>
                        <constraint ref="cmod:liststring2" />
                    </constraints>
                </property>
                <property name="cmod:metadataProperty3">
                    <title>mp3</title>
                    <description>mp3</description>
                    <type>d:boolean</type>
                </property>
            </properties>
        </aspect>
</aspects>
</model>

名为 cmod-model-context.xml 的模型上下文

model context named cmod-model-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <!-- Registration of new models -->
    <bean id="extension.dictionaryBootstrap" 
        parent="dictionaryModelBootstrap" 
        depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/model/cmodModel.xml</value>
          </list>
        </property>
    </bean>

</beans>

希望有帮助.

这篇关于在 Alfresco 内容模型中创建一个方面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆